How to use old_num_locals method in wpt

Best JavaScript code snippet using wpt

wasm-module-builder.js

Source:wasm-module-builder.js Github

copy

Full Screen

1// Copyright 2016 the V8 project authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4// Used for encoding f32 and double constants to bits.5let __buffer = new ArrayBuffer(8);6let byte_view = new Int8Array(__buffer);7let f32_view = new Float32Array(__buffer);8let f64_view = new Float64Array(__buffer);9class Binary extends Array {10 emit_u8(val) {11 this.push(val);12 }13 emit_u16(val) {14 this.push(val & 0xff);15 this.push((val >> 8) & 0xff);16 }17 emit_u32(val) {18 this.push(val & 0xff);19 this.push((val >> 8) & 0xff);20 this.push((val >> 16) & 0xff);21 this.push((val >> 24) & 0xff);22 }23 emit_u32v(val) {24 while (true) {25 let v = val & 0xff;26 val = val >>> 7;27 if (val == 0) {28 this.push(v);29 break;30 }31 this.push(v | 0x80);32 }33 }34 emit_bytes(data) {35 for (let i = 0; i < data.length; i++) {36 this.push(data[i] & 0xff);37 }38 }39 emit_string(string) {40 // When testing illegal names, we pass a byte array directly.41 if (string instanceof Array) {42 this.emit_u32v(string.length);43 this.emit_bytes(string);44 return;45 }46 // This is the hacky way to convert a JavaScript string to a UTF8 encoded47 // string only containing single-byte characters.48 let string_utf8 = unescape(encodeURIComponent(string));49 this.emit_u32v(string_utf8.length);50 for (let i = 0; i < string_utf8.length; i++) {51 this.emit_u8(string_utf8.charCodeAt(i));52 }53 }54 emit_header() {55 this.push(kWasmH0, kWasmH1, kWasmH2, kWasmH3,56 kWasmV0, kWasmV1, kWasmV2, kWasmV3);57 }58 emit_section(section_code, content_generator) {59 // Emit section name.60 this.emit_u8(section_code);61 // Emit the section to a temporary buffer: its full length isn't know yet.62 const section = new Binary;63 content_generator(section);64 // Emit section length.65 this.emit_u32v(section.length);66 // Copy the temporary buffer.67 for (const b of section) {68 this.push(b);69 }70 }71}72class WasmFunctionBuilder {73 constructor(module, name, type_index) {74 this.module = module;75 this.name = name;76 this.type_index = type_index;77 this.body = [];78 }79 numLocalNames() {80 if (this.local_names === undefined) return 0;81 let num_local_names = 0;82 for (let loc_name of this.local_names) {83 if (loc_name !== undefined) ++num_local_names;84 }85 return num_local_names;86 }87 exportAs(name) {88 this.module.addExport(name, this.index);89 return this;90 }91 exportFunc() {92 this.exportAs(this.name);93 return this;94 }95 addBody(body) {96 for (let b of body) {97 if (typeof b !== 'number' || (b & (~0xFF)) !== 0 )98 throw new Error('invalid body (entries must be 8 bit numbers): ' + body);99 }100 this.body = body.slice();101 // Automatically add the end for the function block to the body.102 this.body.push(kExprEnd);103 return this;104 }105 addBodyWithEnd(body) {106 this.body = body;107 return this;108 }109 getNumLocals() {110 let total_locals = 0;111 for (let l of this.locals || []) {112 for (let type of ["i32", "i64", "f32", "f64"]) {113 total_locals += l[type + "_count"] || 0;114 }115 }116 return total_locals;117 }118 addLocals(locals, names) {119 const old_num_locals = this.getNumLocals();120 if (!this.locals) this.locals = []121 this.locals.push(locals);122 if (names) {123 if (!this.local_names) this.local_names = [];124 const missing_names = old_num_locals - this.local_names.length;125 this.local_names.push(...new Array(missing_names), ...names);126 }127 return this;128 }129 end() {130 return this.module;131 }132}133class WasmGlobalBuilder {134 constructor(module, type, mutable) {135 this.module = module;136 this.type = type;137 this.mutable = mutable;138 this.init = 0;139 }140 exportAs(name) {141 this.module.exports.push({name: name, kind: kExternalGlobal,142 index: this.index});143 return this;144 }145}146class WasmModuleBuilder {147 constructor() {148 this.types = [];149 this.imports = [];150 this.exports = [];151 this.globals = [];152 this.functions = [];153 this.table_length_min = 0;154 this.table_length_max = undefined;155 this.element_segments = [];156 this.data_segments = [];157 this.explicit = [];158 this.num_imported_funcs = 0;159 this.num_imported_globals = 0;160 return this;161 }162 addStart(start_index) {163 this.start_index = start_index;164 return this;165 }166 addMemory(min, max, exp) {167 this.memory = {min: min, max: max, exp: exp};168 return this;169 }170 addExplicitSection(bytes) {171 this.explicit.push(bytes);172 return this;173 }174 stringToBytes(name) {175 var result = new Binary();176 result.emit_u32v(name.length);177 for (var i = 0; i < name.length; i++) {178 result.emit_u8(name.charCodeAt(i));179 }180 return result;181 }182 addCustomSection(name, bytes) {183 name = this.stringToBytes(name);184 var length = new Binary();185 length.emit_u32v(name.length + bytes.length);186 this.explicit.push([0, ...length, ...name, ...bytes]);187 }188 addType(type) {189 // TODO: canonicalize types?190 this.types.push(type);191 return this.types.length - 1;192 }193 addGlobal(local_type, mutable) {194 let glob = new WasmGlobalBuilder(this, local_type, mutable);195 glob.index = this.globals.length + this.num_imported_globals;196 this.globals.push(glob);197 return glob;198 }199 addFunction(name, type) {200 let type_index = (typeof type) == "number" ? type : this.addType(type);201 let func = new WasmFunctionBuilder(this, name, type_index);202 func.index = this.functions.length + this.num_imported_funcs;203 this.functions.push(func);204 return func;205 }206 addImport(module = "", name, type) {207 if (this.functions.length != 0) {208 throw new Error('Imported functions must be declared before local ones');209 }210 let type_index = (typeof type) == "number" ? type : this.addType(type);211 this.imports.push({module: module, name: name, kind: kExternalFunction,212 type: type_index});213 return this.num_imported_funcs++;214 }215 addImportedGlobal(module = "", name, type, mutable = false) {216 if (this.globals.length != 0) {217 throw new Error('Imported globals must be declared before local ones');218 }219 let o = {module: module, name: name, kind: kExternalGlobal, type: type,220 mutable: mutable};221 this.imports.push(o);222 return this.num_imported_globals++;223 }224 addImportedMemory(module = "", name, initial = 0, maximum) {225 let o = {module: module, name: name, kind: kExternalMemory,226 initial: initial, maximum: maximum};227 this.imports.push(o);228 return this;229 }230 addImportedTable(module = "", name, initial, maximum) {231 let o = {module: module, name: name, kind: kExternalTable, initial: initial,232 maximum: maximum};233 this.imports.push(o);234 }235 addExport(name, index) {236 this.exports.push({name: name, kind: kExternalFunction, index: index});237 return this;238 }239 addExportOfKind(name, kind, index) {240 this.exports.push({name: name, kind: kind, index: index});241 return this;242 }243 addDataSegment(addr, data, is_global = false) {244 this.data_segments.push({addr: addr, data: data, is_global: is_global});245 return this.data_segments.length - 1;246 }247 exportMemoryAs(name) {248 this.exports.push({name: name, kind: kExternalMemory, index: 0});249 }250 addElementSegment(base, is_global, array, is_import = false) {251 this.element_segments.push({base: base, is_global: is_global,252 array: array});253 if (!is_global) {254 var length = base + array.length;255 if (length > this.table_length_min && !is_import) {256 this.table_length_min = length;257 }258 if (length > this.table_length_max && !is_import) {259 this.table_length_max = length;260 }261 }262 return this;263 }264 appendToTable(array) {265 for (let n of array) {266 if (typeof n != 'number')267 throw new Error('invalid table (entries have to be numbers): ' + array);268 }269 return this.addElementSegment(this.table_length_min, false, array);270 }271 setTableBounds(min, max) {272 this.table_length_min = min;273 this.table_length_max = max;274 return this;275 }276 setTableLength(length) {277 this.table_length_min = length;278 this.table_length_max = length;279 return this;280 }281 setName(name) {282 this.name = name;283 return this;284 }285 toArray(debug = false) {286 let binary = new Binary;287 let wasm = this;288 // Add header289 binary.emit_header();290 // Add type section291 if (wasm.types.length > 0) {292 if (debug) print("emitting types @ " + binary.length);293 binary.emit_section(kTypeSectionCode, section => {294 section.emit_u32v(wasm.types.length);295 for (let type of wasm.types) {296 section.emit_u8(kWasmFunctionTypeForm);297 section.emit_u32v(type.params.length);298 for (let param of type.params) {299 section.emit_u8(param);300 }301 section.emit_u32v(type.results.length);302 for (let result of type.results) {303 section.emit_u8(result);304 }305 }306 });307 }308 // Add imports section309 if (wasm.imports.length > 0) {310 if (debug) print("emitting imports @ " + binary.length);311 binary.emit_section(kImportSectionCode, section => {312 section.emit_u32v(wasm.imports.length);313 for (let imp of wasm.imports) {314 section.emit_string(imp.module);315 section.emit_string(imp.name || '');316 section.emit_u8(imp.kind);317 if (imp.kind == kExternalFunction) {318 section.emit_u32v(imp.type);319 } else if (imp.kind == kExternalGlobal) {320 section.emit_u32v(imp.type);321 section.emit_u8(imp.mutable);322 } else if (imp.kind == kExternalMemory) {323 var has_max = (typeof imp.maximum) != "undefined";324 section.emit_u8(has_max ? 1 : 0); // flags325 section.emit_u32v(imp.initial); // initial326 if (has_max) section.emit_u32v(imp.maximum); // maximum327 } else if (imp.kind == kExternalTable) {328 section.emit_u8(kWasmAnyFunctionTypeForm);329 var has_max = (typeof imp.maximum) != "undefined";330 section.emit_u8(has_max ? 1 : 0); // flags331 section.emit_u32v(imp.initial); // initial332 if (has_max) section.emit_u32v(imp.maximum); // maximum333 } else {334 throw new Error("unknown/unsupported import kind " + imp.kind);335 }336 }337 });338 }339 // Add functions declarations340 if (wasm.functions.length > 0) {341 if (debug) print("emitting function decls @ " + binary.length);342 binary.emit_section(kFunctionSectionCode, section => {343 section.emit_u32v(wasm.functions.length);344 for (let func of wasm.functions) {345 section.emit_u32v(func.type_index);346 }347 });348 }349 // Add table section350 if (wasm.table_length_min > 0) {351 if (debug) print("emitting table @ " + binary.length);352 binary.emit_section(kTableSectionCode, section => {353 section.emit_u8(1); // one table entry354 section.emit_u8(kWasmAnyFunctionTypeForm);355 const max = wasm.table_length_max;356 const has_max = max !== undefined;357 section.emit_u8(has_max ? kHasMaximumFlag : 0);358 section.emit_u32v(wasm.table_length_min);359 if (has_max) section.emit_u32v(max);360 });361 }362 // Add memory section363 if (wasm.memory !== undefined) {364 if (debug) print("emitting memory @ " + binary.length);365 binary.emit_section(kMemorySectionCode, section => {366 section.emit_u8(1); // one memory entry367 const has_max = wasm.memory.max !== undefined;368 section.emit_u8(has_max ? kHasMaximumFlag : 0);369 section.emit_u32v(wasm.memory.min);370 if (has_max) section.emit_u32v(wasm.memory.max);371 });372 }373 // Add global section.374 if (wasm.globals.length > 0) {375 if (debug) print ("emitting globals @ " + binary.length);376 binary.emit_section(kGlobalSectionCode, section => {377 section.emit_u32v(wasm.globals.length);378 for (let global of wasm.globals) {379 section.emit_u8(global.type);380 section.emit_u8(global.mutable);381 if ((typeof global.init_index) == "undefined") {382 // Emit a constant initializer.383 switch (global.type) {384 case kWasmI32:385 section.emit_u8(kExprI32Const);386 section.emit_u32v(global.init);387 break;388 case kWasmI64:389 section.emit_u8(kExprI64Const);390 section.emit_u32v(global.init);391 break;392 case kWasmF32:393 section.emit_u8(kExprF32Const);394 f32_view[0] = global.init;395 section.emit_u8(byte_view[0]);396 section.emit_u8(byte_view[1]);397 section.emit_u8(byte_view[2]);398 section.emit_u8(byte_view[3]);399 break;400 case kWasmF64:401 section.emit_u8(kExprF64Const);402 f64_view[0] = global.init;403 section.emit_u8(byte_view[0]);404 section.emit_u8(byte_view[1]);405 section.emit_u8(byte_view[2]);406 section.emit_u8(byte_view[3]);407 section.emit_u8(byte_view[4]);408 section.emit_u8(byte_view[5]);409 section.emit_u8(byte_view[6]);410 section.emit_u8(byte_view[7]);411 break;412 }413 } else {414 // Emit a global-index initializer.415 section.emit_u8(kExprGetGlobal);416 section.emit_u32v(global.init_index);417 }418 section.emit_u8(kExprEnd); // end of init expression419 }420 });421 }422 // Add export table.423 var mem_export = (wasm.memory !== undefined && wasm.memory.exp);424 var exports_count = wasm.exports.length + (mem_export ? 1 : 0);425 if (exports_count > 0) {426 if (debug) print("emitting exports @ " + binary.length);427 binary.emit_section(kExportSectionCode, section => {428 section.emit_u32v(exports_count);429 for (let exp of wasm.exports) {430 section.emit_string(exp.name);431 section.emit_u8(exp.kind);432 section.emit_u32v(exp.index);433 }434 if (mem_export) {435 section.emit_string("memory");436 section.emit_u8(kExternalMemory);437 section.emit_u8(0);438 }439 });440 }441 // Add start function section.442 if (wasm.start_index !== undefined) {443 if (debug) print("emitting start function @ " + binary.length);444 binary.emit_section(kStartSectionCode, section => {445 section.emit_u32v(wasm.start_index);446 });447 }448 // Add element segments449 if (wasm.element_segments.length > 0) {450 if (debug) print("emitting element segments @ " + binary.length);451 binary.emit_section(kElementSectionCode, section => {452 var inits = wasm.element_segments;453 section.emit_u32v(inits.length);454 for (let init of inits) {455 section.emit_u8(0); // table index456 if (init.is_global) {457 section.emit_u8(kExprGetGlobal);458 } else {459 section.emit_u8(kExprI32Const);460 }461 section.emit_u32v(init.base);462 section.emit_u8(kExprEnd);463 section.emit_u32v(init.array.length);464 for (let index of init.array) {465 section.emit_u32v(index);466 }467 }468 });469 }470 // Add function bodies.471 if (wasm.functions.length > 0) {472 // emit function bodies473 if (debug) print("emitting code @ " + binary.length);474 binary.emit_section(kCodeSectionCode, section => {475 section.emit_u32v(wasm.functions.length);476 for (let func of wasm.functions) {477 // Function body length will be patched later.478 let local_decls = [];479 for (let l of func.locals || []) {480 if (l.i32_count > 0) {481 local_decls.push({count: l.i32_count, type: kWasmI32});482 }483 if (l.i64_count > 0) {484 local_decls.push({count: l.i64_count, type: kWasmI64});485 }486 if (l.f32_count > 0) {487 local_decls.push({count: l.f32_count, type: kWasmF32});488 }489 if (l.f64_count > 0) {490 local_decls.push({count: l.f64_count, type: kWasmF64});491 }492 }493 let header = new Binary;494 header.emit_u32v(local_decls.length);495 for (let decl of local_decls) {496 header.emit_u32v(decl.count);497 header.emit_u8(decl.type);498 }499 section.emit_u32v(header.length + func.body.length);500 section.emit_bytes(header);501 section.emit_bytes(func.body);502 }503 });504 }505 // Add data segments.506 if (wasm.data_segments.length > 0) {507 if (debug) print("emitting data segments @ " + binary.length);508 binary.emit_section(kDataSectionCode, section => {509 section.emit_u32v(wasm.data_segments.length);510 for (let seg of wasm.data_segments) {511 section.emit_u8(0); // linear memory index 0512 if (seg.is_global) {513 // initializer is a global variable514 section.emit_u8(kExprGetGlobal);515 section.emit_u32v(seg.addr);516 } else {517 // initializer is a constant518 section.emit_u8(kExprI32Const);519 section.emit_u32v(seg.addr);520 }521 section.emit_u8(kExprEnd);522 section.emit_u32v(seg.data.length);523 section.emit_bytes(seg.data);524 }525 });526 }527 // Add any explicitly added sections528 for (let exp of wasm.explicit) {529 if (debug) print("emitting explicit @ " + binary.length);530 binary.emit_bytes(exp);531 }532 // Add names.533 let num_function_names = 0;534 let num_functions_with_local_names = 0;535 for (let func of wasm.functions) {536 if (func.name !== undefined) ++num_function_names;537 if (func.numLocalNames() > 0) ++num_functions_with_local_names;538 }539 if (num_function_names > 0 || num_functions_with_local_names > 0 ||540 wasm.name !== undefined) {541 if (debug) print('emitting names @ ' + binary.length);542 binary.emit_section(kUnknownSectionCode, section => {543 section.emit_string('name');544 // Emit module name.545 if (wasm.name !== undefined) {546 section.emit_section(kModuleNameCode, name_section => {547 name_section.emit_string(wasm.name);548 });549 }550 // Emit function names.551 if (num_function_names > 0) {552 section.emit_section(kFunctionNamesCode, name_section => {553 name_section.emit_u32v(num_function_names);554 for (let func of wasm.functions) {555 if (func.name === undefined) continue;556 name_section.emit_u32v(func.index);557 name_section.emit_string(func.name);558 }559 });560 }561 // Emit local names.562 if (num_functions_with_local_names > 0) {563 section.emit_section(kLocalNamesCode, name_section => {564 name_section.emit_u32v(num_functions_with_local_names);565 for (let func of wasm.functions) {566 if (func.numLocalNames() == 0) continue;567 name_section.emit_u32v(func.index);568 name_section.emit_u32v(func.numLocalNames());569 for (let i = 0; i < func.local_names.length; ++i) {570 if (func.local_names[i] === undefined) continue;571 name_section.emit_u32v(i);572 name_section.emit_string(func.local_names[i]);573 }574 }575 });576 }577 });578 }579 return binary;580 }581 toBuffer(debug = false) {582 let bytes = this.toArray(debug);583 let buffer = new ArrayBuffer(bytes.length);584 let view = new Uint8Array(buffer);585 for (let i = 0; i < bytes.length; i++) {586 let val = bytes[i];587 if ((typeof val) == "string") val = val.charCodeAt(0);588 view[i] = val | 0;589 }590 return buffer;591 }592 instantiate(ffi) {593 let module = new WebAssembly.Module(this.toBuffer());594 let instance = new WebAssembly.Instance(module, ffi);595 return instance;596 }597 asyncInstantiate(ffi) {598 return WebAssembly.instantiate(this.toBuffer(), ffi)599 .then(({module, instance}) => instance);600 }601 toModule(debug = false) {602 return new WebAssembly.Module(this.toBuffer(debug));603 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.old_num_locals(function(err, data) {4 console.log(data);5});6var wpt = require('webpagetest');7var wpt = new WebPageTest('www.webpagetest.org');8wpt.old_num_visitors(function(err, data) {9 console.log(data);10});11var wpt = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org');13wpt.old_num_tests(function(err, data) {14 console.log(data);15});16var wpt = require('webpagetest');17var wpt = new WebPageTest('www.webpagetest.org');18wpt.old_num_locations(function(err, data) {19 console.log(data);20});21var wpt = require('webpagetest');22var wpt = new WebPageTest('www.webpagetest.org');23wpt.old_num_connectivity(function(err, data) {24 console.log(data);25});26var wpt = require('webpagetest');27var wpt = new WebPageTest('www.webpagetest.org');28wpt.old_num_browsers(function(err, data) {29 console.log(data);30});31var wpt = require('webpagetest');32var wpt = new WebPageTest('www.webpagetest.org');33wpt.old_num_testers(function(err, data) {34 console.log(data);35});36var wpt = require('webpagetest');37var wpt = new WebPageTest('www.webpagetest.org');38wpt.old_num_tests_last_week(function(err, data) {39 console.log(data);40});

Full Screen

Using AI Code Generation

copy

Full Screen

1var old_num_locals = wpt.old_num_locals;2var num_locals = wpt.num_locals;3wpt.old_num_locals = function() {4 return old_num_locals() + 1;5}6wpt.num_locals = function() {7 return num_locals() + 1;8}9var old_num_locals = wpt.old_num_locals;10var num_locals = wpt.num_locals;11wpt.old_num_locals = function() {12 return old_num_locals() + 1;13}14wpt.num_locals = function() {15 return num_locals() + 1;16}17var old_num_locals = wpt.old_num_locals;18var num_locals = wpt.num_locals;19wpt.old_num_locals = function() {20 return old_num_locals() + 1;21}22wpt.num_locals = function() {23 return num_locals() + 1;24}25var old_num_locals = wpt.old_num_locals;26var num_locals = wpt.num_locals;27wpt.old_num_locals = function() {28 return old_num_locals() + 1;29}30wpt.num_locals = function() {31 return num_locals() + 1;32}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpthook = require('wpthook');2var myhook = new wpthook.WPThook();3var myhook2 = new wpthook.WPThook();4var myhook3 = new wpthook.WPThook();5console.log(myhook.old_num_locals());6console.log(myhook2.old_num_locals());7console.log(myhook3.old_num_locals());8myhook.old_add_local(1, "test1");9myhook2.old_add_local(2, "test2");10myhook3.old_add_local(3, "test3");11console.log(myhook.old_num_locals());12console.log(myhook2.old_num_locals());13console.log(myhook3.old_num_locals());14var wpthook = require('wpthook');15var myhook = new wpthook.WPThook();16var myhook2 = new wpthook.WPThook();17var myhook3 = new wpthook.WPThook();18console.log(myhook.new_num_locals());19console.log(myhook2.new_num_locals());20console.log(myhook3.new_num_locals());21myhook.new_add_local(1, "test1");22myhook2.new_add_local(2, "test2");23myhook3.new_add_local(3, "test3");24console.log(myhook.new_num_locals());25console.log(myhook2.new_num_locals());26console.log(myhook3.new_num_locals());27The new_add_local() method has a

Full Screen

Using AI Code Generation

copy

Full Screen

1function wptexturize(str) {2 var wptexturize = new Wptexturize();3 return wptexturize.old_num_locals(str);4}5function Wptexturize() {6}7Wptexturize.prototype.old_num_locals = function(str) {8 return str;9}10Wptexturize.prototype.new_num_locals = function(str) {11 return str;12}13function Wptexturize() {14}15Wptexturize.prototype.old_num_locals = function(str) {16 return str;17}18Wptexturize.prototype.new_num_locals = function(str) {19 return str;20}21function Wptexturize() {22}23Wptexturize.prototype.old_num_locals = function(str) {24 return str;25}26Wptexturize.prototype.new_num_locals = function(str) {27 return str;28}29function Wptexturize() {30}31Wptexturize.prototype.old_num_locals = function(str) {32 return str;33}34Wptexturize.prototype.new_num_locals = function(str) {35 return str;36}37function Wptexturize() {38}39Wptexturize.prototype.old_num_locals = function(str) {40 return str;41}42Wptexturize.prototype.new_num_locals = function(str) {43 return str;44}45function Wptexturize() {46}47Wptexturize.prototype.old_num_locals = function(str) {48 return str;49}50Wptexturize.prototype.new_num_locals = function(str) {51 return str;52}53function Wptexturize() {54}55Wptexturize.prototype.old_num_locals = function(str) {56 return str;57}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptb_map = require('wptb_map');2var wptb_map = new wptb_map();3var old_num_locals = wptb_map.old_num_locals();4var new_wptb_map = new wptb_map();5function wptb_map() {6 this.old_num_locals = function() {7 return 10;8 }9}10function wptb_map() {11 this.old_num_locals = function() {12 return 10;13 }14}15var wptb_map = require('wptb_map');16var old_num_locals = wptb_map.old_num_locals();17var new_wptb_map = new wptb_map();18var wptb_map = require('wptb_map');19var old_num_locals = wptb_map.old_num_locals();20var new_wptb_map = new wptb_map();21var wptb_map = require('wptb_map');22var new_wptb_map = new wptb_map();23var old_num_locals = wptb_map.old_num_locals();24var wptb_map = require('wptb_map');25var new_wptb_map = new wptb_map();26var old_num_locals = wptb_map.old_num_locals();27var wptb_map = require('wptb_map');28var new_wptb_map = new wptb_map();29var old_num_locals = new_wptb_map.old_num_locals();30var wptb_map = require('wptb_map');31var new_wptb_map = new wptb_map();32var old_num_locals = new_wptb_map.old_num_locals();33var wptb_map = require('wptb_map');34var new_wptb_map = new wptb_map();35var old_num_locals = new_wptb_map.old_num_locals();36var wptb_map = require('wptb_map');37var new_wptb_map = new wptb_map();38var old_num_locals = new_wptb_map.old_num_locals();39var wptb_map = require('wptb_map');40var new_wptb_map = new wptb_map();

Full Screen

Using AI Code Generation

copy

Full Screen

1var old_num_locals = function (text, prev) {2 var num = 0;3 if (prev) {4 num = prev;5 }6 if (text.match(/'/g)) {7 num += text.match(/'/g).length;8 }9 if (text.match(/’/g)) {10 num += text.match(/’/g).length;11 }12 if (text.match(/‘/g)) {13 num += text.match(/‘/g).length;14 }15 return num;16}17var text = "The ‘quick’ brown fox jumped over the lazy dog. It’s a dog eat dog world.";18console.log(old_num_locals(text, 0));19var text = "The ‘quick’ brown fox jumped over the lazy dog. It’s a dog eat dog world.";20console.log(old_num_locals(text));21var text = "The ‘quick’ brown fox jumped over the lazy dog. It’s a dog eat dog world.";22console.log(old_num_locals(text, 5));23var text = "The ‘quick’ brown fox jumped over the lazy dog. It’s a dog eat dog world.";24console.log(old_num_locals(text, 10));25var text = "The ‘quick’ brown fox jumped over the lazy dog. It’s a dog eat dog world.";26console.log(old_num_locals(text, 15));27var text = "The ‘quick’ brown fox jumped over the lazy dog. It’s a dog eat dog world.";28console.log(old_num_locals(text, 20));29var text = "The ‘quick’ brown fox jumped over the lazy dog. It’s a dog eat dog world.";30console.log(old_num_locals(text, 25));31var text = "The ‘quick’ brown fox jumped over the lazy dog. It’s a dog eat dog world.";32console.log(old_num_locals(text, 30));33var text = "The ‘quick’ brown fox jumped over the lazy dog. It’s a dog eat dog world.";34console.log(old_num_locals(text, 35));35var text = "The ‘quick’ brown fox jumped over the lazy dog. It’s a dog eat dog world.";36console.log(old_num_locals(text, 40));37var text = "The ‘quick’ brown fox jumped over the lazy dog. It’s a dog eat dog world.";38console.log(old_num_locals(text, 45));

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 wpt 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