Best JavaScript code snippet using wpt
levelUp.js
Source:levelUp.js
1export const archerLevelUp = async (args) => {2 let upperBound = 03 let lowerBound = 04 const bonus = Math.floor((Math.random() * 3) + 1)5 if(bonus == 3){6 upperBound = 1.57 lowerBound = 1.1798 }else if(bonus == 2){9 upperBound = 1.2510 lowerBound = 1.2511 }else{12 lowerBound = 1.413 upperBound = 1.199714 }15 await args.mutateChar({16 variables: {17 characterId: args.characterId,18 statId: args.baseStats._id,19 charisma: (Math.round(args.baseStats.charisma * upperBound)),20 constitution: (Math.round(args.baseStats.constitution * lowerBound)),21 dexterity: (Math.round(args.baseStats.dexterity * upperBound)),22 health: (Math.round(args.baseStats.health * lowerBound)),23 intelligence: (Math.round(args.baseStats.intelligence * lowerBound)),24 perception: (Math.round(args.baseStats.perception * upperBound)),25 speed: (Math.round(args.baseStats.speed * lowerBound)),26 strength: (Math.round(args.baseStats.strength * lowerBound)),27 wisdom: (Math.round(args.baseStats.wisdom * lowerBound)),28 level: args.levels,29 experience: args.randomXP30 }31 })32}33export const bardLevelUp = async (args) => {34 let upperBound = 035 let lowerBound = 036 const bonus = Math.floor((Math.random() * 3) + 1)37 if(bonus == 3){38 upperBound = 1.839 lowerBound = 1.340 }else if(bonus == 2){41 upperBound = 1.3542 lowerBound = 1.3543 }else{44 lowerBound = 1.545 upperBound = 1.2546 }47 await args.mutateChar({48 variables: {49 characterId: args.characterId,50 statId: args.baseStats._id,51 charisma: (Math.round(args.baseStats.charisma * upperBound)),52 constitution: (Math.round(args.baseStats.constitution * lowerBound)),53 dexterity: (Math.round(args.baseStats.dexterity * upperBound)),54 health: (Math.round(args.baseStats.health * lowerBound)),55 intelligence: (Math.round(args.baseStats.intelligence * lowerBound)),56 perception: (Math.round(args.baseStats.perception * upperBound)),57 speed: (Math.round(args.baseStats.speed * lowerBound)),58 strength: (Math.round(args.baseStats.strength * lowerBound)),59 wisdom: (Math.round(args.baseStats.wisdom * lowerBound)),60 level: args.levels,61 experience: args.randomXP62 }63 })64}65export const sniperLevelUp = async (args) => {66 let upperBound = 067 let lowerBound = 068 const bonus = Math.floor((Math.random() * 3) + 1)69 if(bonus == 3){70 upperBound = 1.871 lowerBound = 1.372 }else if(bonus == 2){73 upperBound = 1.3574 lowerBound = 1.3575 }else{76 lowerBound = 1.577 upperBound = 1.2578 }79 await args.mutateChar({80 variables: {81 characterId: args.characterId,82 statId: args.baseStats._id,83 charisma: (Math.round(args.baseStats.charisma * upperBound)),84 constitution: (Math.round(args.baseStats.constitution * lowerBound)),85 dexterity: (Math.round(args.baseStats.dexterity * upperBound)),86 health: (Math.round(args.baseStats.health * lowerBound)),87 intelligence: (Math.round(args.baseStats.intelligence * lowerBound)),88 perception: (Math.round(args.baseStats.perception * upperBound)),89 speed: (Math.round(args.baseStats.speed * lowerBound)),90 strength: (Math.round(args.baseStats.strength * lowerBound)),91 wisdom: (Math.round(args.baseStats.wisdom * lowerBound)),92 level: args.levels,93 experience: args.randomXP94 }95 })96}97export const arcanistLevelUp = async (args) => {98 let upperBound = 099 let lowerBound = 0100 const bonus = Math.floor((Math.random() * 3) + 1)101 if(bonus == 3){102 upperBound = 1.5103 lowerBound = 1.179104 }else if(bonus == 2){105 upperBound = 1.25106 lowerBound = 1.25107 }else{108 lowerBound = 1.4109 upperBound = 1.1997110 }111 await args.mutateChar({112 variables: {113 characterId: args.characterId,114 statId: args.baseStats._id,115 charisma: (Math.round(args.baseStats.charisma * lowerBound)),116 constitution: (Math.round(args.baseStats.constitution * lowerBound)),117 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),118 health: (Math.round(args.baseStats.health * lowerBound)),119 intelligence: (Math.round(args.baseStats.intelligence * upperBound)),120 perception: (Math.round(args.baseStats.perception * upperBound)),121 speed: (Math.round(args.baseStats.speed * lowerBound)),122 strength: (Math.round(args.baseStats.strength * lowerBound)),123 wisdom: (Math.round(args.baseStats.wisdom * upperBound)),124 level: args.levels,125 experience: args.randomXP126 }127 })128}129export const scholarLevelUp = async (args) => {130 let upperBound = 0131 let lowerBound = 0132 const bonus = Math.floor((Math.random() * 3) + 1)133 if(bonus == 3){134 upperBound = 1.8135 lowerBound = 1.3136 }else if(bonus == 2){137 upperBound = 1.35138 lowerBound = 1.35139 }else{140 lowerBound = 1.5141 upperBound = 1.25142 }143 await args.mutateChar({144 variables: {145 characterId: args.characterId,146 statId: args.baseStats._id,147 charisma: (Math.round(args.baseStats.charisma * lowerBound)),148 constitution: (Math.round(args.baseStats.constitution * lowerBound)),149 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),150 health: (Math.round(args.baseStats.health * lowerBound)),151 intelligence: (Math.round(args.baseStats.intelligence * upperBound)),152 perception: (Math.round(args.baseStats.perception * upperBound)),153 speed: (Math.round(args.baseStats.speed * lowerBound)),154 strength: (Math.round(args.baseStats.strength * lowerBound)),155 wisdom: (Math.round(args.baseStats.wisdom * upperBound)),156 level: args.levels,157 experience: args.randomXP158 }159 })160}161export const summonerLevelUp = async (args) => {162 let upperBound = 0163 let lowerBound = 0164 const bonus = Math.floor((Math.random() * 3) + 1)165 if(bonus == 3){166 upperBound = 1.8167 lowerBound = 1.3168 }else if(bonus == 2){169 upperBound = 1.35170 lowerBound = 1.35171 }else{172 lowerBound = 1.5173 upperBound = 1.25174 }175 await args.mutateChar({176 variables: {177 characterId: args.characterId,178 statId: args.baseStats._id,179 charisma: (Math.round(args.baseStats.charisma * lowerBound)),180 constitution: (Math.round(args.baseStats.constitution * lowerBound)),181 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),182 health: (Math.round(args.baseStats.health * lowerBound)),183 intelligence: (Math.round(args.baseStats.intelligence * upperBound)),184 perception: (Math.round(args.baseStats.perception * upperBound)),185 speed: (Math.round(args.baseStats.speed * lowerBound)),186 strength: (Math.round(args.baseStats.strength * lowerBound)),187 wisdom: (Math.round(args.baseStats.wisdom * upperBound)),188 level: args.levels,189 experience: args.randomXP190 }191 })192}193export const nomadLevelUp = async (args) => {194 let upperBound = 0195 let lowerBound = 0196 const bonus = Math.floor((Math.random() * 3) + 1)197 if(bonus == 3){198 upperBound = 1.5199 lowerBound = 1.179200 }else if(bonus == 2){201 upperBound = 1.25202 lowerBound = 1.25203 }else{204 lowerBound = 1.4205 upperBound = 1.1997206 }207 await args.mutateChar({208 variables: {209 characterId: args.characterId,210 statId: args.baseStats._id,211 charisma: (Math.round(args.baseStats.charisma * lowerBound)),212 constitution: (Math.round(args.baseStats.constitution * upperBound)),213 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),214 health: (Math.round(args.baseStats.health * upperBound)),215 intelligence: (Math.round(args.baseStats.intelligence * upperBound)),216 perception: (Math.round(args.baseStats.perception * lowerBound)),217 speed: (Math.round(args.baseStats.speed * lowerBound)),218 strength: (Math.round(args.baseStats.strength * upperBound)),219 wisdom: (Math.round(args.baseStats.wisdom * lowerBound)),220 level: args.levels,221 experience: args.randomXP222 }223 })224}225export const druidLevelUp = async (args) => {226 let upperBound = 0227 let lowerBound = 0228 const bonus = Math.floor((Math.random() * 3) + 1)229 if(bonus == 3){230 upperBound = 1.8231 lowerBound = 1.3232 }else if(bonus == 2){233 upperBound = 1.35234 lowerBound = 1.35235 }else{236 lowerBound = 1.5237 upperBound = 1.25238 }239 await args.mutateChar({240 variables: {241 characterId: args.characterId,242 statId: args.baseStats._id,243 charisma: (Math.round(args.baseStats.charisma * lowerBound)),244 constitution: (Math.round(args.baseStats.constitution * upperBound)),245 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),246 health: (Math.round(args.baseStats.health * upperBound)),247 intelligence: (Math.round(args.baseStats.intelligence * lowerBound)),248 perception: (Math.round(args.baseStats.perception * upperBound)),249 speed: (Math.round(args.baseStats.speed * lowerBound)),250 strength: (Math.round(args.baseStats.strength * upperBound)),251 wisdom: (Math.round(args.baseStats.wisdom * upperBound)),252 level: args.levels,253 experience: args.randomXP254 }255 })256}257export const beastmasterLevelUp = async (args) => {258 let upperBound = 0259 let lowerBound = 0260 const bonus = Math.floor((Math.random() * 3) + 1)261 if(bonus == 3){262 upperBound = 1.8263 lowerBound = 1.3264 }else if(bonus == 2){265 upperBound = 1.35266 lowerBound = 1.35267 }else{268 lowerBound = 1.5269 upperBound = 1.25270 }271 await args.mutateChar({272 variables: {273 characterId: args.characterId,274 statId: args.baseStats._id,275 charisma: (Math.round(args.baseStats.charisma * lowerBound)),276 constitution: (Math.round(args.baseStats.constitution * lowerBound)),277 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),278 health: (Math.round(args.baseStats.health * lowerBound)),279 intelligence: (Math.round(args.baseStats.intelligence * upperBound)),280 perception: (Math.round(args.baseStats.perception * lowerBound)),281 speed: (Math.round(args.baseStats.speed * lowerBound)),282 strength: (Math.round(args.baseStats.strength * lowerBound)),283 wisdom: (Math.round(args.baseStats.wisdom * upperBound)),284 level: args.levels,285 experience: args.randomXP286 }287 })288}289export const geomancerLevelUp = async (args) => {290 let upperBound = 0291 let lowerBound = 0292 const bonus = Math.floor((Math.random() * 3) + 1)293 if(bonus == 3){294 upperBound = 1.8295 lowerBound = 1.3296 }else if(bonus == 2){297 upperBound = 1.35298 lowerBound = 1.35299 }else{300 lowerBound = 1.5301 upperBound = 1.25302 }303 await args.mutateChar({304 variables: {305 characterId: args.characterId,306 statId: args.baseStats._id,307 charisma: (Math.round(args.baseStats.charisma * lowerBound)),308 constitution: (Math.round(args.baseStats.constitution * lowerBound)),309 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),310 health: (Math.round(args.baseStats.health * lowerBound)),311 intelligence: (Math.round(args.baseStats.intelligence * upperBound)),312 perception: (Math.round(args.baseStats.perception * upperBound)),313 speed: (Math.round(args.baseStats.speed * lowerBound)),314 strength: (Math.round(args.baseStats.strength * lowerBound)),315 wisdom: (Math.round(args.baseStats.wisdom * upperBound)),316 level: args.levels,317 experience: args.randomXP318 }319 })320}321export const pugilistLevelUp = async (args) => {322 let upperBound = 0323 let lowerBound = 0324 const bonus = Math.floor((Math.random() * 3) + 1)325 if(bonus == 3){326 upperBound = 1.5327 lowerBound = 1.179328 }else if(bonus == 2){329 upperBound = 1.25330 lowerBound = 1.25331 }else{332 lowerBound = 1.4333 upperBound = 1.1997334 }335 await args.mutateChar({336 variables: {337 characterId: args.characterId,338 statId: args.baseStats._id,339 charisma: (Math.round(args.baseStats.charisma * lowerBound)),340 constitution: (Math.round(args.baseStats.constitution * upperBound)),341 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),342 health: (Math.round(args.baseStats.health * upperBound)),343 intelligence: (Math.round(args.baseStats.intelligence * lowerBound)),344 perception: (Math.round(args.baseStats.perception * upperBound)),345 speed: (Math.round(args.baseStats.speed * upperBound)),346 strength: (Math.round(args.baseStats.strength * upperBound)),347 wisdom: (Math.round(args.baseStats.wisdom * lowerBound)),348 level: args.levels,349 experience: args.randomXP350 }351 })352}353export const monkLevelUp = async (args) => {354 let upperBound = 0355 let lowerBound = 0356 const bonus = Math.floor((Math.random() * 3) + 1)357 if(bonus == 3){358 upperBound = 1.8359 lowerBound = 1.3360 }else if(bonus == 2){361 upperBound = 1.35362 lowerBound = 1.35363 }else{364 lowerBound = 1.5365 upperBound = 1.25366 }367 await args.mutateChar({368 variables: {369 characterId: args.characterId,370 statId: args.baseStats._id,371 charisma: (Math.round(args.baseStats.charisma * lowerBound)),372 constitution: (Math.round(args.baseStats.constitution * upperBound)),373 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),374 health: (Math.round(args.baseStats.health * upperBound)),375 intelligence: (Math.round(args.baseStats.intelligence * upperBound)),376 perception: (Math.round(args.baseStats.perception * lowerBound)),377 speed: (Math.round(args.baseStats.speed * upperBound)),378 strength: (Math.round(args.baseStats.strength * lowerBound)),379 wisdom: (Math.round(args.baseStats.wisdom * upperBound)),380 level: args.levels,381 experience: args.randomXP382 }383 })384}385export const fighterLevelUp = async (args) => {386 let upperBound = 0387 let lowerBound = 0388 const bonus = Math.floor((Math.random() * 3) + 1)389 if(bonus == 3){390 upperBound = 1.8391 lowerBound = 1.3392 }else if(bonus == 2){393 upperBound = 1.35394 lowerBound = 1.35395 }else{396 lowerBound = 1.5397 upperBound = 1.25398 }399 await args.mutateChar({400 variables: {401 characterId: args.characterId,402 statId: args.baseStats._id,403 charisma: (Math.round(args.baseStats.charisma * lowerBound)),404 constitution: (Math.round(args.baseStats.constitution * upperBound)),405 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),406 health: (Math.round(args.baseStats.health * upperBound)),407 intelligence: (Math.round(args.baseStats.intelligence * lowerBound)),408 perception: (Math.round(args.baseStats.perception * upperBound)),409 speed: (Math.round(args.baseStats.speed * upperBound)),410 strength: (Math.round(args.baseStats.strength * upperBound)),411 wisdom: (Math.round(args.baseStats.wisdom * lowerBound)),412 level: args.levels,413 experience: args.randomXP414 }415 })416}417export const soldierLevelUp = async (args) => {418 let upperBound = 0419 let lowerBound = 0420 const bonus = Math.floor((Math.random() * 3) + 1)421 if(bonus == 3){422 upperBound = 1.5423 lowerBound = 1.179424 }else if(bonus == 2){425 upperBound = 1.25426 lowerBound = 1.25427 }else{428 lowerBound = 1.4429 upperBound = 1.1997430 }431 await args.mutateChar({432 variables: {433 characterId: args.characterId,434 statId: args.baseStats._id,435 charisma: (Math.round(args.baseStats.charisma * lowerBound)),436 constitution: (Math.round(args.baseStats.constitution * upperBound)),437 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),438 health: (Math.round(args.baseStats.health * upperBound)),439 intelligence: (Math.round(args.baseStats.intelligence * lowerBound)),440 perception: (Math.round(args.baseStats.perception * lowerBound)),441 speed: (Math.round(args.baseStats.speed * lowerBound)),442 strength: (Math.round(args.baseStats.strength * upperBound)),443 wisdom: (Math.round(args.baseStats.wisdom * lowerBound)),444 level: args.levels,445 experience: args.randomXP446 }447 })448}449export const berserkerLevelUp = async (args) => {450 let upperBound = 0451 let lowerBound = 0452 const bonus = Math.floor((Math.random() * 3) + 1)453 if(bonus == 3){454 upperBound = 1.8455 lowerBound = 1.3456 }else if(bonus == 2){457 upperBound = 1.35458 lowerBound = 1.35459 }else{460 lowerBound = 1.5461 upperBound = 1.25462 }463 await args.mutateChar({464 variables: {465 characterId: args.characterId,466 statId: args.baseStats._id,467 charisma: (Math.round(args.baseStats.charisma * lowerBound)),468 constitution: (Math.round(args.baseStats.constitution * upperBound)),469 dexterity: (Math.round(args.baseStats.dexterity * upperBound)),470 health: (Math.round(args.baseStats.health * upperBound)),471 intelligence: (Math.round(args.baseStats.intelligence * lowerBound)),472 perception: (Math.round(args.baseStats.perception * upperBound)),473 speed: (Math.round(args.baseStats.speed * upperBound)),474 strength: (Math.round(args.baseStats.strength * upperBound)),475 wisdom: (Math.round(args.baseStats.wisdom * lowerBound)),476 level: args.levels,477 experience: args.randomXP478 }479 })480}481export const paladinLevelUp = async (args) => {482 let upperBound = 0483 let lowerBound = 0484 const bonus = Math.floor((Math.random() * 3) + 1)485 if(bonus == 3){486 upperBound = 1.8487 lowerBound = 1.3488 }else if(bonus == 2){489 upperBound = 1.35490 lowerBound = 1.35491 }else{492 lowerBound = 1.5493 upperBound = 1.25494 }495 await args.mutateChar({496 variables: {497 characterId: args.characterId,498 statId: args.baseStats._id,499 charisma: (Math.round(args.baseStats.charisma * lowerBound)),500 constitution: (Math.round(args.baseStats.constitution * upperBound)),501 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),502 health: (Math.round(args.baseStats.health * upperBound)),503 intelligence: (Math.round(args.baseStats.intelligence * upperBound)),504 perception: (Math.round(args.baseStats.perception * lowerBound)),505 speed: (Math.round(args.baseStats.speed * lowerBound)),506 strength: (Math.round(args.baseStats.strength * upperBound)),507 wisdom: (Math.round(args.baseStats.wisdom * upperBound)),508 level: args.levels,509 experience: args.randomXP510 }511 })512}513export const darkknightLevelUp = async (args) => {514 let upperBound = 0515 let lowerBound = 0516 const bonus = Math.floor((Math.random() * 3) + 1)517 if(bonus == 3){518 upperBound = 1.8519 lowerBound = 1.3520 }else if(bonus == 2){521 upperBound = 1.35522 lowerBound = 1.35523 }else{524 lowerBound = 1.5525 upperBound = 1.25526 }527 await args.mutateChar({528 variables: {529 characterId: args.characterId,530 statId: args.baseStats._id,531 charisma: (Math.round(args.baseStats.charisma * lowerBound)),532 constitution: (Math.round(args.baseStats.constitution * upperBound)),533 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),534 health: (Math.round(args.baseStats.health * upperBound)),535 intelligence: (Math.round(args.baseStats.intelligence * lowerBound)),536 perception: (Math.round(args.baseStats.perception * upperBound)),537 speed: (Math.round(args.baseStats.speed * lowerBound)),538 strength: (Math.round(args.baseStats.strength * upperBound)),539 wisdom: (Math.round(args.baseStats.wisdom * upperBound)),540 level: args.levels,541 experience: args.randomXP542 }543 })544}545export const sorcererLevelUp = async (args) => {546 let upperBound = 0547 let lowerBound = 0548 const bonus = Math.floor((Math.random() * 3) + 1)549 if(bonus == 3){550 upperBound = 1.5551 lowerBound = 1.179552 }else if(bonus == 2){553 upperBound = 1.25554 lowerBound = 1.25555 }else{556 lowerBound = 1.4557 upperBound = 1.1997558 }559 await args.mutateChar({560 variables: {561 characterId: args.characterId,562 statId: args.baseStats._id,563 charisma: (Math.round(args.baseStats.charisma * lowerBound)),564 constitution: (Math.round(args.baseStats.constitution * lowerBound)),565 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),566 health: (Math.round(args.baseStats.health * lowerBound)),567 intelligence: (Math.round(args.baseStats.intelligence * upperBound)),568 perception: (Math.round(args.baseStats.perception * upperBound)),569 speed: (Math.round(args.baseStats.speed * lowerBound)),570 strength: (Math.round(args.baseStats.strength * lowerBound)),571 wisdom: (Math.round(args.baseStats.wisdom * upperBound)),572 level: args.levels,573 experience: args.randomXP574 }575 })576}577export const whitemageLevelUp = async (args) => {578 let upperBound = 0579 let lowerBound = 0580 const bonus = Math.floor((Math.random() * 3) + 1)581 if(bonus == 3){582 upperBound = 1.8583 lowerBound = 1.3584 }else if(bonus == 2){585 upperBound = 1.35586 lowerBound = 1.35587 }else{588 lowerBound = 1.5589 upperBound = 1.25590 }591 await args.mutateChar({592 variables: {593 characterId: args.characterId,594 statId: args.baseStats._id,595 charisma: (Math.round(args.baseStats.charisma * lowerBound)),596 constitution: (Math.round(args.baseStats.constitution * lowerBound)),597 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),598 health: (Math.round(args.baseStats.health * upperBound)),599 intelligence: (Math.round(args.baseStats.intelligence * upperBound)),600 perception: (Math.round(args.baseStats.perception * lowerBound)),601 speed: (Math.round(args.baseStats.speed * lowerBound)),602 strength: (Math.round(args.baseStats.strength * lowerBound)),603 wisdom: (Math.round(args.baseStats.wisdom * upperBound)),604 level: args.levels,605 experience: args.randomXP606 }607 })608}609export const blackmageLevelUp = async (args) => {610 let upperBound = 0611 let lowerBound = 0612 const bonus = Math.floor((Math.random() * 3) + 1)613 if(bonus == 3){614 upperBound = 1.8615 lowerBound = 1.3616 }else if(bonus == 2){617 upperBound = 1.35618 lowerBound = 1.35619 }else{620 lowerBound = 1.5621 upperBound = 1.25622 }623 await args.mutateChar({624 variables: {625 characterId: args.characterId,626 statId: args.baseStats._id,627 charisma: (Math.round(args.baseStats.charisma * lowerBound)),628 constitution: (Math.round(args.baseStats.constitution * upperBound)),629 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),630 health: (Math.round(args.baseStats.health * upperBound)),631 intelligence: (Math.round(args.baseStats.intelligence * lowerBound)),632 perception: (Math.round(args.baseStats.perception * upperBound)),633 speed: (Math.round(args.baseStats.speed * upperBound)),634 strength: (Math.round(args.baseStats.strength * upperBound)),635 wisdom: (Math.round(args.baseStats.wisdom * lowerBound)),636 level: args.levels,637 experience: args.randomXP638 }639 })640}641export const redmageLevelUp = async (args) => {642 let upperBound = 0643 let lowerBound = 0644 const bonus = Math.floor((Math.random() * 3) + 1)645 if(bonus == 3){646 upperBound = 1.8647 lowerBound = 1.3648 }else if(bonus == 2){649 upperBound = 1.35650 lowerBound = 1.35651 }else{652 lowerBound = 1.5653 upperBound = 1.25654 }655 await args.mutateChar({656 variables: {657 characterId: args.characterId,658 statId: args.baseStats._id,659 charisma: (Math.round(args.baseStats.charisma * lowerBound)),660 constitution: (Math.round(args.baseStats.constitution * upperBound)),661 dexterity: (Math.round(args.baseStats.dexterity * lowerBound)),662 health: (Math.round(args.baseStats.health * upperBound)),663 intelligence: (Math.round(args.baseStats.intelligence * lowerBound)),664 perception: (Math.round(args.baseStats.perception * upperBound)),665 speed: (Math.round(args.baseStats.speed * upperBound)),666 strength: (Math.round(args.baseStats.strength * upperBound)),667 wisdom: (Math.round(args.baseStats.wisdom * lowerBound)),668 level: args.levels,669 experience: args.randomXP670 }671 })672}673export const thiefLevelUp = async (args) => {674 let upperBound = 0675 let lowerBound = 0676 const bonus = Math.floor((Math.random() * 3) + 1)677 if(bonus == 3){678 upperBound = 1.5679 lowerBound = 1.179680 }else if(bonus == 2){681 upperBound = 1.25682 lowerBound = 1.25683 }else{684 lowerBound = 1.4685 upperBound = 1.1997686 }687 await args.mutateChar({688 variables: {689 characterId: args.characterId,690 statId: args.baseStats._id,691 charisma: (Math.round(args.baseStats.charisma * upperBound)),692 constitution: (Math.round(args.baseStats.constitution * lowerBound)),693 dexterity: (Math.round(args.baseStats.dexterity * upperBound)),694 health: (Math.round(args.baseStats.health * lowerBound)),695 intelligence: (Math.round(args.baseStats.intelligence * upperBound)),696 perception: (Math.round(args.baseStats.perception * upperBound)),697 speed: (Math.round(args.baseStats.speed * upperBound)),698 strength: (Math.round(args.baseStats.strength * lowerBound)),699 wisdom: (Math.round(args.baseStats.wisdom * lowerBound)),700 level: args.levels,701 experience: args.randomXP702 }703 })704}705export const ninjaLevelUp = async (args) => {706 let upperBound = 0707 let lowerBound = 0708 const bonus = Math.floor((Math.random() * 3) + 1)709 if(bonus == 3){710 upperBound = 1.8711 lowerBound = 1.3712 }else if(bonus == 2){713 upperBound = 1.35714 lowerBound = 1.35715 }else{716 lowerBound = 1.5717 upperBound = 1.25718 }719 await args.mutateChar({720 variables: {721 characterId: args.characterId,722 statId: args.baseStats._id,723 charisma: (Math.round(args.baseStats.charisma * upperBound)),724 constitution: (Math.round(args.baseStats.constitution * lowerBound)),725 dexterity: (Math.round(args.baseStats.dexterity * upperBound)),726 health: (Math.round(args.baseStats.health * lowerBound)),727 intelligence: (Math.round(args.baseStats.intelligence * upperBound)),728 perception: (Math.round(args.baseStats.perception * upperBound)),729 speed: (Math.round(args.baseStats.speed * upperBound)),730 strength: (Math.round(args.baseStats.strength * lowerBound)),731 wisdom: (Math.round(args.baseStats.wisdom * lowerBound)),732 level: args.levels,733 experience: args.randomXP734 }735 })736}737export const reaperLevelUp = async (args) => {738 let upperBound = 0739 let lowerBound = 0740 const bonus = Math.floor((Math.random() * 3) + 1)741 if(bonus == 3){742 upperBound = 1.8743 lowerBound = 1.3744 }else if(bonus == 2){745 upperBound = 1.35746 lowerBound = 1.35747 }else{748 lowerBound = 1.5749 upperBound = 1.25750 }751 await args.mutateChar({752 variables: {753 characterId: args.characterId,754 statId: args.baseStats._id,755 charisma: (Math.round(args.baseStats.charisma * lowerBound)),756 constitution: (Math.round(args.baseStats.constitution * upperBound)),757 dexterity: (Math.round(args.baseStats.dexterity * upperBound)),758 health: (Math.round(args.baseStats.health * upperBound)),759 intelligence: (Math.round(args.baseStats.intelligence * lowerBound)),760 perception: (Math.round(args.baseStats.perception * lowerBound)),761 speed: (Math.round(args.baseStats.speed * upperBound)),762 strength: (Math.round(args.baseStats.strength * upperBound)),763 wisdom: (Math.round(args.baseStats.wisdom * lowerBound)),764 level: args.levels,765 experience: args.randomXP766 }767 })...
b2AABB.js
Source:b2AABB.js
1/*2 * Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com3 *4 * This software is provided 'as-is', without any express or implied5 * warranty. In no event will the authors be held liable for any damages6 * arising from the use of this software.7 * Permission is granted to anyone to use this software for any purpose,8 * including commercial applications, and to alter it and redistribute it9 * freely, subject to the following restrictions:10 * 1. The origin of this software must not be misrepresented; you must not11 * claim that you wrote the original software. If you use this software12 * in a product, an acknowledgment in the product documentation would be13 * appreciated but is not required.14 * 2. Altered source versions must be plainly marked as such, and must not be15 * misrepresented as being the original software.16 * 3. This notice may not be removed or altered from any source distribution.17 */18/*19 * Original Box2D created by Erin Catto20 * http://www.gphysics.com21 * http://box2d.org/22 * 23 * Box2D was converted to Flash by Boris the Brave, Matt Bush, and John Nesky as Box2DFlash24 * http://www.box2dflash.org/25 * 26 * Box2DFlash was converted from Flash to Javascript by Uli Hecht as box2Dweb27 * http://code.google.com/p/box2dweb/28 * 29 * box2Dweb was modified to utilize Google Closure, as well as other bug fixes, optimizations, and tweaks by Illandril30 * https://github.com/illandril/box2dweb-closure31 */32 33goog.provide('Box2D.Collision.b2AABB');34goog.require('Box2D.Common.Math.b2Vec2');35/**36 * @private37 * @constructor38 */39Box2D.Collision.b2AABB = function() {40 UsageTracker.get('Box2D.Collision.b2AABB').trackCreate();41 42 /**43 * @private44 * @type {!Box2D.Common.Math.b2Vec2}45 */46 this.lowerBound = Box2D.Common.Math.b2Vec2.Get(0, 0);47 48 /**49 * @private50 * @type {!Box2D.Common.Math.b2Vec2}51 */52 this.upperBound = Box2D.Common.Math.b2Vec2.Get(0, 0);53};54/**55 * @private56 * @type {Array.<!Box2D.Collision.b2AABB>}57 */58Box2D.Collision.b2AABB._freeCache = [];59/**60 * @return {!Box2D.Collision.b2AABB}61 */62Box2D.Collision.b2AABB.Get = function() {63 UsageTracker.get('Box2D.Collision.b2AABB').trackGet();64 if (Box2D.Collision.b2AABB._freeCache.length > 0) {65 var aabb = Box2D.Collision.b2AABB._freeCache.pop();66 aabb.SetZero();67 return aabb;68 }69 return new Box2D.Collision.b2AABB();70};71/**72 * @param {!Box2D.Collision.b2AABB} aabb73 */74Box2D.Collision.b2AABB.Free = function(aabb) {75 if (aabb != null) {76 UsageTracker.get('Box2D.Collision.b2AABB').trackFree();77 Box2D.Collision.b2AABB._freeCache.push(aabb);78 }79};80/**81 * @param {number} lowerX82 * @param {number} lowerY83 * @param {number} upperX84 * @param {number} upperY85 */86Box2D.Collision.b2AABB.prototype.Set = function(lowerX, lowerY, upperX, upperY) {87 this.lowerBound.Set(lowerX, lowerY);88 this.upperBound.Set(upperX, upperY);89};90/**91 * @param {!Box2D.Common.Math.b2Vec2} lowerBound92 * @param {!Box2D.Common.Math.b2Vec2} upperBound93 */94Box2D.Collision.b2AABB.prototype.SetVV = function(lowerBound, upperBound) {95 this.lowerBound.SetV(lowerBound);96 this.upperBound.SetV(upperBound);97};98Box2D.Collision.b2AABB.prototype.SetZero = function() {99 this.lowerBound.Set(0, 0);100 this.upperBound.Set(0, 0);101};102/**103 * @return {boolean}104 */105Box2D.Collision.b2AABB.prototype.IsValid = function() {106 var dX = this.upperBound.x - this.lowerBound.x;107 if (dX < 0) {108 return false;109 }110 var dY = this.upperBound.y - this.lowerBound.y;111 if (dY < 0) {112 return false;113 }114 return this.lowerBound.IsValid() && this.upperBound.IsValid();115};116/**117 * @return {!Box2D.Common.Math.b2Vec2}118 */119Box2D.Collision.b2AABB.prototype.GetCenter = function() {120 return Box2D.Common.Math.b2Vec2.Get((this.lowerBound.x + this.upperBound.x) / 2, (this.lowerBound.y + this.upperBound.y) / 2);121};122/**123 * @param {!Box2D.Common.Math.b2Vec2} newCenter124 */125Box2D.Collision.b2AABB.prototype.SetCenter = function(newCenter) {126 var oldCenter = this.GetCenter();127 this.lowerBound.Subtract(oldCenter);128 this.upperBound.Subtract(oldCenter);129 this.lowerBound.Add(newCenter);130 this.upperBound.Add(newCenter);131 Box2D.Common.Math.b2Vec2.Free(oldCenter);132};133/**134 * @return {!Box2D.Common.Math.b2Vec2}135 */136Box2D.Collision.b2AABB.prototype.GetExtents = function() {137 return Box2D.Common.Math.b2Vec2.Get((this.upperBound.x - this.lowerBound.x) / 2, (this.upperBound.y - this.lowerBound.y) / 2);138};139/**140 * @param {!Box2D.Collision.b2AABB} aabb141 * @return {boolean}142 */143Box2D.Collision.b2AABB.prototype.Contains = function(aabb) {144 var result = true;145 result = result && this.lowerBound.x <= aabb.lowerBound.x;146 result = result && this.lowerBound.y <= aabb.lowerBound.y;147 result = result && aabb.upperBound.x <= this.upperBound.x;148 result = result && aabb.upperBound.y <= this.upperBound.y;149 return result;150};151/**152 * @param {!Box2D.Collision.b2RayCastOutput} output153 * @param {!Box2D.Collision.b2RayCastInput} input154 * @return {boolean}155 */156Box2D.Collision.b2AABB.prototype.RayCast = function(output, input) {157 var tmin = (-Number.MAX_VALUE);158 var tmax = Number.MAX_VALUE;159 160 var dX = input.p2.x - input.p1.x;161 var absDX = Math.abs(dX);162 if (absDX < Number.MIN_VALUE) {163 if (input.p1.x < this.lowerBound.x || this.upperBound.x < input.p1.x) {164 return false;165 }166 } else {167 var inv_d = 1.0 / dX;168 var t1 = (this.lowerBound.x - input.p1.x) * inv_d;169 var t2 = (this.upperBound.x - input.p1.x) * inv_d;170 var s = (-1.0);171 if (t1 > t2) {172 var t3 = t1;173 t1 = t2;174 t2 = t3;175 s = 1.0;176 }177 if (t1 > tmin) {178 output.normal.x = s;179 output.normal.y = 0;180 tmin = t1;181 }182 tmax = Math.min(tmax, t2);183 if (tmin > tmax) return false;184 }185 186 var dY = input.p2.y - input.p1.y;187 var absDY = Math.abs(dY);188 if (absDY < Number.MIN_VALUE) {189 if (input.p1.y < this.lowerBound.y || this.upperBound.y < input.p1.y) {190 return false;191 }192 } else {193 var inv_d = 1.0 / dY;194 var t1 = (this.lowerBound.y - input.p1.y) * inv_d;195 var t2 = (this.upperBound.y - input.p1.y) * inv_d;196 var s = (-1.0);197 if (t1 > t2) {198 var t3 = t1;199 t1 = t2;200 t2 = t3;201 s = 1.0;202 }203 if (t1 > tmin) {204 output.normal.y = s;205 output.normal.x = 0;206 tmin = t1;207 }208 tmax = Math.min(tmax, t2);209 if (tmin > tmax) {210 return false;211 }212 }213 output.fraction = tmin;214 return true;215};216/**217 * @param {!Box2D.Collision.b2AABB} other218 * @return {boolean}219 */220Box2D.Collision.b2AABB.prototype.TestOverlap = function(other) {221 if ( other.lowerBound.x - this.upperBound.x > 0 ) { return false; }222 if ( other.lowerBound.y - this.upperBound.y > 0 ) { return false; }223 if ( this.lowerBound.x - other.upperBound.x > 0 ) { return false; }224 if ( this.lowerBound.y - other.upperBound.y > 0 ) { return false; }225 return true;226};227/**228 * @param {!Box2D.Collision.b2AABB} aabb1229 * @param {!Box2D.Collision.b2AABB} aabb2230 * @return {!Box2D.Collision.b2AABB}231 */232Box2D.Collision.b2AABB.Combine = function(aabb1, aabb2) {233 var aabb = Box2D.Collision.b2AABB.Get();234 aabb.Combine(aabb1, aabb2);235 return aabb;236};237/**238 * @param {!Box2D.Collision.b2AABB} aabb1239 * @param {!Box2D.Collision.b2AABB} aabb2240 */241Box2D.Collision.b2AABB.prototype.Combine = function(aabb1, aabb2) {242 this.lowerBound.x = Math.min(aabb1.lowerBound.x, aabb2.lowerBound.x);243 this.lowerBound.y = Math.min(aabb1.lowerBound.y, aabb2.lowerBound.y);244 this.upperBound.x = Math.max(aabb1.upperBound.x, aabb2.upperBound.x);245 this.upperBound.y = Math.max(aabb1.upperBound.y, aabb2.upperBound.y);246};247/**248 * @return {number}249 */250Box2D.Collision.b2AABB.prototype.GetMinX = function() {251 return this.lowerBound.x;252};253/**254 * @return {number}255 */256Box2D.Collision.b2AABB.prototype.GetMaxX = function() {257 return this.upperBound.x;258};259/**260 * @return {number}261 */262Box2D.Collision.b2AABB.prototype.GetMinY = function() {263 return this.lowerBound.y;264};265/**266 * @return {number}267 */268Box2D.Collision.b2AABB.prototype.GetMaxY = function() {269 return this.upperBound.y;...
calculate_timeseries_interval.js
Source:calculate_timeseries_interval.js
1/*2 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one3 * or more contributor license agreements. Licensed under the Elastic License;4 * you may not use this file except in compliance with the Elastic License.5 */6import moment from 'moment';7import expect from '@kbn/expect';8import { calculateTimeseriesInterval } from '../calculate_timeseries_interval';9describe('calculateTimeseriesInterval', () => {10 it('returns an interval of 10s when duration is 15m', () => {11 const upperBound = moment.utc();12 const lowerBound = upperBound.clone().subtract(15, 'minutes');13 const minIntervalSeconds = 10;14 expect(15 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)16 ).to.be(10);17 });18 it('returns an interval of 30s when duration is 30m', () => {19 const upperBound = moment.utc();20 const lowerBound = upperBound.clone().subtract(30, 'minutes');21 const minIntervalSeconds = 10;22 expect(23 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)24 ).to.be(30);25 });26 it('returns an interval of 30s when duration is 1h', () => {27 const upperBound = moment.utc();28 const lowerBound = upperBound.clone().subtract(1, 'hour');29 const minIntervalSeconds = 10;30 expect(31 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)32 ).to.be(30);33 });34 it('returns an interval of 1m when duration is 4h', () => {35 const upperBound = moment.utc();36 const lowerBound = upperBound.clone().subtract(4, 'hours');37 const minIntervalSeconds = 10;38 expect(39 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)40 ).to.be(60);41 });42 it('returns an interval of 5m when duration is 12h', () => {43 const upperBound = moment.utc();44 const lowerBound = upperBound.clone().subtract(12, 'hours');45 const minIntervalSeconds = 10;46 expect(47 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)48 ).to.be(5 * 60);49 });50 it('returns an interval of 10m when duration is 24h', () => {51 const upperBound = moment.utc();52 const lowerBound = upperBound.clone().subtract(24, 'hours');53 const minIntervalSeconds = 10;54 expect(55 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)56 ).to.be(10 * 60);57 });58 it('returns an interval of 1h when duration is 7d', () => {59 const upperBound = moment.utc();60 const lowerBound = upperBound.clone().subtract(7, 'days');61 const minIntervalSeconds = 10;62 expect(63 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)64 ).to.be(60 * 60);65 });66 it('returns an interval of 12h when duration is 30d', () => {67 const upperBound = moment.utc();68 const lowerBound = upperBound.clone().subtract(30, 'days');69 const minIntervalSeconds = 10;70 expect(71 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)72 ).to.be(12 * 60 * 60);73 });74 it('returns an interval of 12h when duration is 60d', () => {75 const upperBound = moment.utc();76 const lowerBound = upperBound.clone().subtract(60, 'days');77 const minIntervalSeconds = 10;78 expect(79 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)80 ).to.be(12 * 60 * 60);81 });82 it('returns an interval of 12h when duration is 90d', () => {83 const upperBound = moment.utc();84 const lowerBound = upperBound.clone().subtract(90, 'days');85 const minIntervalSeconds = 10;86 expect(87 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)88 ).to.be(12 * 60 * 60);89 });90 it('returns an interval of 1d when duration is 6mo', () => {91 const upperBound = moment.utc();92 const lowerBound = upperBound.clone().subtract(6, 'months');93 const minIntervalSeconds = 10;94 expect(95 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)96 ).to.be(24 * 60 * 60);97 });98 it('returns an interval of 1d when duration is 1y', () => {99 const upperBound = moment.utc();100 const lowerBound = upperBound.clone().subtract(1, 'year');101 const minIntervalSeconds = 10;102 expect(103 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)104 ).to.be(24 * 60 * 60);105 });106 it('returns an interval of 7d when duration is 2y', () => {107 const upperBound = moment.utc();108 const lowerBound = upperBound.clone().subtract(2, 'years');109 const minIntervalSeconds = 10;110 expect(111 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)112 ).to.be(7 * 24 * 60 * 60);113 });114 it('returns an interval of 7d when duration is 5y', () => {115 const upperBound = moment.utc();116 const lowerBound = upperBound.clone().subtract(5, 'years');117 const minIntervalSeconds = 10;118 expect(119 calculateTimeseriesInterval(lowerBound.valueOf(), upperBound.valueOf(), minIntervalSeconds)120 ).to.be(7 * 24 * 60 * 60);121 });...
Using AI Code Generation
1var wptree = require('wptree');2var tree = new wptree();3var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];4tree.build(arr);5console.log(tree.upperBound(5));6tree.upperBound(5) returns 67tree.upperBound(6) returns 78tree.upperBound(7) returns 89tree.upperBound(8) returns 910tree.upperBound(9) returns -111tree.upperBound(10) returns -112tree.upperBound(1) returns 213tree.upperBound(2) returns 314tree.upperBound(3) returns 415tree.upperBound(4) returns 516tree.upperBound(0) returns 117tree.upperBound(-1) returns 118tree.upperBound(-2) returns 119tree.upperBound(-3) returns 120tree.upperBound(-4) returns 121tree.upperBound(-5) returns 122tree.upperBound(-6) returns 123tree.upperBound(-7) returns 124tree.upperBound(-8) returns 125tree.upperBound(-9) returns 126tree.upperBound(-10) returns 127tree.upperBound(-11) returns 128tree.upperBound(-12) returns 129tree.upperBound(-13) returns 130tree.upperBound(-14) returns 131tree.upperBound(-15) returns 132tree.upperBound(-16) returns 133tree.upperBound(-17) returns 134tree.upperBound(-18) returns 135tree.upperBound(-19) returns 136tree.upperBound(-20) returns 137tree.upperBound(-21) returns 138tree.upperBound(-22) returns 139tree.upperBound(-23) returns 140tree.upperBound(-24) returns 141tree.upperBound(-25) returns 142tree.upperBound(-26) returns 143tree.upperBound(-27) returns 144tree.upperBound(-28) returns 145tree.upperBound(-29) returns 146tree.upperBound(-30) returns 147tree.upperBound(-31) returns 148tree.upperBound(-32) returns 149tree.upperBound(-33)
Using AI Code Generation
1var wptree = require('wptree');2var tree = new wptree();3tree.insert(10);4tree.insert(20);5tree.insert(30);6tree.insert(40);7tree.insert(50);8var wptree = require('wptree');9var tree = new wptree();10tree.insert(10);11tree.insert(20);12tree.insert(30);13tree.insert(40);14tree.insert(50);15var wptree = require('wptree');16var tree = new wptree();17tree.insert(10);18tree.insert(20);19tree.insert(30);20tree.insert(40);21tree.insert(50);
Using AI Code Generation
1var wptree = require('./wptree.js');2var myTree = new wptree();3myTree.insert(2);4myTree.insert(3);5myTree.insert(1);6myTree.insert(4);7myTree.insert(5);8myTree.insert(6);9myTree.insert(7);10myTree.insert(8);11myTree.insert(9);12myTree.insert(10);13myTree.insert(11);14myTree.insert(12);15myTree.insert(13);16myTree.insert(14);17myTree.insert(15);18myTree.insert(16);19myTree.insert(17);20myTree.insert(18);21myTree.insert(19);22myTree.insert(20);23myTree.insert(21);24myTree.insert(22);25myTree.insert(23);26myTree.insert(24);27myTree.insert(25);28myTree.insert(26);29myTree.insert(27);30myTree.insert(28);31myTree.insert(29);32myTree.insert(30);33myTree.insert(31);34myTree.insert(32);35myTree.insert(33);36myTree.insert(34);37myTree.insert(35);38myTree.insert(36);39myTree.insert(37);40myTree.insert(38);41myTree.insert(39);42myTree.insert(40);43myTree.insert(41);44myTree.insert(42);45myTree.insert(43);46myTree.insert(44);47myTree.insert(45);48myTree.insert(46);49myTree.insert(47);50myTree.insert(48);51myTree.insert(49);52myTree.insert(50);53myTree.insert(51);54myTree.insert(52);55myTree.insert(53);56myTree.insert(54);57myTree.insert(55);58myTree.insert(56);59myTree.insert(57);60myTree.insert(58);61myTree.insert(59);62myTree.insert(60);63myTree.insert(61);64myTree.insert(62);65myTree.insert(63);66myTree.insert(64);67myTree.insert(65);68myTree.insert(66);69myTree.insert(67);70myTree.insert(68);71myTree.insert(69);72myTree.insert(70);73myTree.insert(71);74myTree.insert(72);75myTree.insert(73);76myTree.insert(74);77myTree.insert(75);78myTree.insert(76);79myTree.insert(77);80myTree.insert(78);81myTree.insert(79);
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) {4 console.log(err);5 } else {6 console.log('Test Finished. You can view the status of your test at ' + data.data.userUrl);7 wpt.getTestResults(data.data.testId, function(err, data) {8 if (err) {9 console.log(err);10 } else {11 console.log(data);12 }13 });14 }15});16var wpt = require('wpt');17var wpt = new WebPageTest('www.webpagetest.org');18 if (err) {19 console.log(err);20 } else {21 console.log('Test Finished. You can view the status of your test at ' + data.data.userUrl);22 wpt.getTestResults(data.data.testId, function(err, data) {23 if (err) {24 console.log(err);25 } else {26 console.log(data);27 }28 });29 }30});31var wpt = require('wpt');32var wpt = new WebPageTest('www.webpagetest.org');33 if (err) {34 console.log(err);35 } else {36 console.log('Test Finished. You can view the status of your test at ' + data.data.userUrl);37 wpt.getTestResults(data.data.testId, function(err, data) {38 if (err) {39 console.log(err);40 } else {41 console.log(data);42 }43 });44 }45});46var wpt = require('wpt');47var wpt = new WebPageTest('www.webpagetest.org');
Using AI Code Generation
1var wptree = require('wptree');2var tree = new wptree();3tree.add('A', 1);4tree.add('B', 2);5tree.add('C', 3);6tree.add('D', 4);7tree.add('E', 5);8tree.add('F', 6);9tree.add('G', 7);10tree.add('H', 8);11tree.add('I', 9);12tree.add('J', 10);13console.log(tree.upperBound(5));14console.log(tree.upperBound(10));15console.log(tree.upperBound(0));16console.log(tree.upperBound(11));17console.log(tree.upperBound(4));18console.log(tree.upperBound(6));19console.log(tree.upperBound(3));20console.log(tree.upperBound(7));21{ key: 'E', value: 5 }22{ key: 'J', value: 10 }23{ key: 'A', value: 1 }24{ key: 'A', value: 1 }25{ key: 'D', value: 4 }26{ key: 'F', value: 6 }27{ key: 'C', value: 3 }28{ key: 'G', value: 7 }
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!!