How to use convertArgument method in Puppeteer

Best JavaScript code snippet using puppeteer

js_ffi.js

Source:js_ffi.js Github

copy

Full Screen

...98 let b = mem.slice(offset, offset + length * size);99 let a = new t(b);100 return a;101 }102 function convertArgument(val_type, val) {103 if (val_type == TYPE_NUM) {104 } else if (val_type === TYPE_NOTHING) {105 val = undefined;106 } else if (val_type === TYPE_STRING) {107 val = getStringFromMemory(mod.instance.exports.memory.buffer, val);108 } else if (val_type === TYPE_BOOL) {109 val = val != 0;110 } else if (val_type === TYPE_OBJ) {111 val = allocator_get(val);112 } else if (val_type === TYPE_FUNCTION) {113 let id = val;114 val = function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {115 let l = arguments.length;116 if (l === 0) {117 mod.instance.exports.jsfficallback(118 id,119 0,120 0,121 0,122 0,123 0,124 0,125 0,126 0,127 0,128 0129 );130 } else if (l === 1) {131 mod.instance.exports.jsfficallback(132 id,133 convertResponse(a1),134 0,135 0,136 0,137 0,138 0,139 0,140 0,141 0,142 0143 );144 } else if (l === 2) {145 mod.instance.exports.jsfficallback(146 id,147 convertResponse(a1),148 convertResponse(a2),149 0,150 0,151 0,152 0,153 0,154 0,155 0,156 0157 );158 } else if (l === 3) {159 mod.instance.exports.jsfficallback(160 id,161 convertResponse(a1),162 convertResponse(a2),163 convertResponse(a3),164 0,165 0,166 0,167 0,168 0,169 0,170 0171 );172 } else if (l === 4) {173 mod.instance.exports.jsfficallback(174 id,175 convertResponse(a1),176 convertResponse(a2),177 convertResponse(a3),178 convertResponse(a4),179 0,180 0,181 0,182 0,183 0,184 0185 );186 } else if (l === 5) {187 mod.instance.exports.jsfficallback(188 id,189 convertResponse(a1),190 convertResponse(a2),191 convertResponse(a3),192 convertResponse(a4),193 convertResponse(a5),194 0,195 0,196 0,197 0,198 0199 );200 } else if (l === 6) {201 mod.instance.exports.jsfficallback(202 id,203 convertResponse(a1),204 convertResponse(a2),205 convertResponse(a3),206 convertResponse(a4),207 convertResponse(a5),208 convertResponse(a6),209 0,210 0,211 0,212 0213 );214 } else if (l === 7) {215 mod.instance.exports.jsfficallback(216 id,217 convertResponse(a1),218 convertResponse(a2),219 convertResponse(a3),220 convertResponse(a4),221 convertResponse(a5),222 convertResponse(a6),223 convertResponse(a7),224 0,225 0,226 0227 );228 } else if (l === 8) {229 mod.instance.exports.jsfficallback(230 id,231 convertResponse(a1),232 convertResponse(a2),233 convertResponse(a3),234 convertResponse(a4),235 convertResponse(a5),236 convertResponse(a6),237 convertResponse(a7),238 convertResponse(a8),239 0,240 0241 );242 } else if (l === 9) {243 mod.instance.exports.jsfficallback(244 id,245 convertResponse(a1),246 convertResponse(a2),247 convertResponse(a3),248 convertResponse(a4),249 convertResponse(a5),250 convertResponse(a6),251 convertResponse(a7),252 convertResponse(a8),253 convertResponse(a9),254 0255 );256 } else if (l === 10) {257 mod.instance.exports.jsfficallback(258 id,259 convertResponse(a1),260 convertResponse(a2),261 convertResponse(a3),262 convertResponse(a4),263 convertResponse(a5),264 convertResponse(a6),265 convertResponse(a7),266 convertResponse(a8),267 convertResponse(a9),268 convertResponse(a10)269 );270 }271 };272 } else if (val_type === TYPE_UINT8_ARRAY) {273 val = getTypedArrayFromMemory(274 Uint8Array,275 mod.instance.exports.memory.buffer,276 val,277 1278 );279 } else if (val_type === TYPE_INT8_ARRAY) {280 val = getTypedArrayFromMemory(281 Int8Array,282 mod.instance.exports.memory.buffer,283 val,284 1285 );286 } else if (val_type === TYPE_F32_ARRAY) {287 val = getTypedArrayFromMemory(288 Float32Array,289 mod.instance.exports.memory.buffer,290 val,291 4292 );293 } else if (val_type === TYPE_F64_ARRAY) {294 val = getTypedArrayFromMemory(295 Float64Array,296 mod.instance.exports.memory.buffer,297 val,298 8299 );300 } else if (val_type === TYPE_INT32_ARRAY) {301 val = getTypedArrayFromMemory(302 Int32Array,303 mod.instance.exports.memory.buffer,304 val,305 4306 );307 } else if (val_type === TYPE_UINT32_ARRAY) {308 val = getTypedArrayFromMemory(309 Uint32Array,310 mod.instance.exports.memory.buffer,311 val,312 4313 );314 } else if (val_type === TYPE_INT16_ARRAY) {315 val = getTypedArrayFromMemory(316 Int16Array,317 mod.instance.exports.memory.buffer,318 val,319 2320 );321 } else if (val_type === TYPE_UINT16_ARRAY) {322 val = getTypedArrayFromMemory(323 Uint16Array,324 mod.instance.exports.memory.buffer,325 val,326 2327 );328 } else if (val_type === TYPE_MEMORY) {329 val = mod.instance.exports.memory.buffer;330 } else {331 throw error("Unknown data type");332 }333 return val;334 }335 function convertResponse(r) {336 const type = typeof r;337 if (type === "string") {338 return createString(r);339 } else if (type === "number") {340 return r;341 } else if (r === undefined) {342 return 0;343 } else if (r === null) {344 return 1;345 } else if (r === true) {346 return 1;347 } else if (r === false) {348 return 0;349 } else if (r.constructor === Float32Array) {350 return createTypedArray(r, Float32Array, 4);351 } else if (r.constructor === Uint8Array) {352 return createTypedArray(r, Uint8Array, 1);353 } else if (r.constructor === Int8Array) {354 return createTypedArray(r, Int8Array, 1);355 } else if (r.constructor === Float64Array) {356 return createTypedArray(r, Float64Array, 8);357 } else if (r.constructor === Int32Array) {358 return createTypedArray(r, Int32Array, 4);359 } else if (r.constructor === Uint32Array) {360 return createTypedArray(r, Uint32Array, 4);361 } else if (r.constructor === Int16Array) {362 return createTypedArray(r, Int16Array, 2);363 } else if (r.constructor === Uint16Array) {364 return createTypedArray(r, Uint16Array, 2);365 }366 return allocate(r);367 }368 if (typeof cfg === "string") {369 cfg = { path: cfg };370 }371 let result = {};372 fetch(cfg.path)373 .then(response => response.arrayBuffer())374 .then(bytes =>375 WebAssembly.instantiate(376 bytes,377 cfg.overrides || {378 env: Object.assign(379 {380 jsffithrowerror: function(e) {381 let err = getStringFromMemory(382 mod.instance.exports.memory.buffer,383 e384 );385 console.error(err);386 throw new Error("Web assembly module exited unexpectedly.");387 },388 jsffirelease: function(obj) {389 allocator_release(obj);390 },391 jsffiregister: function(code) {392 code = getStringFromMemory(393 mod.instance.exports.memory.buffer,394 code395 );396 let id = functions.length;397 functions.push(eval("(" + code + ")"));398 return id;399 },400 jsfficall0: function(obj, f) {401 return convertResponse(functions[f].call(allocator_get(obj)));402 },403 jsfficall1: function(obj, f, a1_type, a1) {404 return convertResponse(405 functions[f].call(406 allocator_get(obj),407 convertArgument(a1_type, a1)408 )409 );410 },411 jsfficall2: function(obj, f, a1_type, a1, a2_type, a2) {412 return convertResponse(413 functions[f].call(414 allocator_get(obj),415 convertArgument(a1_type, a1),416 convertArgument(a2_type, a2)417 )418 );419 },420 jsfficall3: function(421 obj,422 f,423 a1_type,424 a1,425 a2_type,426 a2,427 a3_type,428 a3429 ) {430 return convertResponse(431 functions[f].call(432 allocator_get(obj),433 convertArgument(a1_type, a1),434 convertArgument(a2_type, a2),435 convertArgument(a3_type, a3)436 )437 );438 },439 jsfficall4: function(440 obj,441 f,442 a1_type,443 a1,444 a2_type,445 a2,446 a3_type,447 a3,448 a4_type,449 a4450 ) {451 return convertResponse(452 functions[f].call(453 allocator_get(obj),454 convertArgument(a1_type, a1),455 convertArgument(a2_type, a2),456 convertArgument(a3_type, a3),457 convertArgument(a4_type, a4)458 )459 );460 },461 jsfficall5: function(462 obj,463 f,464 a1_type,465 a1,466 a2_type,467 a2,468 a3_type,469 a3,470 a4_type,471 a4,472 a5_type,473 a5474 ) {475 return convertResponse(476 functions[f].call(477 allocator_get(obj),478 convertArgument(a1_type, a1),479 convertArgument(a2_type, a2),480 convertArgument(a3_type, a3),481 convertArgument(a4_type, a4),482 convertArgument(a5_type, a5)483 )484 );485 },486 jsfficall6: function(487 obj,488 f,489 a1_type,490 a1,491 a2_type,492 a2,493 a3_type,494 a3,495 a4_type,496 a4,497 a5_type,498 a5,499 a6_type,500 a6501 ) {502 return convertResponse(503 functions[f].call(504 allocator_get(obj),505 convertArgument(a1_type, a1),506 convertArgument(a2_type, a2),507 convertArgument(a3_type, a3),508 convertArgument(a4_type, a4),509 convertArgument(a5_type, a5),510 convertArgument(a6_type, a6)511 )512 );513 },514 jsfficall7: function(515 obj,516 f,517 a1_type,518 a1,519 a2_type,520 a2,521 a3_type,522 a3,523 a4_type,524 a4,525 a5_type,526 a5,527 a6_type,528 a6,529 a7_type,530 a7531 ) {532 return convertResponse(533 functions[f].call(534 allocator_get(obj),535 convertArgument(a1_type, a1),536 convertArgument(a2_type, a2),537 convertArgument(a3_type, a3),538 convertArgument(a4_type, a4),539 convertArgument(a5_type, a5),540 convertArgument(a6_type, a6),541 convertArgument(a7_type, a7)542 )543 );544 },545 jsfficall8: function(546 obj,547 f,548 a1_type,549 a1,550 a2_type,551 a2,552 a3_type,553 a3,554 a4_type,555 a4,556 a5_type,557 a5,558 a6_type,559 a6,560 a7_type,561 a7,562 a8_type,563 a8564 ) {565 return convertResponse(566 functions[f].call(567 allocator_get(obj),568 convertArgument(a1_type, a1),569 convertArgument(a2_type, a2),570 convertArgument(a3_type, a3),571 convertArgument(a4_type, a4),572 convertArgument(a5_type, a5),573 convertArgument(a6_type, a6),574 convertArgument(a7_type, a7),575 convertArgument(a8_type, a8)576 )577 );578 },579 jsfficall9: function(580 obj,581 f,582 a1_type,583 a1,584 a2_type,585 a2,586 a3_type,587 a3,588 a4_type,589 a4,590 a5_type,591 a5,592 a6_type,593 a6,594 a7_type,595 a7,596 a8_type,597 a8,598 a9_type,599 a9600 ) {601 return convertResponse(602 functions[f].call(603 allocator_get(obj),604 convertArgument(a1_type, a1),605 convertArgument(a2_type, a2),606 convertArgument(a3_type, a3),607 convertArgument(a4_type, a4),608 convertArgument(a5_type, a5),609 convertArgument(a6_type, a6),610 convertArgument(a7_type, a7),611 convertArgument(a8_type, a8),612 convertArgument(a9_type, a9)613 )614 );615 },616 jsfficall10: function(617 obj,618 f,619 a1_type,620 a1,621 a2_type,622 a2,623 a3_type,624 a3,625 a4_type,626 a4,627 a5_type,628 a5,629 a6_type,630 a6,631 a7_type,632 a7,633 a8_type,634 a8,635 a9_type,636 a9,637 a10_type,638 a10639 ) {640 return convertResponse(641 functions[f].call(642 allocator_get(obj),643 convertArgument(a1_type, a1),644 convertArgument(a2_type, a2),645 convertArgument(a3_type, a3),646 convertArgument(a4_type, a4),647 convertArgument(a5_type, a5),648 convertArgument(a6_type, a6),649 convertArgument(a7_type, a7),650 convertArgument(a8_type, a8),651 convertArgument(a9_type, a9),652 convertArgument(a10_type, a10)653 )654 );655 }656 },657 cfg.imports || {}658 )659 }660 ).then(module => {661 mod = module;662 result.instance = module.instance;663 if (cfg.onLoad) {664 cfg.onLoad(module);665 }666 if (cfg.entry !== null) {...

Full Screen

Full Screen

wasm-module.js

Source:wasm-module.js Github

copy

Full Screen

...92 let b = mem.slice(offset, offset + length * size);93 let a = new t(b);94 return a;95 }96 function convertArgument(val_type, val) {97 if (val_type == TYPE_NUM) {98 } else if (val_type === TYPE_NOTHING) {99 val = undefined;100 } else if (val_type === TYPE_STRING) {101 val = getStringFromMemory(mod.instance.exports.memory.buffer, val);102 } else if (val_type === TYPE_BOOL) {103 val = val != 0;104 } else if (val_type === TYPE_OBJ) {105 val = allocator_get(val);106 } else if (val_type === TYPE_FUNCTION) {107 let id = val;108 val = function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {109 let l = arguments.length;110 if (l === 0) {111 mod.instance.exports.jsfficallback(112 id,113 0,114 0,115 0,116 0,117 0,118 0,119 0,120 0,121 0,122 0123 );124 } else if (l === 1) {125 mod.instance.exports.jsfficallback(126 id,127 convertResponse(a1),128 0,129 0,130 0,131 0,132 0,133 0,134 0,135 0,136 0137 );138 } else if (l === 2) {139 mod.instance.exports.jsfficallback(140 id,141 convertResponse(a1),142 convertResponse(a2),143 0,144 0,145 0,146 0,147 0,148 0,149 0,150 0151 );152 } else if (l === 3) {153 mod.instance.exports.jsfficallback(154 id,155 convertResponse(a1),156 convertResponse(a2),157 convertResponse(a3),158 0,159 0,160 0,161 0,162 0,163 0,164 0165 );166 } else if (l === 4) {167 mod.instance.exports.jsfficallback(168 id,169 convertResponse(a1),170 convertResponse(a2),171 convertResponse(a3),172 convertResponse(a4),173 0,174 0,175 0,176 0,177 0,178 0179 );180 } else if (l === 5) {181 mod.instance.exports.jsfficallback(182 id,183 convertResponse(a1),184 convertResponse(a2),185 convertResponse(a3),186 convertResponse(a4),187 convertResponse(a5),188 0,189 0,190 0,191 0,192 0193 );194 } else if (l === 6) {195 mod.instance.exports.jsfficallback(196 id,197 convertResponse(a1),198 convertResponse(a2),199 convertResponse(a3),200 convertResponse(a4),201 convertResponse(a5),202 convertResponse(a6),203 0,204 0,205 0,206 0207 );208 } else if (l === 7) {209 mod.instance.exports.jsfficallback(210 id,211 convertResponse(a1),212 convertResponse(a2),213 convertResponse(a3),214 convertResponse(a4),215 convertResponse(a5),216 convertResponse(a6),217 convertResponse(a7),218 0,219 0,220 0221 );222 } else if (l === 8) {223 mod.instance.exports.jsfficallback(224 id,225 convertResponse(a1),226 convertResponse(a2),227 convertResponse(a3),228 convertResponse(a4),229 convertResponse(a5),230 convertResponse(a6),231 convertResponse(a7),232 convertResponse(a8),233 0,234 0235 );236 } else if (l === 9) {237 mod.instance.exports.jsfficallback(238 id,239 convertResponse(a1),240 convertResponse(a2),241 convertResponse(a3),242 convertResponse(a4),243 convertResponse(a5),244 convertResponse(a6),245 convertResponse(a7),246 convertResponse(a8),247 convertResponse(a9),248 0249 );250 } else if (l === 10) {251 mod.instance.exports.jsfficallback(252 id,253 convertResponse(a1),254 convertResponse(a2),255 convertResponse(a3),256 convertResponse(a4),257 convertResponse(a5),258 convertResponse(a6),259 convertResponse(a7),260 convertResponse(a8),261 convertResponse(a9),262 convertResponse(a10)263 );264 }265 };266 } else if (val_type === TYPE_UINT8_ARRAY) {267 val = getTypedArrayFromMemory(268 Uint8Array,269 mod.instance.exports.memory.buffer,270 val,271 1272 );273 } else if (val_type === TYPE_INT8_ARRAY) {274 val = getTypedArrayFromMemory(275 Int8Array,276 mod.instance.exports.memory.buffer,277 val,278 1279 );280 } else if (val_type === TYPE_F32_ARRAY) {281 val = getTypedArrayFromMemory(282 Float32Array,283 mod.instance.exports.memory.buffer,284 val,285 4286 );287 } else if (val_type === TYPE_F64_ARRAY) {288 val = getTypedArrayFromMemory(289 Float64Array,290 mod.instance.exports.memory.buffer,291 val,292 8293 );294 } else if (val_type === TYPE_INT32_ARRAY) {295 val = getTypedArrayFromMemory(296 Int32Array,297 mod.instance.exports.memory.buffer,298 val,299 4300 );301 } else if (val_type === TYPE_UINT32_ARRAY) {302 val = getTypedArrayFromMemory(303 Uint32Array,304 mod.instance.exports.memory.buffer,305 val,306 4307 );308 } else if (val_type === TYPE_INT16_ARRAY) {309 val = getTypedArrayFromMemory(310 Int16Array,311 mod.instance.exports.memory.buffer,312 val,313 2314 );315 } else if (val_type === TYPE_UINT16_ARRAY) {316 val = getTypedArrayFromMemory(317 Uint16Array,318 mod.instance.exports.memory.buffer,319 val,320 2321 );322 } else if (val_type === TYPE_MEMORY) {323 val = mod.instance.exports.memory.buffer;324 }else {325 throw error("Unknown data type");326 }327 return val;328 }329 function convertResponse(r) {330 const type = typeof r;331 if (type === "string") {332 return createString(r);333 } else if (type === "number") {334 return r;335 } else if (r === undefined) {336 return 0;337 } else if (r === null) {338 return 1;339 } else if (r === true) {340 return 1;341 } else if (r === false) {342 return 0;343 } else if (r.constructor === Float32Array) {344 return createTypedArray(r,Float32Array,4)345 } else if (r.constructor === Uint8Array) {346 return createTypedArray(r,Uint8Array,1)347 } else if (r.constructor === Int8Array) {348 return createTypedArray(r,Int8Array,1)349 } else if (r.constructor === Float64Array) {350 return createTypedArray(r,Float64Array,8)351 } else if (r.constructor === Int32Array) {352 return createTypedArray(r,Int32Array,4)353 } else if (r.constructor === Uint32Array) {354 return createTypedArray(r,Uint32Array,4)355 } else if (r.constructor === Int16Array) {356 return createTypedArray(r,Int16Array,2)357 } else if (r.constructor === Uint16Array) {358 return createTypedArray(r,Uint16Array,2)359 }360 return allocate(r);361 }362 if (typeof cfg === "string") {363 cfg = { path: cfg };364 }365 fetch(cfg.path)366 .then(response => response.arrayBuffer())367 .then(bytes =>368 WebAssembly.instantiate(bytes, {369 env: {370 jsffithrowerror: function(e) {371 let err = getStringFromMemory(372 mod.instance.exports.memory.buffer,373 e374 );375 console.error(err);376 throw new Error("Web assembly module exited unexpectedly.");377 },378 jsffirelease: function(obj) {379 allocator_release(obj);380 },381 jsffiregister: function(code) {382 code = getStringFromMemory(383 mod.instance.exports.memory.buffer,384 code385 );386 let id = functions.length;387 functions.push(eval("("+code+")"));388 return id;389 },390 jsfficall0: function(obj, f) {391 return convertResponse(functions[f].call(allocator_get(obj)));392 },393 jsfficall1: function(obj, f, a1_type, a1) {394 return convertResponse(395 functions[f].call(396 allocator_get(obj),397 convertArgument(a1_type, a1)398 )399 );400 },401 jsfficall2: function(obj, f, a1_type, a1, a2_type, a2) {402 return convertResponse(403 functions[f].call(404 allocator_get(obj),405 convertArgument(a1_type, a1),406 convertArgument(a2_type, a2)407 )408 );409 },410 jsfficall3: function(411 obj,412 f,413 a1_type,414 a1,415 a2_type,416 a2,417 a3_type,418 a3419 ) {420 return convertResponse(421 functions[f].call(422 allocator_get(obj),423 convertArgument(a1_type, a1),424 convertArgument(a2_type, a2),425 convertArgument(a3_type, a3)426 )427 );428 },429 jsfficall4: function(430 obj,431 f,432 a1_type,433 a1,434 a2_type,435 a2,436 a3_type,437 a3,438 a4_type,439 a4440 ) {441 return convertResponse(442 functions[f].call(443 allocator_get(obj),444 convertArgument(a1_type, a1),445 convertArgument(a2_type, a2),446 convertArgument(a3_type, a3),447 convertArgument(a4_type, a4)448 )449 );450 },451 jsfficall5: function(452 obj,453 f,454 a1_type,455 a1,456 a2_type,457 a2,458 a3_type,459 a3,460 a4_type,461 a4,462 a5_type,463 a5464 ) {465 return convertResponse(466 functions[f].call(467 allocator_get(obj),468 convertArgument(a1_type, a1),469 convertArgument(a2_type, a2),470 convertArgument(a3_type, a3),471 convertArgument(a4_type, a4),472 convertArgument(a5_type, a5)473 )474 );475 },476 jsfficall6: function(477 obj,478 f,479 a1_type,480 a1,481 a2_type,482 a2,483 a3_type,484 a3,485 a4_type,486 a4,487 a5_type,488 a5,489 a6_type,490 a6491 ) {492 return convertResponse(493 functions[f].call(494 allocator_get(obj),495 convertArgument(a1_type, a1),496 convertArgument(a2_type, a2),497 convertArgument(a3_type, a3),498 convertArgument(a4_type, a4),499 convertArgument(a5_type, a5),500 convertArgument(a6_type, a6)501 )502 );503 },504 jsfficall7: function(505 obj,506 f,507 a1_type,508 a1,509 a2_type,510 a2,511 a3_type,512 a3,513 a4_type,514 a4,515 a5_type,516 a5,517 a6_type,518 a6,519 a7_type,520 a7521 ) {522 return convertResponse(523 functions[f].call(524 allocator_get(obj),525 convertArgument(a1_type, a1),526 convertArgument(a2_type, a2),527 convertArgument(a3_type, a3),528 convertArgument(a4_type, a4),529 convertArgument(a5_type, a5),530 convertArgument(a6_type, a6),531 convertArgument(a7_type, a7)532 )533 );534 },535 jsfficall8: function(536 obj,537 f,538 a1_type,539 a1,540 a2_type,541 a2,542 a3_type,543 a3,544 a4_type,545 a4,546 a5_type,547 a5,548 a6_type,549 a6,550 a7_type,551 a7,552 a8_type,553 a8554 ) {555 return convertResponse(556 functions[f].call(557 allocator_get(obj),558 convertArgument(a1_type, a1),559 convertArgument(a2_type, a2),560 convertArgument(a3_type, a3),561 convertArgument(a4_type, a4),562 convertArgument(a5_type, a5),563 convertArgument(a6_type, a6),564 convertArgument(a7_type, a7),565 convertArgument(a8_type, a8)566 )567 );568 },569 jsfficall9: function(570 obj,571 f,572 a1_type,573 a1,574 a2_type,575 a2,576 a3_type,577 a3,578 a4_type,579 a4,580 a5_type,581 a5,582 a6_type,583 a6,584 a7_type,585 a7,586 a8_type,587 a8,588 a9_type,589 a9590 ) {591 return convertResponse(592 functions[f].call(593 allocator_get(obj),594 convertArgument(a1_type, a1),595 convertArgument(a2_type, a2),596 convertArgument(a3_type, a3),597 convertArgument(a4_type, a4),598 convertArgument(a5_type, a5),599 convertArgument(a6_type, a6),600 convertArgument(a7_type, a7),601 convertArgument(a8_type, a8),602 convertArgument(a9_type, a9)603 )604 );605 },606 jsfficall10: function(607 obj,608 f,609 a1_type,610 a1,611 a2_type,612 a2,613 a3_type,614 a3,615 a4_type,616 a4,617 a5_type,618 a5,619 a6_type,620 a6,621 a7_type,622 a7,623 a8_type,624 a8,625 a9_type,626 a9,627 a10_type,628 a10629 ) {630 return convertResponse(631 functions[f].call(632 allocator_get(obj),633 convertArgument(a1_type, a1),634 convertArgument(a2_type, a2),635 convertArgument(a3_type, a3),636 convertArgument(a4_type, a4),637 convertArgument(a5_type, a5),638 convertArgument(a6_type, a6),639 convertArgument(a7_type, a7),640 convertArgument(a8_type, a8),641 convertArgument(a9_type, a9),642 convertArgument(a10_type, a10)643 )644 );645 }646 }647 }).then(module => {648 mod = module;649 if (cfg.onLoad) {650 cfg.onLoad(module);651 }652 module.instance.exports.main();653 })654 );655 }656};...

Full Screen

Full Screen

center-entered-calls.controller.js

Source:center-entered-calls.controller.js Github

copy

Full Screen

...54const getMappingIndex = async ({ data, service_name }) => {55 console.log("rep_number_data : " + JSON.stringify(data));56 var mapping_index;57 for(var i=0; i<length(data); i++) {58 if(data[i].REP_NUMBER && convertArgument(data[i].REP_NUMBER) == service_name) mapping_index = data[i].REP_INDEX59 if(data[i].SERVICE_NAME && convertArgument(data[i].SERVICE_NAME) == service_name) mapping_index = data[i].SERVICE_INDEX60 }61 return mapping_index;62}63const addColumnNum = (data) => {64 for(var i=0; i<length(data); i++) {65 data[i].NUM = i+1;66 }67 return data;68};69const omitColumn = (data) => {70 var filtered_data = new Array();71 for(var i=0; i<length(data); i++) {72 filtered_data[i] = omit(['DT_KEY', 'VQ_KEY', 'PREV_VQ_KEY', 'REP_INDEX', 'SERVICE_INDEX', 'RESPONSE_RATE'], data[i]);73 }74 return filtered_data;75};76const getSum = (data) => {77 var sum_data = new Object();78 var sumData = 0;79 sumData = sum(pluck('CONTACT_CENTER_ENTERED', data));80 sum_data.CONTACT_CENTER_ENTERED = sumData || 0;81 sumData = sum(pluck('AGENT_QUEUE_ENTERED', data));82 sum_data.AGENT_QUEUE_ENTERED = sumData || 0;83 sumData = sum(pluck('AGENT_CONNECTED', data));84 sum_data.AGENT_CONNECTED = sumData || 0;85 sumData = sum(pluck('AGENT_QUEUE_ABANDONED', data));86 sum_data.AGENT_QUEUE_ABANDONED = sumData || 0;87 sumData = sum(pluck('AGENT_RING_ABANDONED', data));88 sum_data.AGENT_RING_ABANDONED = sumData || 0;89 sumData = sum(pluck('SYSTEM_ABANDONED', data));90 sum_data.SYSTEM_ABANDONED = sumData || 0;91 sumData = sum(pluck('FORWARDED', data));92 sum_data.FORWARDED = sumData || 0;93 return sum_data;94};95const getAvg = (sorted_data, sum_data) => {96 // var data_length = length(sorted_data);97 var data_length;98 data_length = length(sorted_data) == 0 ? 1 : length(sorted_data);99 var avg_data = new Object();100 var avgData;101 avgData = prop('CONTACT_CENTER_ENTERED', sum_data)/data_length;102 avg_data.CONTACT_CENTER_ENTERED = avgData.toFixed(2);103 avgData = prop('AGENT_QUEUE_ENTERED', sum_data)/data_length;104 avg_data.CONSULT_ENTERED = avgData.toFixed(2); 105 avgData = prop('AGENT_CONNECTED', sum_data)/data_length;106 avg_data.AGENT_CONNECTED = avgData.toFixed(2); 107 avgData = prop('AGENT_QUEUE_ABANDONED', sum_data)/data_length;108 avg_data.AGENT_QUEUE_ABANDONED = avgData.toFixed(2); 109 avgData = prop('AGENT_RING_ABANDONED', sum_data)/data_length;110 avg_data.AGENT_RING_ABANDONED = avgData.toFixed(2); 111 avgData = prop('SYSTEM_ABANDONED', sum_data)/data_length;112 avg_data.SYSTEM_ABANDONED = avgData.toFixed(2); 113 avgData = prop('FORWARDED', sum_data)/data_length;114 avg_data.FORWARDED = avgData.toFixed(2); 115 avgData = prop('AGENT_CONNECTED', sum_data) / prop('AGENT_QUEUE_ENTERED', sum_data) *100;116 prop('AGENT_CONNECTED', sum_data) == 0 ? avg_data.RESPONSE_RATE = 0 : avg_data.RESPONSE_RATE = avgData.toFixed(2);117 return avg_data;118};119const readDatasource = async({ site_cd, date_unit, start_date, end_date, start_time, end_time, enter_queue_key, consult_queue_key }) => {120 return Promise.all([121 getSiteRepNumber({ site_cd, apply_date: end_date }),122 getSiteServiceName({ site_cd, apply_date: end_date }),123 EnterQueue.find({ site_cd, date_unit, start_date, end_date, start_time, end_time, enter_queue_key }),124 ConsultConnectQueue.find({ site_cd, date_unit, start_date, end_date, start_time, end_time, consult_queue_key })125 ])126};127 128const read = async (req, res, next) => {129 try {130 console.log("center-entered-calls")131 const site_cd = filterArgumentsIncludeKorean(req.params.site_cd);132 const date_unit = filterArgumentsIncludeAlphabet(req.params.date_unit);133 const param = req.query || {};134 135 var existMandatoryParam = true;136 var mandatoryParamList = ["startdate", "enddate"];137 var missingParamList = [];138 if (!param.startdate || param.startdate == '') {139 existMandatoryParam = false;140 missingParamList.push("startdate");141 }142 if (!param.enddate || param.enddate == '') {143 existMandatoryParam = false;144 missingParamList.push("enddate");145 }146 if (!existMandatoryParam) {147 res148 .status(418)149 .send(150 getResDataForNotMandatoryParam(mandatoryParamList, missingParamList)151 );152 return;153 }154 var start_date = filterArgumentsNumber(param.startdate).substring(0,8);155 var end_date = filterArgumentsNumber(param.enddate).substring(0,8);156 if(date_unit == 'monthly') {157 start_date = filterArgumentsNumber(param.startdate).substring(0,6) + '01';158 end_date = filterArgumentsNumber(param.enddate).substring(0,6) + '31';159 }160 if (length(start_date) != 8 || length(end_date) != 8) {161 console.log()162 res.status(418).send("Wrong Date Format");163 return;164 }165 var start_time = '';166 var end_time = '';167 if (date_unit == 'hourly' && param.starttime && param.endtime) {168 console.log("date_unit: " + date_unit);169 start_time = filterArgumentsTimeFormat(param.starttime);170 end_time = filterArgumentsTimeFormat(param.endtime);171 }172 var rep_number_index = '';173 var service_name_index = '';174 var enter_queue_key = '';175 var consult_queue_key = '';176 177 enter_queue_key = await getEnterQueueKeys({ site_cd, end_date });178 console.log('[consult-connected-calls.controller] enter_queue_key: ' + JSON.stringify(enter_queue_key));179 180 consult_queue_key = await getConsultQueueKeys({ site_cd, end_date });181 console.log('[consult-connected-calls.controller] consult_queue_key: ' + JSON.stringify(consult_queue_key));182 const [183 enter_queue_info,184 consult_queue_info,185 enter_queue_data,186 consult_queue_data187 ] = await readDatasource({ site_cd, date_unit, start_date, end_date, start_time, end_time, enter_queue_key, consult_queue_key });188 console.log('[consult-connected-calls.controller] enter_queue_info: ' + JSON.stringify(enter_queue_info));189 console.log('[consult-connected-calls.controller] consult_queue_info: ' + JSON.stringify(consult_queue_info));190 console.log('[consult-connected-calls.controller] enter_queue_data: ' + JSON.stringify(enter_queue_data));191 console.log('[consult-connected-calls.controller] consult_queue_data: ' + JSON.stringify(consult_queue_data));192 if(param.repnumber) {193 rep_number = convertArgument(param.repnumber);194 console.log("rep_number : " + rep_number);195 rep_number_index = await getMappingIndex({ data: enter_queue_info, service_name: rep_number });196 // rep_number_index = await getDatabaseServiceName({ site_cd, end_date, service_name: rep_number });197 console.log("rep_number_index : " + rep_number_index);198 }199 if(param.servicename) {200 service_name = convertArgument(param.servicename);201 console.log("service_name : " + service_name);202 service_name_index = await getMappingIndex({ data: consult_queue_info, service_name: service_name });203 // service_name_index = await getDatabaseServiceName({ site_cd, end_date, service_name: service_name });204 console.log("service_name_index : " + service_name_index);205 }206 const filterByParameter = filterTwoSlot(207 param.repnumber ? filterByRepNumber(rep_number_index) : filterNone,208 param.servicename ? filterByServiceName(service_name_index) : filterNone209 )210 const enter_queue_data_n_info = await leftJoinOnVqKey(enter_queue_data, enter_queue_info);211 console.log('[consult-connected-calls.controller] consult_queue_info_n_data: ' + JSON.stringify(enter_queue_data_n_info));212 const consult_queue_data_n_info = await leftJoinOnVqKey(consult_queue_data, consult_queue_info);213 console.log('[consult-connected-calls.controller] consult_queue_info_n_data: ' + JSON.stringify(consult_queue_data_n_info));214 const consult_queue_n_enter_queue = await leftJoinOnDTKeyAndPrevMappingIndex(enter_queue_data_n_info, consult_queue_data_n_info);...

Full Screen

Full Screen

consult-connected-calls.controller.js

Source:consult-connected-calls.controller.js Github

copy

Full Screen

...39const getMappingIndex = async ({ data, service_name }) => {40 console.log("rep_number_data : " + JSON.stringify(data));41 var mapping_index;42 for(var i=0; i<length(data); i++) {43 if(data[i].REP_NUMBER && convertArgument(data[i].REP_NUMBER) == service_name) mapping_index = data[i].REP_INDEX44 if(data[i].SERVICE_NAME && convertArgument(data[i].SERVICE_NAME) == service_name) mapping_index = data[i].SERVICE_INDEX45 }46 return mapping_index;47}48const addColumnNum = (data) => {49 for(var i=0; i<length(data); i++) {50 data[i].NUM = i+1;51 }52 return data;53};54const omitColumn = (data) => {55 var filtered_data = new Array();56 for(var i=0; i<length(data); i++) {57 filtered_data[i] = omit(['VQ_KEY', 'PREV_VQ_KEY', 'REP_INDEX', 'SERVICE_INDEX'], data[i]);58 }59 return filtered_data;60};61const getSum = (data) => {62 var sum_data = new Object();63 var sumData = 0;64 sumData = sum(pluck('AGENT_QUEUE_ENTERED', data));65 sum_data.AGENT_QUEUE_ENTERED = sumData;66 sumData = sum(pluck('AGENT_CONNECTED', data));67 sum_data.AGENT_CONNECTED = sumData;68 sumData = sum(pluck('AGENT_QUEUE_ABANDONED', data));69 sum_data.AGENT_QUEUE_ABANDONED = sumData;70 sumData = sum(pluck('AGENT_RING_ABANDONED', data));71 sum_data.AGENT_RING_ABANDONED = sumData;72 sumData = sum(pluck('SYSTEM_ABANDONED', data));73 sum_data.SYSTEM_ABANDONED = sumData;74 sumData = sum(pluck('FORWARDED', data));75 sum_data.FORWARDED = sumData;76 return sum_data;77};78const getAvg = (sorted_data, sum_data) => {79 // var data_length = length(sorted_data);80 var data_length;81 data_length = length(sorted_data) == 0 ? 1 : length(sorted_data);82 var avg_data = new Object();83 var avgData;84 avgData = prop('AGENT_QUEUE_ENTERED', sum_data)/data_length;85 avg_data.CONSULT_ENTERED = avgData.toFixed(2); 86 avgData = prop('AGENT_CONNECTED', sum_data)/data_length;87 avg_data.AGENT_CONNECTED = avgData.toFixed(2); 88 avgData = prop('AGENT_QUEUE_ABANDONED', sum_data)/data_length;89 avg_data.AGENT_QUEUE_ABANDONED = avgData.toFixed(2); 90 avgData = prop('AGENT_RING_ABANDONED', sum_data)/data_length;91 avg_data.AGENT_RING_ABANDONED = avgData.toFixed(2); 92 avgData = prop('SYSTEM_ABANDONED', sum_data)/data_length;93 avg_data.SYSTEM_ABANDONED = avgData.toFixed(2); 94 avgData = prop('FORWARDED', sum_data)/data_length;95 avg_data.FORWARDED = avgData.toFixed(2); 96 avgData = prop('AGENT_CONNECTED', sum_data) / prop('AGENT_QUEUE_ENTERED', sum_data) *100;97 prop('AGENT_CONNECTED', sum_data) == 0 ? avg_data.RESPONSE_RATE = 0 : avg_data.RESPONSE_RATE = avgData.toFixed(2);98 return avg_data;99};100const readDatasource = async({ site_cd, date_unit, start_date, end_date, start_time, end_time, enter_queue_key, consult_queue_key }) => {101 return Promise.all([102 getSiteRepNumber({ site_cd, apply_date: end_date }),103 getSiteServiceName({ site_cd, apply_date: end_date }),104 ConsultConnectQueue.find({ site_cd, date_unit, start_date, end_date, start_time, end_time, consult_queue_key })105 ])106};107const read = async (req, res, next) => {108 try {109 console.log("consult-connect-calls")110 const site_cd = filterArgumentsIncludeKorean(req.params.site_cd);111 const date_unit = filterArgumentsIncludeAlphabet(req.params.date_unit);112 const param = req.query || {};113 114 var existMandatoryParam = true;115 var mandatoryParamList = ["startdate", "enddate"];116 var missingParamList = [];117 if (!param.startdate || param.startdate == '') {118 existMandatoryParam = false;119 missingParamList.push("startdate");120 }121 if (!param.enddate || param.enddate == '') {122 existMandatoryParam = false;123 missingParamList.push("enddate");124 }125 if (!existMandatoryParam) {126 res127 .status(418)128 .send(129 getResDataForNotMandatoryParam(mandatoryParamList, missingParamList)130 );131 return;132 }133 var start_date = filterArgumentsNumber(param.startdate).substring(0,8);134 var end_date = filterArgumentsNumber(param.enddate).substring(0,8);135 if(date_unit == 'monthly') {136 start_date = filterArgumentsNumber(param.startdate).substring(0,6) + '01';137 end_date = filterArgumentsNumber(param.enddate).substring(0,6) + '31';138 }139 if (length(start_date) != 8 || length(end_date) != 8) {140 res.status(418).send("Wrong Date Format");141 return;142 }143 var start_time = '';144 var end_time = '';145 if (date_unit == 'hourly' && param.starttime && param.endtime) {146 console.log("date_unit: " + date_unit);147 start_time = filterArgumentsTimeFormat(param.starttime);148 end_time = filterArgumentsTimeFormat(param.endtime);149 }150 var rep_number_index = '';151 var service_name_index = '';152 var enter_queue_key = '';153 var consult_queue_key = '';154 155 enter_queue_key = await getEnterQueueKeys({ site_cd, end_date });156 console.log('[consult-connected-calls.controller] enter_queue_key: ' + JSON.stringify(enter_queue_key));157 158 consult_queue_key = await getConsultQueueKeys({ site_cd, end_date });159 console.log('[consult-connected-calls.controller] consult_queue_key: ' + JSON.stringify(consult_queue_key));160 const [161 enter_queue_info,162 consult_queue_info,163 consult_queue_data164 ] = await readDatasource({ site_cd, date_unit, start_date, end_date, start_time, end_time, enter_queue_key, consult_queue_key });165 console.log('[consult-connected-calls.controller] enter_queue_info: ' + JSON.stringify(enter_queue_info));166 console.log('[consult-connected-calls.controller] consult_queue_info: ' + JSON.stringify(consult_queue_info));167 console.log('[consult-connected-calls.controller] consult_queue_data: ' + JSON.stringify(consult_queue_data));168 if(param.repnumber) {169 rep_number = convertArgument(param.repnumber);170 console.log("rep_number : " + rep_number);171 rep_number_index = await getMappingIndex({ data: enter_queue_info, service_name: rep_number });172 // rep_number_index = await getDatabaseServiceName({ site_cd, end_date, service_name: rep_number });173 console.log("rep_number_index : " + rep_number_index);174 }175 if(param.servicename) {176 service_name = convertArgument(param.servicename);177 console.log("service_name : " + service_name);178 service_name_index = await getMappingIndex({ data: consult_queue_info, service_name: service_name });179 // service_name_index = await getDatabaseServiceName({ site_cd, end_date, service_name: service_name });180 console.log("service_name_index : " + service_name_index);181 }182 const filterByParameter = filterTwoSlot(183 param.repnumber ? filterByRepNumber(rep_number_index) : filterNone,184 param.servicename ? filterByServiceName(service_name_index) : filterNone185 )186 const consult_queue_data_n_info = await leftJoinOnVqKey(consult_queue_data, consult_queue_info);187 console.log('[consult-connected-calls.controller] consult_queue_info_n_data: ' + JSON.stringify(consult_queue_data_n_info));188 const consult_queue_n_enter_queue = await leftJoinOnPrevMappingIndex(consult_queue_data_n_info, enter_queue_info);189 console.log('[consult-connected-calls.controller] consult_queue_n_enter_queue: ' + JSON.stringify(consult_queue_n_enter_queue));190 ...

Full Screen

Full Screen

templateHelper.js

Source:templateHelper.js Github

copy

Full Screen

...96 const ret = [];97 parentsList.forEach((parentName) => {98 const args = constructors[ parentName ];99 for (const [type, path, value = null] of args) {100 ret.push(`${ convertArgument(type, path, value) }, // ${ path }`);101 }102 });103 return `${ ret.join(`\n${ writeTabs(numTap) }`) }`;104}105/**106 * @notice write Token's constructor arguments in migration file107 */108export function writeTokenArguments(input, numTap = 2) {109 const {110 token: {111 token_type: { is_minime },112 token_name,113 token_symbol,114 decimals,115 },116 } = input;117 if (!is_minime) {118 return []; // no arguments for Zeppelin's Mintable token119 }120 const ret = [121 "\"0x00\"", // token factory122 ];123 return `${ ret.join(`,\n${ writeTabs(numTap) }`) }`;124}125export function wrapNewBigNumber(value) {126 return `new BigNumber("${ new BigNumber(value).toFixed(0) }")`;127}128/**129 * @notice convert argument info to javascript statement130 */131export function convertArgument(type, path, value = null) {132 if (!value) return `get(data, "${ path }")`;133 if (type === "address") return convertAddress(value);134 if (moment.isDate(value) || moment.isMoment(value)) return wrapNewBigNumber(convertDateString(value));135 return wrapNewBigNumber(value);136}137export function convertDateString(v) {138 return moment.utc(v).unix();139}140export function convertAddress(s) {141 return `"${ s }"`;142}143export function convertBigNumber(b) {144 return b.toFixed(0);145}...

Full Screen

Full Screen

practice4.js

Source:practice4.js Github

copy

Full Screen

...49// Write a function that converts the argument values. If it will be a string, convert it to number and wise versa.50// It should return an array of converted values.51// console.log(convert("1", 2, 3, "4"));52// convert('1', 2, 3, '4') // [1, '2', '3', 4]53// function convertArgument(...args) {54// for (let i = 0; i < args.length; i += 1) {55// if (typeof args[i] === 'string') {56// args[i] = Number(args[i]);57// } else {58// args[i] = String(args[i]);59// }60// }61// return args;62// }63// console.log(convertArgument('1', 2, 3, '4'));64// ----------------------65// function convertArgument(...args) {66// const newArray = [];67// for (let argument of args) {68// if (typeof argument === "string") {69// argument = Number(argument);70// newArray.push(argument);71// } else {72// argument = String(argument);73// newArray.push(argument);74// }75// }76// return newArray;77// }78// console.log(convertArgument('1', 2, 3, '4'));79// ------------------------80// TASK #381// Write a function that checks if array contains arg passed as a parameter value and returns true in this case.82// containsValue([2, 5, 8], 2) 83// returns true84// containsValue([12, 4, 6], 5) 85// returns false86// function containsValue(arrayOne, arrayTwo) {87// for (const element of arrayOne) {88// if (element === arrayTwo) {89// return true;90// }91// return false;92// }...

Full Screen

Full Screen

Bytecode.js

Source:Bytecode.js Github

copy

Full Screen

...38 const flatArguments = [];39 for (const object in args) {40 if (args[object] instanceof Array) {41 for (const nestObject in object) {42 flatArguments.push(Bytecode.convertArgument(object[nestObject], true));43 }44 } else {45 flatArguments.push(Bytecode.convertArgument(args[object], true));46 }47 }48 return flatArguments;49 }50 static convertArgument(argument, searchBindings) {51 if (searchBindings) {52 const variable = Bindings.getBoundVariable(argument);53 if (undefined !== variable) {54 return new Binding(variable, Bytecode.convertArgument(argument, false));55 }56 }57 //58 if (argument.propType) {59 return argument.asAdmin().getBytecode();60 } else if (argument instanceof Map) {61 const map = new Map();62 for (const key in argument) {63 map.put(Bytecode.convertArgument(key, true), Bytecode.convertArgument(argument[key], true));64 }65 return map;66 } else if (argument instanceof Array) {67 const list = [];68 for (const key in argument) {69 list.push(Bytecode.convertArgument(argument[key], true));70 }71 return list;72 }73 return argument;74 }75 cloneInstructions(array) {76 const newArray = [];77 array.map(one => newArray.push(one.clone()));78 return newArray;79 }80 clone() {81 try {82 const clone = Object.assign(Object.create(this), this);83 clone.sourceInstructions = this.cloneInstructions(this.sourceInstructions);...

Full Screen

Full Screen

data-helper.js

Source:data-helper.js Github

copy

Full Screen

...71const getMappingIndex = async ({ data, service_name }) => {72 console.log("rep_number_data : " + JSON.stringify(data));73 var mapping_index;74 for(var i=0; i<length(data); i++) {75 if(data[i].REP_NUMBER && convertArgument(data[i].REP_NUMBER) == service_name) mapping_index = data[i].REP_INDEX76 if(data[i].SERVICE_NAME && convertArgument(data[i].SERVICE_NAME) == service_name) mapping_index = data[i].SERVICE_INDEX77 }78 return mapping_index;79}80 module.exports = {81 addMetaData,82 filterByRepNumber,83 filterByServiceName,84 filterNone,85 filterTwoSlot,86 fulfillServiceReqData,87 leftJoinOnVqKey,88 leftJoinOnPrevMappingIndex,89 leftJoinOnDTKeyAndPrevMappingIndex,90 getMappingIndex...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Puppeteer automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful