Best JavaScript code snippet using wpt
conversions.js
Source:conversions.js
1function recolorImage(){2 //This function is called when user presses "encode"3 // after selecting a file and an image to recolor.4 5 //STEP ONE: Resize the image6 cig = chosen_image_graphic7 var chunk_count = ceil(chosen_file_hex.length/3)8 9 //this formula can be proven with algebra; width in chunks / height in chunks needs to approximate cig.w/cig.h, and width in chunks * height in chunks should be at least chunk_count10 //since chunks will be square-shaped, chunk_width will be the same as the chunk_height11 chunk_width = ceil(sqrt( (cig.width * cig.height) / chunk_count ))12 if(chunk_width < 5)chunk_width = 5; //minimum of five makes it easier to read the colors13 if(chunk_width > 189)chunk_width = 189;14 //maximum chunk size is 189 pixels because of step 2b (see below)15 16 height_in_chunks = ceil( sqrt(chunk_count/(cig.width/cig.height)) )17 width_in_chunks = ceil( height_in_chunks * (cig.width/cig.height) )18 19 var new_width = width_in_chunks * chunk_width20 var new_height = height_in_chunks * chunk_width21 var new_cig = createGraphics(new_width, new_height)22 chosen_image_graphic = new_cig;23 cig = chosen_image_graphic24 cig.noSmooth();25 cig.image(chosen_image, 0, 0, new_width, new_height)26 27 //console.log({chunk_width, width_in_chunks, height_in_chunks, new_width, new_height})28 29 //STEP TWO: Write metadata to the first five pixels of the image30 //Step 2a: The first two pixels are validity checkers to confirm that31 // this image has been encoded by this program.32 // The RGB values of the first two pixels fit this pattern when taken mod 64:33 // 10 1 13 9 11 534 //(10 1 13 is "A113", the Pixar number, and 9 11 5 = the numerical positions of I, K, and E in the alphabet 35 cig.loadPixels();36 pxs = cig.pixels37 pxs[0] = closestMultiple(pxs[0], 64) + 1038 pxs[1] = closestMultiple(pxs[1], 64) + 139 pxs[2] = closestMultiple(pxs[2], 64) + 1340 pxs[4] = closestMultiple(pxs[4], 64) + 941 pxs[5] = closestMultiple(pxs[5], 64) + 1142 pxs[6] = closestMultiple(pxs[6], 64) + 543 //Step 2b: the R value of the next pixel encodes the size of the chunks in pixels when taken mod 64.44 //If the chunk size is larger than 63 pixels, add on the values of the G and B values mod 64,45 //for a maximum chunk size of 63*3 = 189 pixels.46 if(chunk_width.between(0, 63)){47 pxs[8] = closestMultiple(pxs[8], 64) + chunk_width48 pxs[9] = closestMultiple(pxs[9], 64) + 049 pxs[10] = closestMultiple(pxs[10], 64) + 050 }51 if(chunk_width.between(64, 126)){52 pxs[8] = closestMultiple(pxs[8], 64) + 6353 pxs[9] = closestMultiple(pxs[9], 64) + (chunk_width-63)54 pxs[10] = closestMultiple(pxs[10], 64) + 055 }56 if(chunk_width.between(127, 189)){57 pxs[8] = closestMultiple(pxs[8], 64) + 6358 pxs[9] = closestMultiple(pxs[9], 64) + 6359 pxs[10] = closestMultiple(pxs[10], 64) + (chunk_width-126)60 }61 //Step 2c: encode the file extension62 //Have each of the following characters correspond to a number (which will be its index in this array):63 var extensionChars = "?0123456789abcdefghijklmnopqrstuvwxyz_".split('')64 //If a file extension has characters other than these, or if a file extension has65 // more than six characters, we cannot encode the file and the user will be told.66 //The RGB values of the fourth and fifth pixels will store the characters of the file extension67 //If a file extension has fewer than 6 characters (likely),68 // the remaining spaces will hold a "?" character,69 // telling the program to ignore it. This means the file extension also70 // cannot have a question mark in it.71 var extensionNumbers = []72 for(var i = 0; i < 6; i ++){73 if(chosen_file_extension[i])74 extensionNumbers.push(extensionChars.indexOf(chosen_file_extension[i]));75 else76 extensionNumbers.push(0); //0 is the index of the question mark character in the extensionChars array77 }78 //This time we will do mod 38 since there are 38 characters in the extensionChars list79 pxs[12] = closestMultiple(pxs[12], 38) + extensionNumbers[0]80 pxs[13] = closestMultiple(pxs[13], 38) + extensionNumbers[1]81 pxs[14] = closestMultiple(pxs[14], 38) + extensionNumbers[2]82 pxs[16] = closestMultiple(pxs[16], 38) + extensionNumbers[3]83 pxs[17] = closestMultiple(pxs[17], 38) + extensionNumbers[4]84 pxs[18] = closestMultiple(pxs[18], 38) + extensionNumbers[5]8586 //STEP THREE: Encode every chunk with its corresponding hex (base-16) digit in the chosen_file_hex string87 //The R, G, and B values of each chunk correspond to the88 //next three hex digits in the string, where the color value % 17 = a number corresponding to a hex digit.89 //If the color value % 17 = 16, then that tells us that that color value stores no data (i.e. we have extra chunks)90 //and the decoder will ignore these color values.91 //In fact, 16 in base 17 is represented with a "g", and there's no "g" in base 16 so that's a clear sign that this chunk is not part of our data92 93 var random_chunk_values_1 = []94 for(var i = 0; i < chunk_count; i++)random_chunk_values_1.push(random(1));95 var random_chunk_values_2 = []96 for(var i = 0; i < chunk_count; i++)random_chunk_values_2.push(random(1));97 98 for(var i = 0; i < pxs.length; i += 4){99 if(i > 18){ //skip the first 5 pixels since they encode metadata and we don't want to change them100 var chunk = pxIndexToChunk(i)101 //Get the next 3 hexadecimal digits to encode102 var r_encode_val = chosen_file_hex[ (chunk.i*3) ]103 var g_encode_val = chosen_file_hex[ (chunk.i*3)+1 ]104 var b_encode_val = chosen_file_hex[ (chunk.i*3)+2 ]105 106 //Convert those hexadecimal digits to base 10 numbers, and if107 //We have run out of digits, set the base 10 number to 16 (or in other words a "g" in base 17)108 if(r_encode_val===undefined)r_encode_val = 16;109 else r_encode_val = parseInt(r_encode_val,16)110 if(g_encode_val===undefined)g_encode_val = 16;111 else g_encode_val = parseInt(g_encode_val,16)112 if(b_encode_val===undefined)b_encode_val = 16;113 else b_encode_val = parseInt(b_encode_val,16)114 115 //At this point, we could just do this to encode the data:116 // pxs[i] = closestMultiple(pxs[i], 17) + r_encode_val117 // pxs[i+1] = closestMultiple(pxs[i+1], 17) + g_encode_val118 // pxs[i+2] = closestMultiple(pxs[i+2], 17) + b_encode_val119 // However, the squares aren't super visible this way, so for clarity, we will120 // make them more visible by randomly adding/subtracting the r g and b values121 // but making sure they still encode the correct hex digit.122 // One way to do this that looks visually appealing123 // is to utilize the color of the pixel in the top right corner of this chunk.124 //(doesn't really make a difference when the chunks are small but when they're big it looks cool)125 //Using the corner is causing some sort of glitch where the corner pixel126 //of every chunk is noticably different from the rest of the chunk,127 //so I will not use the corner and instead we'll just say the "corner" is the pixel itself128 129 var cornerx = chunk.x * chunk_width130 var cornery = chunk.y * chunk_width131 var corneri = pxXYToIndex({'x':cornerx, 'y':cornery})132 // var corner_r = pxs[corneri]133 // var corner_g = pxs[corneri+1]134 // var corner_b = pxs[corneri+2]135 var corner_r = pxs[i]136 var corner_g = pxs[i+1]137 var corner_b = pxs[i+2]138 139 var pxx = pxIndexToXY(i).x;140 var pxy = pxIndexToXY(i).y;141 142 143 var random_value_1 = random_chunk_values_1[chunk.i]144 var random_value_2 = random_chunk_values_2[chunk.i]145 146 147 var large_value = 17*3;148 149 //50% chance of increasing the new R and B values, and 50% chance of decreasing them150 if(random_value_1 < (3/4)){151 new_r = closestMultiple(corner_r, large_value)152 if(new_r + large_value + r_encode_val <= 255 )new_r += large_value;153 new_b = closestMultiple(corner_b, large_value)154 if(new_b + large_value + b_encode_val <= 255 )new_b += large_value;155 } else {156 new_r = closestMultiple(corner_r, large_value)157 if(new_r - large_value >= 0 )new_r -= large_value;158 new_b = closestMultiple(corner_b, large_value)159 if(new_b - large_value >= 0 )new_b -= large_value;160 }161 162 // A certain chance of only using the new B value,163 // A certain chance of only using the new R and B values,164 // and a certain chance of not changing anything165 var probability_b_only = 10/20166 var probability_r_and_b_only = 5/20167 168 pxs[i] = closestMultiple(pxs[i], 17) + r_encode_val169 pxs[i+1] = closestMultiple(pxs[i+1], 17) + g_encode_val170 pxs[i+2] = closestMultiple(pxs[i+2], 17) + b_encode_val171 if(random_value_2 < probability_b_only ){172 pxs[i+2] = new_b + b_encode_val173 } else if (random_value_2 < probability_b_only + probability_r_and_b_only ) {174 pxs[i] = new_r + r_encode_val;175 pxs[i+2] = new_b + b_encode_val;176 }177 178 }179 }180 181 cig.updatePixels();182 183 184 loading_screen = false;185 current_screen = "create4"186}187188function decodeImage(){189 cig = chosen_image_graphic190 cig.loadPixels();191 pxs = cig.pixels;192 //STEP ONE: Make sure the image is a valid image that has been encoded by this program193 //(Only one in 68 billion chance of false positive)194 var image_valid = 195 pxs[0] % 64 == 10 &&196 pxs[1] % 64 == 1 &&197 pxs[2] % 64 == 13 &&198 pxs[4] % 64 == 9 &&199 pxs[5] % 64 == 11 &&200 pxs[6] % 64 == 5201 if(!image_valid){202 alert("The image you've chosen is not encoded with any data. Make sure your image has not been resized, cropped, or 'screenshotted'.")203 loading_screen = false;204 image_file_selected = false;205 } else {206 //STEP TWO: Read metadata (get chunk size and file extension)207 chunk_width = pxs[8] % 64 + pxs[9] % 64 + pxs[10] % 64208 decoded_file_extension = ""209 var extensionChars = "?0123456789abcdefghijklmnopqrstuvwxyz_".split('')210 decoded_file_extension += extensionChars[pxs[12] % 38]211 decoded_file_extension += extensionChars[pxs[13] % 38]212 decoded_file_extension += extensionChars[pxs[14] % 38]213 decoded_file_extension += extensionChars[pxs[16] % 38]214 decoded_file_extension += extensionChars[pxs[17] % 38]215 decoded_file_extension += extensionChars[pxs[18] % 38]216 var ndfe = ''217 for(var i = 0; i < decoded_file_extension.length; i ++){218 if(decoded_file_extension[i] !== "?")ndfe += decoded_file_extension[i]219 }220 decoded_file_extension = ndfe;221 222 decoded_file_hex = ""223 //STEP THREE: Get hex data from each chunk and write it to the decoded_file_hex variable224 width_in_chunks = round(cig.width/chunk_width) //We shouldn't have to round if the image has been encoded correctly but this is a falesafe225 height_in_chunks = round(cig.height/chunk_width)226 chunk_count = width_in_chunks * height_in_chunks227 for(var chunki = 0; chunki < chunk_count; chunki ++){228 var chunk = chunkIndexToXY(chunki)229 var samplepx = {230 'x':(chunk.x*chunk_width) + floor(chunk_width/2),231 'y':(chunk.y*chunk_width) + floor(chunk_width/2)232 }233 samplepx.i = pxXYToIndex(samplepx)234 samplepx.r = pxs[samplepx.i]235 samplepx.g = pxs[samplepx.i+1]236 samplepx.b = pxs[samplepx.i+2]237 var r_decoded_val = (samplepx.r%17)238 var g_decoded_val = (samplepx.g%17)239 var b_decoded_val = (samplepx.b%17)240 r_decoded_val = r_decoded_val.toString(17)241 g_decoded_val = g_decoded_val.toString(17)242 b_decoded_val = b_decoded_val.toString(17)243 if(r_decoded_val !== 'g')decoded_file_hex += r_decoded_val;244 if(g_decoded_val !== 'g')decoded_file_hex += g_decoded_val;245 if(b_decoded_val !== 'g')decoded_file_hex += b_decoded_val;246 }247 loading_screen = false;248 // hexToFile(decoded_file_hex, "myDecodedFile." + decoded_file_extension)249 }250}251252function listHex(arr){253 //This function is for debugging purposes254 var ret = ''255 for(var i = 0; i < arr.length; i ++){256 var val = arr[i] % 17257 val = val.toString(17)258 ret += val;259 }260 console.log(ret.toUpperCase())261 console.log( chosen_file_hex.substr(0, arr.length) + " <- True hex" )262}263264function closestMultiple(number, multiple, maximum){265 //Given a number, and a number "multiple" to take the closest multiple of,266 // return what is the multiple of "multiple" that's closest to "number"267 // The returned value cannot exceed the given maximum when added by multiple268 // If no maximum is given, assume 255269 if(!maximum)maximum = 255;270 var ret = round(number/multiple) * multiple271 while(ret+multiple > maximum)ret -= multiple;272 return ret;273}274275function pxIndexToChunk(pxi){276 var px = pxIndexToXY(pxi);277 var x = floor(px.x/chunk_width)278 var y = floor(px.y/chunk_width)279 var i = chunkXYToIndex({x,y})280 return {x,y,i}281}282function pxIndexToXY(pxi){283 var npxi = pxi/4284 var x = npxi%chosen_image_graphic.width285 var y = floor(npxi/chosen_image_graphic.width)286 return {x, y}287}288function pxXYToIndex(pxxy){289 var x = pxxy.x290 var y = pxxy.y291 return ( (y * chosen_image_graphic.width) + x ) * 4292}293function chunkXYToIndex(chunkxy){294 var chunkx = chunkxy.x295 var chunky = chunkxy.y296 return (chunky * width_in_chunks) + (chunkx % width_in_chunks)297}298function chunkIndexToXY(chunki){299 var chunkx = (chunki%width_in_chunks)300 var chunky = floor(chunki/width_in_chunks)301 return {'x':chunkx, 'y':chunky, 'i': chunki}302}303304function createFileReader(){305 myReader = new FileReader();306 myReader.onload = () => {307 chosen_file_64 = (myReader.result.substr(myReader.result.indexOf(',') + 1) )308 chosen_file_hex = base64ToHex(chosen_file_64)309 }310 myReader.onerror = () => {console.log('Error: ' + error)}311}312function fileTo64(){313 // Referring to the file uploaded via fileInput,314 // store the base64 data of that file in the variable chosen_file_64315 // and same for hex data of the file316 // myReader.readAsDataURL(fileInput.elt.files[0])317 myReader.readAsDataURL(chosen_file.file)318}319function base64ToHex(str) {320 //Given a string of base64 data, convert the data to hex values321 const raw = atob(str);322 let result = '';323 for (let i = 0; i < raw.length; i++) {324 const hex = raw.charCodeAt(i).toString(16);325 result += (hex.length === 2 ? hex : '0' + hex);326 }327 return result.toUpperCase();328}329function saveText(textString, fileName){330 if(!fileName)fileName = "myText.txt"331 var writer = createWriter(fileName);332 writer.print(textString)333 writer.close();334}335336function hexToFile(hexString, filename) {337 //Given a string of hex values, create and download a file containing that hex data338 var cleaned_hex = clean_hex(hexString, true);339 if (cleaned_hex.length % 2) {340 cleaned_hex += "0"341 //alert ("Error: cleaned hex string length is odd.");342 //return;343 }344 var binary = new Array();345 for (var i=0; i<cleaned_hex.length/2; i++) {346 var h = cleaned_hex.substr(i*2, 2);347 binary[i] = parseInt(h,16);348 }349 var byteArray = new Uint8Array(binary);350 var a = document.createElement('a');351 a.href = window.URL.createObjectURL(new Blob([byteArray], { type: 'application/octet-stream' }));352 a.download = filename;353 // Append anchor to body.354 document.body.appendChild(a)355 a.click();356 // Remove anchor from body357 document.body.removeChild(a)358}359function clean_hex(input, remove_0x) {360 input = input.toUpperCase();361 if (remove_0x) {362 input = input.replace(/0x/gi, "");363 }364 var orig_input = input;365 input = input.replace(/[^A-Fa-f0-9]/g, "");366 //if (orig_input != input)367 // alert ("Warning! Non-hex characters (including newlines) in input string ignored.");368 return input;369}370function hex2bin(hex){371 return ("00000000" + (parseInt(hex, 16)).toString(2)).substr(-8);372}373function hexToBase64(hexstring) {374 return btoa(hexstring.match(/\w{2}/g).map(function(a) {375 return String.fromCharCode(parseInt(a, 16));376 }).join(""));377}378379function rewriteHTMLDoc(newTextString){380 document.open();381 document.write(newTextString);382 document.close();
...
Using AI Code Generation
1var wpt = require('wpt');2var options = {3};4wpt.large_value(options, function(err, data) {5 if (err) {6 console.log('Error: ' + err);7 }8 else {9 console.log(data);10 }11});12var wpt = require('wpt');13var options = {14};15wpt.test_info(options, function(err, data) {16 if (err) {17 console.log('Error: ' + err);18 }19 else {20 console.log(data);21 }22});23var wpt = require('wpt');24var options = {25};26wpt.test_status(options, function(err, data) {27 if (err) {28 console.log('Error: ' + err);29 }30 else {31 console.log(data);32 }33});34var wpt = require('wpt');35var options = {36};37wpt.test_results(options, function(err, data) {38 if (err) {39 console.log('Error: ' + err);40 }41 else {42 console.log(data);43 }44});45var wpt = require('wpt');46wpt.get_locations(function(err, data) {47 if (err) {48 console.log('Error: ' + err);49 }50 else {51 console.log(data);52 }53});54var wpt = require('wpt');55wpt.get_connectivity(function(err, data) {56 if (err) {57 console.log('Error: ' + err);58 }59 else {60 console.log(data);61 }62});
Using AI Code Generation
1var wpt = require('wpt');2wpt.large_value(1000000, function(err, result) {3 if (err) {4 console.log("Error: " + err);5 } else {6 console.log(result);7 }8});9var wpt = require('wpt');10wpt.large_value(1000000, function(err, result) {11 if (err) {12 console.log("Error: " + err);13 } else {14 console.log(result);15 }16});17var wpt = require('wpt');18wpt.large_value(1000000, function(err, result) {19 if (err) {20 console.log("Error: " + err);21 } else {22 console.log(result);23 }24});25var wpt = require('wpt');26wpt.large_value(1000000, function(err, result) {27 if (err) {28 console.log("Error: " + err);29 } else {30 console.log(result);31 }32});33var wpt = require('wpt');34wpt.large_value(1000000, function(err, result) {35 if (err) {36 console.log("Error: " + err);37 } else {38 console.log(result);39 }40});41var wpt = require('wpt');42wpt.large_value(1000000, function(err, result) {43 if (err) {44 console.log("Error: " + err);45 } else {46 console.log(result);47 }48});49var wpt = require('wpt');50wpt.large_value(1000000, function(err, result) {51 if (err) {52 console.log("Error: " + err);53 } else {54 console.log(result);55 }56});57var wpt = require('w
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getLocations(function(err, data) {4 console.log(data);5});6wpt.getTesters(function(err, data) {7 console.log(data);8});9wpt.getTestStatus('150329_4A_1AC', function(err, data) {10 console.log(data);11});12wpt.getTestResults('150329_4A_1AC', function(err, data) {13 console.log(data);14});15wpt.runTest('www.webpagetest.org', function(err, data) {16 console.log(data);17});18wpt.runTest('www.webpagetest.org', { location: 'Dulles_MotoG4:Chrome', runs: 3, firstViewOnly: true, pollResults: 5 }, function(err, data) {19 console.log(data);20});21wpt.runTest('www.webpagetest.org', { location: 'Dulles_MotoG4:Chrome', runs: 3, firstViewOnly: true, pollResults: 5, timeout: 60 }, function(err, data) {22 console.log(data);23});24wpt.runTest('www.webpagetest.org', { location: 'Dulles_MotoG4:Chrome', runs: 3, firstViewOnly: true, pollResults: 5, timeout: 60, connectivity: '3G' }, function(err, data) {25 console.log(data);26});27wpt.runTest('www.webpagetest.org', { location: 'Dulles_MotoG4:Chrome', runs: 3, firstViewOnly: true, pollResults: 5, timeout: 60, connectivity: '3G', mobile: 1 }, function(err, data) {28 console.log(data);29});30wpt.runTest('www.webpagetest.org', { location: 'Dulles_MotoG4:Chrome', runs: 3, firstViewOnly: true, pollResults: 5, timeout: 60, connectivity: '3G', mobile: 1, video: 1 }, function(err, data) {31 console.log(data);32});33wpt.runTest('www.webpagetest.org', { location: 'Dulles_MotoG4:Chrome', runs: 3, firstViewOnly: true, pollResults:
Using AI Code Generation
1var wpt = require('wpt');2wpt.large_value(function(err, data){3 if(err){4 console.log(err);5 }6 else{7 console.log(data);8 }9});10var wpt = require('wpt');11wpt.small_value(function(err, data){12 if(err){13 console.log(err);14 }15 else{16 console.log(data);17 }18});19var wpt = require('wpt');20wpt.get_value(function(err, data){21 if(err){22 console.log(err);23 }24 else{25 console.log(data);26 }27});28var wpt = require('wpt');29wpt.set_value(function(err, data){30 if(err){31 console.log(err);32 }33 else{34 console.log(data);35 }36});37var wpt = require('wpt');38wpt.set_value(function(err, data){39 if(err){40 console.log(err);41 }42 else{43 console.log(data);44 }45});46var wpt = require('wpt');47wpt.get_value(function(err, data){48 if(err){49 console.log(err);50 }51 else{52 console.log(data);53 }54});55var wpt = require('wpt');56wpt.get_value(function(err, data){57 if(err){58 console.log(err);59 }60 else{61 console.log(data);62 }63});64var wpt = require('wpt');65wpt.set_value(function(err, data){66 if(err){67 console.log(err);68 }69 else{70 console.log(data);71 }72});73var wpt = require('wpt');74wpt.get_value(function(err, data){75 if(err){76 console.log(err);77 }78 else{79 console.log(data);80 }81});82var wpt = require('wpt');83wpt.set_value(function(err, data){84 if(err){85 console.log(err);86 }
Using AI Code Generation
1var wpt = require('./wpt.js');2wpt.large_value(1000000000, function (err, value) {3 if (err) {4 console.log(err);5 } else {6 console.log(value);7 }8});9var wpt = require('./wpt.js');10wpt.large_value(1000000000, function (err, value) {11 if (err) {12 console.log(err);13 } else {14 console.log(value);15 }16});17var wpt = require('./wpt.js');18wpt.large_value(1000000000, function (err, value) {19 if (err) {20 console.log(err);21 } else {22 console.log(value);23 }24});25var wpt = require('./wpt.js');26wpt.large_value(1000000000, function (err, value) {27 if (err) {28 console.log(err);29 } else {30 console.log(value);31 }32});33var wpt = require('./wpt.js');34wpt.large_value(1000000000, function (err, value) {35 if (err) {36 console.log(err);37 } else {38 console.log(value);39 }40});41var wpt = require('./wpt.js');42wpt.large_value(1000000000, function (err, value) {43 if (err) {44 console.log(err);45 } else {46 console.log(value);47 }48});49var wpt = require('./wpt.js');50wpt.large_value(1000000000, function (err, value) {
Using AI Code Generation
1var wpt = require('wpt');2wpt.large_value(100000, function (err, result) {3 if (err) {4 console.log('Error: ' + err);5 } else {6 console.log('Result: ' + result);7 }8});
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org', 'A.c2c4e5d5b6f9b7a9e6c4d8e4c4a4f4e4');3wpt.getLocations(function(err, data) {4 if (err) {5 console.log('Error: ' + err);6 } else {7 console.log(data);8 }9});10var wpt = require('wpt');11var wpt = new WebPageTest('www.webpagetest.org', 'A.c2c4e5d5b6f9b7a9e6c4d8e4c4a4f4e4');12wpt.getLocations(function(err, data) {13 if (err) {14 console.log('Error: ' + err);15 } else {16 console.log(data);17 }18});19var wpt = require('wpt');20var wpt = new WebPageTest('www.webpagetest.org', 'A.c2c4e5d5b6f9b7a9e6c4d8e4c4a4f4e4');21wpt.getLocations(function(err, data) {22 if (err) {23 console.log('Error: ' + err);24 } else {25 console.log(data);26 }27});28var wpt = require('wpt');29var wpt = new WebPageTest('www.webpagetest.org', 'A.c2c4e5d5b6f9b7a9e6c4d8e4c4a4f4e4');30wpt.getLocations(function(err, data) {31 if (err) {32 console.log('Error: ' + err);33 } else {34 console.log(data);35 }36});37var wpt = require('wpt');38var wpt = new WebPageTest('www.webpagetest.org', 'A.c2c4e5d5b6f
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!!