Best JavaScript code snippet using wpt
timeChoose.js
Source:timeChoose.js
1var $ = require('jquery');2var _ = require('lodash');3var utils = require('public/util.js');4var laydate = require('laydate');5var endDate = null;6module.exports = {7 holidayClass: '.holiday',8 init: function () {9 this.bingTagInit();10 },11 bingTagInit: function () {12 var self = this;13 var start, end, currentTime, endMin, endMax;14 var startObj = '#choose_start_time';15 var endObj = '#choose_end_time';16 var lastDate = $(startObj).data('last') || '';17 var maxAfter = parseInt($(endObj).data('max'), 10);18 var minAfter = parseInt($(endObj).data('min'), 10);19 var format = 'YYYY-MM-DD';20 $(startObj).focus(function () {21 start = {22 elem: startObj,23 min: utils.formatDate(new Date(), format),24 show: true,25 showBottom: false,26 done: function (datas) {27 if (datas) {28 currentTime = datas;29 if (minAfter > 0) {30 endMin = self.addNDays(currentTime, minAfter, format);31 } else {32 endMin = currentTime;33 }34 endMax = self.addNDays(currentTime, maxAfter - 1, format);35 $(endObj).val('').removeAttr('disabled');36 self.changeEndDate(endMin, endMax);37 }38 }39 };40 if (lastDate) start.max = lastDate;41 laydate.render(start);42 });43 $(endObj).focus(function () {44 if (!start || !currentTime || !endMin || !endMax) return false;45 end = {elem: endObj};46 if (endDate === null) {47 end.min = endMin;48 end.max = endMax;49 end.show = true;50 end.showBottom = false;51 endDate = laydate.render(end);52 } else {53 laydate.render(end);54 }55 });56 },57 changeEndDate: function (endMin, endMax) {58 console.log(endMin);59 console.log(endMax);60 if (endDate !== null) {61 var minDate = new Date(Date.parse(endMin.replace(/-/g, '/')));62 var maxDate = new Date(Date.parse(endMax.replace(/-/g, '/')));63 endDate.config.min = {64 year: minDate.getFullYear(),65 month: minDate.getMonth(),66 date: minDate.getDate()67 };68 endDate.config.max = {69 year: maxDate.getFullYear(),70 month: maxDate.getMonth(),71 date: maxDate.getDate()72 };73 }74 },75 addNDays: function (date, n, format) {76 var d = new Date(Date.parse(date.replace(/-/g, '/')));77 var time = d.getTime();78 var newTime = time + n * 24 * 60 * 60 * 1000;79 return utils.formatDate(new Date(newTime), format);80 }...
sol-1.js
Source:sol-1.js
1/**2 * @param {number[]} nums3 * @return {number}4 */5var maxSubArray = function (nums) {6 // let maxSum = findMaxValue(nums);7 let maxSum = Math.max(...nums); // !O(n)8 console.log('Initial Max no : ', maxSum);9 let tracerSum = nums[0];10 let i = 0;11 // !O(n^2)- Quadratic T.C12 for (let trace = i + 1; i < nums.length; trace++) {13 // !O(n)14 console.log('i -> ', i, 't ->', trace);15 tracerSum += nums[trace];16 if (tracerSum > maxSum) {17 console.log('** tracerSum ', tracerSum);18 maxSum = tracerSum;19 }20 if (trace >= nums.length - 1) {21 i++; // !O(n)22 trace = i;23 tracerSum = nums[i];24 console.log('new i value', i, trace, ':: maxSum', maxSum);25 }26 }27 return maxSum;28};29/* function findMaxValue(nums) {30 let maxVal = nums[0];31 nums.forEach(ele => {32 if (ele > maxVal) {33 maxVal = ele;34 }35 });36 return maxVal;37 } */38console.log(maxSubArray([-2, 1, -3, 4, -1, 2, 1, -5, 4]));39// console.log(maxSubArray([-1]));40// console.log(maxSubArray([1]));41// console.log(maxSubArray([-2, 1]));42// console.log(maxSubArray([-1, 1, 2, 1]));43// console.log(findMaxValue([-2, 1]));44console.log('--------------');45function maxSubArray2(nums) {46 let max = Math.min(...nums);47 // console.log(max);48 // let max = -9999999999999999;49 let endMax = 0;50 for (let i = 0; i < nums.length; i++) {51 endMax += nums[i];52 if (max < endMax) max = endMax;53 if (endMax < 0) endMax = 0;54 }55 return max;56}...
maxSubArray.js
Source:maxSubArray.js
1const maxSubArray = nums => {2 let currentMax = nums[0];3 let endMax = 0;4 for(const num of nums){5 endMax += num;6 currentMax = Math.max(currentMax, endMax);7 if(endMax < 0) endMax = 0;8 }9 return currentMax;...
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.endMax(function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var wpt = require('wpt');11var wpt = new WebPageTest('www.webpagetest.org');12wpt.getLocations(function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19var wpt = require('wpt');20var wpt = new WebPageTest('www.webpagetest.org');21wpt.getTesters(function(err, data) {22 if (err) {23 console.log(err);24 } else {25 console.log(data);26 }27});28var wpt = require('wpt');29var wpt = new WebPageTest('www.webpagetest.org');30wpt.getTesters(function(err, data) {31 if (err) {32 console.log(err);33 } else {34 console.log(data);35 }36});37var wpt = require('wpt');38var wpt = new WebPageTest('www.webpagetest.org');39wpt.getTesters(function(err, data) {40 if (err) {41 console.log(err);42 } else {43 console.log(data);44 }45});46var wpt = require('wpt');47var wpt = new WebPageTest('www.webpagetest.org');48wpt.getTesters(function(err, data) {49 if (err) {50 console.log(err);51 } else {52 console.log(data);53 }54});55var wpt = require('wpt');56var wpt = new WebPageTest('www.webpagetest.org');57wpt.getTesters(function(err, data) {58 if (
Using AI Code Generation
1var wpt = require('wpt');2wpt.endMax('testId', function(error, data) {3 if (error) {4 console.log(error);5 } else {6 console.log(data);7 }8});9{ statusCode: 200,10 { statusCode: 200,11 { statusCode: 200,12 data: { testId: 'testId', data: { runs: 1, fvonly: 0, fvruns: 0 } } } } }13var wpt = require('wpt');14wpt.endMax('testId', function(error, data) {15 if (error) {16 console.log(error);17 } else {18 console.log(data.data.data.data);19 }20});21{ testId: 'testId',22 { runs: 1,23 { firstView:24 { loadTime: 1994,
Using AI Code Generation
1wpt.endMax(1);2wpt.endMax(1);3wpt.endMax(2);4wpt.endMax(1);5wpt.endMax(2);6wpt.endMax(3);7wpt.endMax(1);8wpt.endMax(2);9wpt.endMax(3);10wpt.endMax(4);11wpt.endMax(1);12wpt.endMax(2);13wpt.endMax(3);14wpt.endMax(4);15wpt.endMax(5);16wpt.endMax(1);17wpt.endMax(2);18wpt.endMax(3);19wpt.endMax(4);20wpt.endMax(5);21wpt.endMax(6);22wpt.endMax(1);23wpt.endMax(2);24wpt.endMax(3);25wpt.endMax(4);26wpt.endMax(5);27wpt.endMax(6);28wpt.endMax(7);29wpt.endMax(1);30wpt.endMax(2);31wpt.endMax(3);32wpt.endMax(4);33wpt.endMax(5);34wpt.endMax(6);35wpt.endMax(7);36wpt.endMax(8);37wpt.endMax(1);38wpt.endMax(2);39wpt.endMax(3);40wpt.endMax(4);41wpt.endMax(5);42wpt.endMax(6);43wpt.endMax(7);44wpt.endMax(8);45wpt.endMax(9);46wpt.endMax(1);47wpt.endMax(2);48wpt.endMax(3);
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new wpt();3wpt.endMax('test',function(err,data){4 if(err) throw err;5 console.log(data);6});7var wpt = require('wpt');8var wpt = new wpt();9wpt.endMax('test',function(err,data){10 if(err) throw err;11 console.log(data);12});13var wpt = require('wpt');14var wpt = new wpt();15wpt.endMax('test',function(err,data){16 if(err) throw err;17 console.log(data);18});19var wpt = require('wpt');20var wpt = new wpt();21wpt.endMax('test',function(err,data){22 if(err) throw err;23 console.log(data);24});25var wpt = require('wpt');26var wpt = new wpt();27wpt.endMax('test',function(err,data){28 if(err) throw err;29 console.log(data);30});31var wpt = require('wpt');32var wpt = new wpt();33wpt.endMax('test',function(err,data){34 if(err) throw err;35 console.log(data);36});37var wpt = require('wpt');38var wpt = new wpt();39wpt.endMax('test',function(err,data){40 if(err) throw err;41 console.log(data);42});43var wpt = require('wpt');44var wpt = new wpt();45wpt.endMax('test',function(err,data){46 if(err) throw err;47 console.log(data);48});49var wpt = require('wpt');50var wpt = new wpt();51wpt.endMax('test',function
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!!