Best JavaScript code snippet using wpt
assembler.js
Source:assembler.js
...64}65/**66 * Get a constant value and check that it is in range.67 */68function constValue(r, min = 0, max = 255) {69 const d = typeof r === 'string' ? parseInt(r) : r;70 if (isNaN(d)) {71 throw 'constant is not a number.';72 }73 if (d < min || d > max) {74 throw '[Ks] out of range: ' + min + '<>' + max;75 }76 return d;77}78/*79 * Fit a twos-complement number into the specific bit count80 */81function fitTwoC(r, bits) {82 if (bits < 2) {83 throw 'Need at least 2 bits to be signed.';84 }85 if (bits > 16) {86 throw 'fitTwoC only works on 16bit numbers for now.';87 }88 if (Math.abs(r) > Math.pow(2, bits - 1))89 throw 'Not enough bits for number. (' + r + ', ' + bits + ')';90 if (r < 0) {91 r = 0xffff + r + 1;92 }93 const mask = 0xffff >> (16 - bits);94 return r & mask;95}96/**97 * Determin if input is an address or label and lookup if required.98 * If label that doesn't exist, return NaN.99 * If offset is not 0, convert from absolute address to relative.100 */101function constOrLabel(c, labels, offset = 0) {102 if (typeof c === 'string') {103 let d = parseInt(c);104 if (isNaN(d)) {105 if (c in labels) {106 d = labels[c] - offset;107 }108 else {109 return NaN;110 }111 }112 c = d;113 }114 return c;115}116/**117 * Convert number to hex and left pad it118 * @param len default to words.119 */120function zeroPad(r, len = 4) {121 r = Number(r).toString(16);122 const base = Array(len + 1).join('0');123 const t = base.substr(0, len - r.length) + r;124 return t;125}126/**127 * Get an Indirect Address Register and shift it to where it is commonly found.128 */129function stldXYZ(xyz) {130 switch (xyz) {131 case 'X':132 return 0x900c;133 case 'X+':134 return 0x900d;135 case '-X':136 return 0x900e;137 case 'Y':138 return 0x8008;139 case 'Y+':140 return 0x9009;141 case '-Y':142 return 0x900a;143 case 'Z':144 return 0x8000;145 case 'Z+':146 return 0x9001;147 case '-Z':148 return 0x9002;149 default:150 throw 'Not -?[XYZ]\\+?';151 }152}153/**154 * Get an Indirect Address Register with displacement and shift it to where it is commonly found.155 */156function stldYZq(yzq) {157 const d = yzq.match(/([YZ])\+(\d+)/);158 let r = 0x8000;159 if (d == null) {160 throw 'Invalid arguments';161 }162 switch (d[1]) {163 case 'Y':164 r |= 0x8;165 break;166 case 'Z':167 /* r|= 0; */168 break;169 default:170 throw 'Not Y or Z with q';171 }172 const q = parseInt(d[2]);173 if (q < 0 || q > 64) {174 throw 'q is out of range';175 }176 r |= ((q & 0x20) << 8) | ((q & 0x18) << 7) | (q & 0x7);177 return r;178}179const SEflag = (a) => zeroPad(0x9408 | (constValue(a, 0, 7) << 4));180/**181 * Table of instructions that can be assembled.182 */183const OPTABLE = {184 ADD(a, b) {185 const r = 0x0c00 | destRindex(a) | srcRindex(b);186 return zeroPad(r);187 },188 ADC(a, b) {189 const r = 0x1c00 | destRindex(a) | srcRindex(b);190 return zeroPad(r);191 },192 ADIW(a, b) {193 let r = 0x9600;194 const dm = a.match(/[Rr](24|26|28|30)/);195 if (!dm) {196 throw 'Rd must be 24, 26, 28, or 30';197 }198 let d = parseInt(dm[1]);199 d = (d - 24) / 2;200 r |= (d & 0x3) << 4;201 const k = constValue(b, 0, 63);202 r |= ((k & 0x30) << 2) | (k & 0x0f);203 return zeroPad(r);204 },205 AND(a, b) {206 const r = 0x2000 | destRindex(a) | srcRindex(b);207 return zeroPad(r);208 },209 ANDI(a, b) {210 let r = 0x7000 | (destRindex(a, 16, 31) & 0xf0);211 const k = constValue(b);212 r |= ((k & 0xf0) << 4) | (k & 0xf);213 return zeroPad(r);214 },215 ASR(a) {216 const r = 0x9405 | destRindex(a);217 return zeroPad(r);218 },219 BCLR(a) {220 let r = 0x9488;221 const s = constValue(a, 0, 7);222 r |= (s & 0x7) << 4;223 return zeroPad(r);224 },225 BLD(a, b) {226 const r = 0xf800 | destRindex(a) | (constValue(b, 0, 7) & 0x7);227 return zeroPad(r);228 },229 BRBC(a, b, byteLoc, labels) {230 const k = constOrLabel(b, labels, byteLoc + 2);231 if (isNaN(k)) {232 return (l) => OPTABLE['BRBC'](a, b, byteLoc, l);233 }234 let r = 0xf400 | constValue(a, 0, 7);235 r |= fitTwoC(constValue(k >> 1, -64, 63), 7) << 3;236 return zeroPad(r);237 },238 BRBS(a, b, byteLoc, labels) {239 const k = constOrLabel(b, labels, byteLoc + 2);240 if (isNaN(k)) {241 return (l) => OPTABLE['BRBS'](a, b, byteLoc, l);242 }243 let r = 0xf000 | constValue(a, 0, 7);244 r |= fitTwoC(constValue(k >> 1, -64, 63), 7) << 3;245 return zeroPad(r);246 },247 BRCC(a, _, byteLoc, labels) {248 return OPTABLE['BRBC']('0', a, byteLoc, labels);249 },250 BRCS(a, _, byteLoc, labels) {251 return OPTABLE['BRBS']('0', a, byteLoc, labels);252 },253 BREAK() {254 return '9598';255 },256 BREQ(a, _, byteLoc, labels) {257 return OPTABLE['BRBS']('1', a, byteLoc, labels);258 },259 BRGE(a, _, byteLoc, labels) {260 return OPTABLE['BRBC']('4', a, byteLoc, labels);261 },262 BRHC(a, _, byteLoc, labels) {263 return OPTABLE['BRBC']('5', a, byteLoc, labels);264 },265 BRHS(a, _, byteLoc, labels) {266 return OPTABLE['BRBS']('5', a, byteLoc, labels);267 },268 BRID(a, _, byteLoc, labels) {269 return OPTABLE['BRBC']('7', a, byteLoc, labels);270 },271 BRIE(a, _, byteLoc, labels) {272 return OPTABLE['BRBS']('7', a, byteLoc, labels);273 },274 BRLO(a, _, byteLoc, labels) {275 return OPTABLE['BRBS']('0', a, byteLoc, labels);276 },277 BRLT(a, _, byteLoc, labels) {278 return OPTABLE['BRBS']('4', a, byteLoc, labels);279 },280 BRMI(a, _, byteLoc, labels) {281 return OPTABLE['BRBS']('2', a, byteLoc, labels);282 },283 BRNE(a, _, byteLoc, labels) {284 return OPTABLE['BRBC']('1', a, byteLoc, labels);285 },286 BRPL(a, _, byteLoc, labels) {287 return OPTABLE['BRBC']('2', a, byteLoc, labels);288 },289 BRSH(a, _, byteLoc, labels) {290 return OPTABLE['BRBC']('0', a, byteLoc, labels);291 },292 BRTC(a, _, byteLoc, labels) {293 return OPTABLE['BRBC']('6', a, byteLoc, labels);294 },295 BRTS(a, _, byteLoc, labels) {296 return OPTABLE['BRBS']('6', a, byteLoc, labels);297 },298 BRVC(a, _, byteLoc, labels) {299 return OPTABLE['BRBC']('3', a, byteLoc, labels);300 },301 BRVS(a, _, byteLoc, labels) {302 return OPTABLE['BRBS']('3', a, byteLoc, labels);303 },304 BSET(a) {305 let r = 0x9408;306 const s = constValue(a, 0, 7);307 r |= (s & 0x7) << 4;308 return zeroPad(r);309 },310 BST(a, b) {311 const r = 0xfa00 | destRindex(a) | constValue(b, 0, 7);312 return zeroPad(r);313 },314 CALL(a, b, byteLoc, labels) {315 let k = constOrLabel(a, labels);316 if (isNaN(k)) {317 return [(l) => OPTABLE['CALL'](a, b, byteLoc, l), 'xxxx'];318 }319 let r = 0x940e;320 k = constValue(k, 0, 0x400000) >> 1;321 const lk = k & 0xffff;322 const hk = (k >> 16) & 0x3f;323 r |= ((hk & 0x3e) << 3) | (hk & 1);324 return [zeroPad(r), zeroPad(lk)];325 },326 CBI(a, b) {327 const r = 0x9800 | (constValue(a, 0, 31) << 3) | constValue(b, 0, 7);328 return zeroPad(r);329 },330 CRB(a, b, byteLoc, l) {331 const k = constValue(b);332 return OPTABLE['ANDI'](a.toString(), (~k & 0xff).toString(), byteLoc, l);333 },334 CLC() {335 return '9488';336 },337 CLH() {338 return '94d8';339 },340 CLI() {341 return '94f8';342 },343 CLN() {344 return '94a8';345 },346 CLR(a, _, byteLoc, l) {347 return OPTABLE['EOR'](a, a, byteLoc, l);348 },349 CLS() {350 return '94c8';351 },352 CLT() {353 return '94e8';354 },355 CLV() {356 return '94b8';357 },358 CLZ() {359 return '9498';360 },361 COM(a) {362 const r = 0x9400 | destRindex(a);363 return zeroPad(r);364 },365 CP(a, b) {366 const r = 0x1400 | destRindex(a) | srcRindex(b);367 return zeroPad(r);368 },369 CPC(a, b) {370 const r = 0x0400 | destRindex(a) | srcRindex(b);371 return zeroPad(r);372 },373 CPI(a, b) {374 let r = 0x3000 | (destRindex(a, 16, 31) & 0xf0);375 const k = constValue(b);376 r |= ((k & 0xf0) << 4) | (k & 0xf);377 return zeroPad(r);378 },379 CPSE(a, b) {380 const r = 0x1000 | destRindex(a) | srcRindex(b);381 return zeroPad(r);382 },383 DEC(a) {384 const r = 0x940a | destRindex(a);385 return zeroPad(r);386 },387 DES(a) {388 const r = 0x940b | (constValue(a, 0, 15) << 4);389 return zeroPad(r);390 },391 EICALL() {392 return '9519';393 },394 EIJMP() {395 return '9419';396 },397 ELPM(a, b) {398 if (typeof a === 'undefined' || a === '') {399 return '95d8';400 }401 else {402 let r = 0x9000 | destRindex(a);403 switch (b) {404 case 'Z':405 r |= 6;406 break;407 case 'Z+':408 r |= 7;409 break;410 default:411 throw 'Bad operand';412 }413 return zeroPad(r);414 }415 },416 EOR(a, b) {417 const r = 0x2400 | destRindex(a) | srcRindex(b);418 return zeroPad(r);419 },420 FMUL(a, b) {421 const r = 0x0308 | (destRindex(a, 16, 23) & 0x70) | (srcRindex(b, 16, 23) & 0x7);422 return zeroPad(r);423 },424 FMULS(a, b) {425 const r = 0x0380 | (destRindex(a, 16, 23) & 0x70) | (srcRindex(b, 16, 23) & 0x7);426 return zeroPad(r);427 },428 FMULSU(a, b) {429 const r = 0x0388 | (destRindex(a, 16, 23) & 0x70) | (srcRindex(b, 16, 23) & 0x7);430 return zeroPad(r);431 },432 ICALL() {433 return '9509';434 },435 IJMP() {436 return '9409';437 },438 IN(a, b) {439 let r = 0xb000 | destRindex(a);440 const A = constValue(b, 0, 63);441 r |= ((A & 0x30) << 5) | (A & 0x0f);442 return zeroPad(r);443 },444 INC(a) {445 const r = 0x9403 | destRindex(a);446 return zeroPad(r);447 },448 JMP(a, b, byteLoc, labels) {449 let k = constOrLabel(a, labels);450 if (isNaN(k)) {451 return [(l) => OPTABLE['JMP'](a, b, byteLoc, l), 'xxxx'];452 }453 let r = 0x940c;454 k = constValue(k, 0, 0x400000) >> 1;455 const lk = k & 0xffff;456 const hk = (k >> 16) & 0x3f;457 r |= ((hk & 0x3e) << 3) | (hk & 1);458 return [zeroPad(r), zeroPad(lk)];459 },460 LAC(a, b) {461 if (a !== 'Z') {462 throw 'First Operand is not Z';463 }464 const r = 0x9206 | destRindex(b);465 return zeroPad(r);466 },467 LAS(a, b) {468 if (a !== 'Z') {469 throw 'First Operand is not Z';470 }471 const r = 0x9205 | destRindex(b);472 return zeroPad(r);473 },474 LAT(a, b) {475 if (a !== 'Z') {476 throw 'First Operand is not Z';477 }478 const r = 0x9207 | destRindex(b);479 return zeroPad(r);480 },481 LD(a, b) {482 const r = 0x0000 | destRindex(a) | stldXYZ(b);483 return zeroPad(r);484 },485 LDD(a, b) {486 const r = 0x0000 | destRindex(a) | stldYZq(b);487 return zeroPad(r);488 },489 LDI(a, b) {490 let r = 0xe000 | (destRindex(a, 16, 31) & 0xf0);491 const k = constValue(b);492 r |= ((k & 0xf0) << 4) | (k & 0xf);493 return zeroPad(r);494 },495 LDS(a, b) {496 const k = constValue(b, 0, 65535);497 const r = 0x9000 | destRindex(a);498 return [zeroPad(r), zeroPad(k)];499 },500 LPM(a, b) {501 if (typeof a === 'undefined' || a === '') {502 return '95c8';503 }504 else {505 let r = 0x9000 | destRindex(a);506 switch (b) {507 case 'Z':508 r |= 4;509 break;510 case 'Z+':511 r |= 5;512 break;513 default:514 throw 'Bad operand';515 }516 return zeroPad(r);517 }518 },519 LSL(a, _, byteLoc, l) {520 return OPTABLE['ADD'](a, a, byteLoc, l);521 },522 LSR(a) {523 const r = 0x9406 | destRindex(a);524 return zeroPad(r);525 },526 MOV(a, b) {527 const r = 0x2c00 | destRindex(a) | srcRindex(b);528 return zeroPad(r);529 },530 MOVW(a, b) {531 /* use destRindex on both here for simpler shifting */532 const r = 0x0100 | ((destRindex(a) >> 1) & 0xf0) | ((destRindex(b) >> 5) & 0xf);533 return zeroPad(r);534 },535 MUL(a, b) {536 const r = 0x9c00 | destRindex(a) | srcRindex(b);537 return zeroPad(r);538 },539 MULS(a, b) {540 const r = 0x0200 | (destRindex(a, 16, 31) & 0xf0) | (srcRindex(b, 16, 31) & 0xf);541 return zeroPad(r);542 },543 MULSU(a, b) {544 const r = 0x0300 | (destRindex(a, 16, 23) & 0x70) | (srcRindex(b, 16, 23) & 0x7);545 return zeroPad(r);546 },547 NEG(a) {548 const r = 0x9401 | destRindex(a);549 return zeroPad(r);550 },551 NOP() {552 return '0000';553 },554 OR(a, b) {555 const r = 0x2800 | destRindex(a) | srcRindex(b);556 return zeroPad(r);557 },558 ORI(a, b) {559 let r = 0x6000 | (destRindex(a, 16, 31) & 0xf0);560 const k = constValue(b);561 r |= ((k & 0xf0) << 4) | (k & 0xf);562 return zeroPad(r);563 },564 OUT(a, b) {565 let r = 0xb800 | destRindex(b);566 const A = constValue(a, 0, 63);567 r |= ((A & 0x30) << 5) | (A & 0x0f);568 return zeroPad(r);569 },570 POP(a) {571 const r = 0x900f | destRindex(a);572 return zeroPad(r);573 },574 PUSH(a) {575 const r = 0x920f | destRindex(a);576 return zeroPad(r);577 },578 RCALL(a, b, byteLoc, labels) {579 const k = constOrLabel(a, labels, byteLoc + 2);580 if (isNaN(k)) {581 return (l) => OPTABLE['RCALL'](a, b, byteLoc, l);582 }583 const r = 0xd000 | fitTwoC(constValue(k >> 1, -2048, 2047), 12);584 return zeroPad(r);585 },586 RET() {587 return '9508';588 },589 RETI() {590 return '9518';591 },592 RJMP(a, b, byteLoc, labels) {593 const k = constOrLabel(a, labels, byteLoc + 2);594 if (isNaN(k)) {595 return (l) => OPTABLE['RJMP'](a, b, byteLoc, l);596 }597 const r = 0xc000 | fitTwoC(constValue(k >> 1, -2048, 2047), 12);598 return zeroPad(r);599 },600 ROL(a, _, byteLoc, l) {601 return OPTABLE['ADC'](a, a, byteLoc, l);602 },603 ROR(a) {604 const r = 0x9407 | destRindex(a);605 return zeroPad(r);606 },607 SBC(a, b) {608 const r = 0x0800 | destRindex(a) | srcRindex(b);609 return zeroPad(r);610 },611 SBCI(a, b) {612 let r = 0x4000 | (destRindex(a, 16, 31) & 0xf0);613 const k = constValue(b);614 r |= ((k & 0xf0) << 4) | (k & 0x0f);615 return zeroPad(r);616 },617 SBI(a, b) {618 const r = 0x9a00 | (constValue(a, 0, 31) << 3) | constValue(b, 0, 7);619 return zeroPad(r);620 },621 SBIC(a, b) {622 const r = 0x9900 | (constValue(a, 0, 31) << 3) | constValue(b, 0, 7);623 return zeroPad(r);624 },625 SBIS(a, b) {626 const r = 0x9b00 | (constValue(a, 0, 31) << 3) | constValue(b, 0, 7);627 return zeroPad(r);628 },629 SBIW(a, b) {630 let r = 0x9700;631 const dm = a.match(/[Rr](24|26|28|30)/);632 if (!dm) {633 throw 'Rd must be 24, 26, 28, or 30';634 }635 let d = parseInt(dm[1]);636 d = (d - 24) / 2;637 r |= (d & 0x3) << 4;638 const k = constValue(b, 0, 63);639 r |= ((k & 0x30) << 2) | (k & 0x0f);640 return zeroPad(r);641 },642 SBR(a, b) {643 let r = 0x6000 | (destRindex(a, 16, 31) & 0xf0);644 const k = constValue(b);645 r |= ((k & 0xf0) << 4) | (k & 0x0f);646 return zeroPad(r);647 },648 SBRC(a, b) {649 const r = 0xfc00 | destRindex(a) | constValue(b, 0, 7);650 return zeroPad(r);651 },652 SBRS(a, b) {653 const r = 0xfe00 | destRindex(a) | constValue(b, 0, 7);654 return zeroPad(r);655 },656 SEC() {657 return SEflag(0);658 },659 SEH() {660 return SEflag(5);661 },662 SEI() {663 return SEflag(7);664 },665 SEN() {666 return SEflag(2);667 },668 SER(a) {669 const r = 0xef0f | (destRindex(a, 16, 31) & 0xf0);670 return zeroPad(r);671 },672 SES() {673 return SEflag(4);674 },675 SET() {676 return SEflag(6);677 },678 SEV() {679 return SEflag(3);680 },681 SEZ() {682 return SEflag(1);683 },684 SLEEP() {685 return '9588';686 },687 SPM(a) {688 if (typeof a === 'undefined' || a === '') {689 return '95e8';690 }691 else {692 if (a !== 'Z+') {693 throw 'Bad param to SPM';694 }695 return '95f8';696 }697 },698 ST(a, b) {699 const r = 0x0200 | destRindex(b) | stldXYZ(a);700 return zeroPad(r);701 },702 STD(a, b) {703 const r = 0x0200 | destRindex(b) | stldYZq(a);704 return zeroPad(r);705 },706 STS(a, b) {707 const k = constValue(a, 0, 65535);708 const r = 0x9200 | destRindex(b);709 return [zeroPad(r), zeroPad(k)];710 },711 SUB(a, b) {712 const r = 0x1800 | destRindex(a) | srcRindex(b);713 return zeroPad(r);714 },715 SUBI(a, b) {716 let r = 0x5000 | (destRindex(a, 16, 31) & 0xf0);717 const k = constValue(b);718 r |= ((k & 0xf0) << 4) | (k & 0xf);719 return zeroPad(r);720 },721 SWAP(a) {722 const r = 0x9402 | destRindex(a);723 return zeroPad(r);724 },725 TST(a, _, byteLoc, l) {726 return OPTABLE['AND'](a, a, byteLoc, l);727 },728 WDR() {729 return '95a8';730 },731 XCH(a, b) {...
usercard.js
Source:usercard.js
1import { Platform } from 'react-native';2import {3 StyleSheet4 } from 'react-native';5import constvalue from './component_const';6 module.exports = StyleSheet.create({7 container: {8 backgroundColor: constvalue.BACKGROUDCOLOR,9 10 },11 12 header: constvalue.HDEARR,13 logo: constvalue.LOGO14 ,15 listitem: {16 borderRadius: constvalue.CARDVIEW_CORNER,17 backgroundColor: constvalue.BACKGROUDCOLOR,18 19 20 21 },22 listimage: {23 borderRadius: constvalue.CARDVIEW_CORNER,24 height: 176,25 width: null,26 flex: 1,27 zIndex: 0,28 },29 itemcontent: {30 marginTop: 15,31 marginLeft: 18,32 marginRight: 20,33 fontSize: 18,34 fontFamily:'Montserrat-Medium',35 color: '#FFFFFF'36 },37 itemtitle: {38 marginTop: 10,39 marginLeft: 20,40 marginRight: 20,41 marginBottom: 10,42 fontSize: 12,43 fontFamily:'Montserrat-Bold',44 45 },46 listitemdetails: {47 borderBottomWidth: 0,48 }49 ,50 controlbutton: {51 marginTop: -34,52 alignSelf: 'flex-end',53 marginRight: 13,54 height: 28,55 width: 109,56 borderRadius: 8,57 backgroundColor: constvalue.SMALLBUTTON_BACKGROUND,58 zIndex: 1,59 paddingLeft: 13,60 }61 ,62 buttontext: {63 marginTop: 4,64 fontSize: 18,65 color: '#FFFFFF'66 },67 listview: {68 shadowOpacity: 0.5,69 shadowRadius: 9,70 shadowOffset: { width: 0, height: 0 },71 borderRadius: constvalue.CARDVIEW_CORNER,72 backgroundColor: constvalue.FROTGROUNDCOLOR,73 elevation: 2,74 flex: 1,75 flexDirection: 'column',76 marginLeft:14,77 marginRight: 16,78 marginTop: 20,79 marginBottom: 7,80 },81 imageview: {82 shadowOpacity: 0.4,83 shadowRadius: 7,84 shadowOffset: { width: 0, height: 0 },85 borderRadius: constvalue.CARDVIEW_CORNER,86 backgroundColor: constvalue.FROTGROUNDCOLOR,87 // elevation: 2,88 },89 linearGradient: {90 marginTop:9,91 paddingTop: 7,92 height:50,93 width:50,94 paddingLeft: 8,95 borderRadius: 25,96 marginLeft: 14,97 },98 buttonText: {99 fontSize: 18,100 fontFamily:'Montserrat-Medium',101 textAlign: 'center',102 margin: 10,103 color: '#ffffff',104 backgroundColor: 'transparent',105 },106 buttontext_small: {107 marginTop: 4,108 fontSize: 14,109 color: '#FFFFFF',110 fontFamily:'Montserrat-Medium',111 },112 popcontrolbutton_left: {113 marginTop: 45,114 alignSelf: 'flex-end',115 marginRight: -1,116 height: 22,117 width: 100,118 borderRadius: 8,119 backgroundColor: constvalue.SMALLBUTTON_BACKGROUND,120 zIndex: 1,121 paddingLeft: 13,122 }123 ,124 popcontrolbutton_left_deactivate: {125 marginTop: 45,126 alignSelf: 'flex-end',127 marginRight: -2,128 height: 24,129 width: 107,130 borderRadius: 8,131 backgroundColor:'#000000',132 zIndex: 1,133 paddingLeft: 13,134 }135 ,136 popcontrolbutton_right: {137 marginTop: 45,138 alignSelf: 'flex-start',139 marginRight: 0,140 height: 24,141 width: 87,142 borderRadius: 8,143 backgroundColor: constvalue.SMALLBUTTON_BACKGROUND,144 zIndex: 1,145 paddingLeft: 15,146 }147 ,148 popcontrolbutton_right_deactive: {149 marginTop: 45,150 alignSelf: 'flex-start',151 marginRight: 0,152 height: 24,153 width: 87,154 borderRadius: 8,155 backgroundColor:'#000000',156 zIndex: 1,157 paddingLeft: 15,158 },159 categorytitletext:{160 color:'#FFFFFF',161 fontSize:30,162 marginTop:39,163 marginLeft: 29,164 lineHeight:37,165 fontFamily:'Montserrat-SemiBold',166 marginBottom: 7,167 },168 categorytext:{169 color:'#FFFFFF',170 fontSize:18,171 marginLeft: 32,172 lineHeight:47,173 fontFamily:'Montserrat-Medium'174 }175 ,176 clearbutton:{177 alignSelf: 'flex-start',178 fontFamily:'Montserrat-Medium',179 fontSize:18,180 color:'rgb(255,6,23)',181 marginLeft: 25,182 marginTop:59,183 },184 cancelbutton:{185 alignSelf: 'flex-end',186 fontFamily:'Montserrat-Medium',187 fontSize:18,188 color:'#FFFFFF',189 marginRight: 16,190 marginTop: 59,191 },192 searchbox:{193 height:80,194 backgroundColor:'#FFFFFF'195 },196 searchlistitemtext:{197 fontSize:18,198 fontFamily:'Montserrat-Medium',199 color:'#FFFFFF',200 lineHeight:37,201 marginLeft: 32,202 203 }...
authSlice.ts
Source:authSlice.ts
1import { createSlice } from "@reduxjs/toolkit";2import { constValue } from "../values";3export const counterSlice = createSlice({4 name: "auth",5 initialState: {6 loggedIn: localStorage.getItem(constValue.TOKEN_KEY) ? true : false,7 token: localStorage.getItem(constValue.TOKEN_KEY),8 user: localStorage.getItem(constValue.USER_KEY),9 },10 reducers: {11 setUserToken: (state, action) => {12 state.token = action.payload;13 localStorage.setItem(constValue.TOKEN_KEY, JSON.stringify(action.payload));14 },15 setUser: (state, action) => {16 state.user = action.payload;17 localStorage.setItem(constValue.USER_KEY, action.payload);18 },19 login: (state, action) => {20 state.loggedIn = true;21 state.token = action.payload.token;22 state.user = action.payload.user;23 localStorage.setItem(constValue.TOKEN_KEY, action.payload.token);24 localStorage.setItem(constValue.USER_KEY, JSON.stringify(action.payload.user));25 },26 logout: (state) => {27 state.loggedIn = false;28 state.token = null;29 state.user = null;30 localStorage.removeItem(constValue.TOKEN_KEY);31 localStorage.removeItem(constValue.USER_KEY);32 },33 },34});35export const { setUserToken, setUser, login, logout } = counterSlice.actions;...
Using AI Code Generation
1const wpt = require('./wpt');2console.log(wpt.constValue());3module.exports = {4 constValue: function() {5 return 'value';6 }7}8const wpt = require('./wpt');9console.log(wpt.nonExportedMethod());10module.exports = {11 constValue: function() {12 return 'value';13 },14 nonExportedMethod: function() {15 return 'value';16 }17}18const wpt = require('./wpt');19console.log(wpt.nonExportedMethod());20module.exports = {21 constValue: function() {22 return 'value';23 },24 nonExportedMethod: function() {25 return 'value';26 }27}28const wpt = require('./wpt');29console.log(wpt['nonExportedMethod']());30module.exports = {31 constValue: function() {32 return 'value';33 },34 nonExportedMethod: function() {35 return 'value';36 }37}38const wpt = require('./wpt');39console.log(wpt['nonExportedMethod']());40module.exports = {41 constValue: function() {42 return 'value';43 },44 nonExportedMethod: function()
Using AI Code Generation
1const wptConst = require('./wptConst.js');2console.log(wptConst.constValue);3const constValue = 1;4module.exports = {constValue};5Your name to display (optional):6Your name to display (optional):
Using AI Code Generation
1const wptConst = require('./wptConst.js');2const constValue = wptConst.constValue;3console.log(constValue('WPT_URL'));4const wptConst = {5 constValue: function(constantName) {6 switch (constantName) {7 return 'www.webpagetest.org';8 break;9 return 'A.BCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';10 break;11 return 'Dulles:Chrome';12 break;13 return 3;14 break;15 return 'Cable';16 break;17 return 0;18 break;19 return 1;20 break;21 return 1;22 break;23 return 1;24 break;25 return 'wptScript.js';26 break;27 return 'arg1,arg2';28 break;29 return 'WPT Test';30 break;31 return 600;32 break;33 return 30;34 break;35 return 1800;36 break;37 return '170709_2P_5e5b9f5c5d5b0b0c5f5f5d5f5f5e5f5e';38 break;39 return 'testResults';40 break;41 return 'testResults.json';42 break;43 return 'testResultsDir';44 break;45 return 'testResultsJsonDir';46 break;47 return 'testResults.csv';48 break;
Using AI Code Generation
1console.log(wpt.constValue());2console.log(wpt.constValue());3const constValue = () => {4 return 1;5};6console.log(wpt.constValue());7console.log(wpt.constValue());
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!