Best JavaScript code snippet using wpt
battles.js
Source:battles.js
...9const reports = (banList, thisTeamList, thatTeamList) => {10 let results = HeroBattleTable().data11 .filter(battle => _.isEmpty(banList) || !(isIntersected(banList, battle.w) || isIntersected(banList, battle.l))) // é¦å
æé¤banéçå¼ç¥12 .filter(battle => !_.isEqual(battle.w, battle.l)) // æé¤èè´åæ¹éµå®¹ä¸è´ç13 .filter(battle => _.isEmpty(thisTeamList) || isContained(thisTeamList, battle.w) || isContained(thisTeamList, battle.l)) // åªçèªå·±åºçå¼ç¥14 .filter(battle => _.isEmpty(thatTeamList) || isContained(thatTeamList, battle.w) || isContained(thatTeamList, battle.l)) // åªç对æ¹åºçå¼ç¥15 .map(battle => {16 const reports = {}17 if (18 isContained(thisTeamList, battle.w) &&19 isContained(thatTeamList, battle.l) &&20 (21 isContained(thisTeamList, thatTeamList) ||22 !isContained(thisTeamList, battle.l)23 )24 ) {25 const key = [battle.w.sort(), battle.l.sort()].flat().join('_')26 reports[key] = { // 计ç®èåº27 key,28 thisTeam: beautifyOutput(battle.w, thisTeamList),29 thatTeam: beautifyOutput(battle.l, thatTeamList),30 s: 1,31 w: 1,32 l: 0,33 }34 }35 if (36 isContained(thisTeamList, battle.l) &&37 isContained(thatTeamList, battle.w) &&38 (39 isContained(thisTeamList, thatTeamList) ||40 !isContained(thisTeamList, battle.w)41 )42 ) {43 const key = [battle.l.sort(), battle.w.sort()].flat().join('_')44 reports[key] = { // 计ç®è´åº45 key,46 thisTeam: beautifyOutput(battle.l, thisTeamList),47 thatTeam: beautifyOutput(battle.w, thatTeamList),48 s: 1,49 w: 0,50 l: 1,51 }52 }53 return reports54 });...
MeshBVHDebug.js
Source:MeshBVHDebug.js
1import { Box3, Vector3 } from 'three';2import { arrayToBox } from './Utils/ArrayBoxUtilities.js';3const box1 = new Box3();4const box2 = new Box3();5const vec = new Vector3();6export class MeshBVHDebug {7 constructor( bvh, geometry ) {8 this.bvh = bvh;9 this.geometry = geometry;10 }11 validateBounds() {12 const { bvh, geometry } = this;13 const depthStack = [];14 const index = geometry.index;15 const position = geometry.getAttribute( 'position' );16 let passes = true;17 bvh.traverse( ( depth, isLeaf, boundingData, offset, count ) => {18 const info = {19 depth,20 isLeaf,21 boundingData,22 offset,23 count,24 };25 depthStack[ depth ] = info;26 arrayToBox( boundingData, box1 );27 const parent = depthStack[ depth - 1 ];28 if ( isLeaf ) {29 // check triangles30 for ( let i = offset * 3, l = ( offset + count ) * 3; i < l; i += 3 ) {31 const i0 = index.getX( i );32 const i1 = index.getX( i + 1 );33 const i2 = index.getX( i + 2 );34 let isContained;35 vec.fromBufferAttribute( position, i0 );36 isContained = box1.containsPoint( vec );37 vec.fromBufferAttribute( position, i1 );38 isContained = isContained && box1.containsPoint( vec );39 vec.fromBufferAttribute( position, i2 );40 isContained = isContained && box1.containsPoint( vec );41 console.assert( isContained, 'Leaf bounds does not fully contain triangle.' );42 passes = passes && isContained;43 }44 }45 if ( parent ) {46 // check if my bounds fit in my parents47 arrayToBox( boundingData, box2 );48 const isContained = box2.containsBox( box1 );49 console.assert( isContained, 'Parent bounds does not fully contain child.' );50 passes = passes && isContained;51 }52 } );53 return passes;54 }...
lib.spec.ts
Source:lib.spec.ts
...21 const foo = computeAlphabet('foo');22 const food = computeAlphabet('food');23 const foodie = computeAlphabet('foodie');24 test('should work properly', () => {25 expect(isContained(foo, foo)).toBe(true);26 expect(isContained(foo, food)).toBe(false);27 expect(isContained(foo, foodie)).toBe(false);28 expect(isContained(food, foo)).toBe(true);29 expect(isContained(food, food)).toBe(true);30 expect(isContained(food, foodie)).toBe(false);31 expect(isContained(foodie, foo)).toBe(true);32 expect(isContained(foodie, food)).toBe(true);33 expect(isContained(foodie, foodie)).toBe(true);34 });...
Using AI Code Generation
1var wptools = require('wptools');2var query = wptools.page('Barack Obama');3query.get(function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data.isContained('Barack Obama'));8 }9});10var wptools = require('wptools');11var query = wptools.page('Barack Obama');12query.get(function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data.isContained('Barack'));17 }18});19var wptools = require('wptools');20var query = wptools.page('Barack Obama');21query.get(function(err, data) {22 if (err) {23 console.log(err);24 } else {25 console.log(data.isContained('Barack Obama', 'Obama'));26 }27});28var wptools = require('wptools');29var query = wptools.page('Barack Obama');30query.get(function(err, data) {31 if (err) {32 console.log(err);33 } else {34 console.log(data.isContained('Barack Obama', 'Obama', 'Barack'));35 }36});37### isNotContained()38var wptools = require('wptools');39var query = wptools.page('Barack Obama');40query.get(function(err, data) {41 if (err) {42 console.log(err);43 } else {44 console.log(data.is
Using AI Code Generation
1var wpt = require('./wpt.js');2var assert = require('assert');3var wpt = new WebPageTest('www.webpagetest.org', 'A.12345678901234567890123456789012');4wpt.runTest(url, function(err, data) {5 if (err) return console.error(err);6 wpt.getTestResults(data.data.testId, function(err, data) {7 if (err) return console.error(err);8 console.log(data);9 });10});11var wpt = new WebPageTest('www.webpagetest.org', 'A.12345678901234567890123456789012');12wpt.runTest(url, function(err, data) {13 if (err) return console.error(err);14 wpt.getTestResults(data.data.testId, function(err, data) {15 if (err) return console.error(err);16 console.log(data);17 });18});19var wpt = new WebPageTest('www.webpagetest.org', 'A.12345678901234567890123456789012');20wpt.runTest(url, function(err, data) {21 if (err) return console.error(err);22 wpt.getTestResults(data.data.testId, function(err, data) {23 if (err) return console.error(err);24 console.log(data);25 });26});27var wpt = new WebPageTest('www.webpagetest.org', 'A.12345678901234567890123456789012');28wpt.runTest(url, function(err, data) {29 if (err) return console.error(err);30 wpt.getTestResults(data.data.testId, function(err, data) {31 if (err) return console.error(err);32 console.log(data);33 });34});35var wpt = new WebPageTest('www.webpagetest.org', 'A.12345678901234567890123456789012');36wpt.runTest(url, function(err, data) {37 if (err) return console.error(err);38 wpt.getTestResults(data.data.testId, function(err, data) {39 if (
Using AI Code Generation
1var wpt = require('../wpt.js');2var options = {3};4var wpt = new WebPageTest('www.webpagetest.org');5wpt.runTest(options, function(err, data) {6 if (err) return console.log(err);7 wpt.getTestResults(data.data.testId, function(err, data) {8 if (err) return console.log(err);9 console.log(data);10 });11});
Using AI Code Generation
1var wptools = require('wptools');2var page = wptools('Hinduism');3page.isContained('Hinduism', function(err, resp) {4 if (err) {5 console.log(err);6 } else {7 console.log(resp);8 }9});10{ isContained: true }
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2var isContained = wptoolkit.isContained;3var log = console.log;4var array1 = [1, 2, 3, 4, 5];5var array2 = [1, 2, 3];6log(isContained(array1, array2));7var array1 = [1, 2, 3, 4, 5];8var array2 = [1, 2, 3, 4, 5];9log(isContained(array1, array2));10var array1 = [1, 2, 3, 4, 5];11var array2 = [1, 2, 3, 4, 5, 6];12log(isContained(array1, array2));13var array1 = [1, 2, 3, 4, 5];14var array2 = [6, 7, 8, 9, 10];15log(isContained(array1, array2));16var array1 = [1, 2, 3, 4, 5];17var array2 = [];18log(isContained(array1, array2));19var array1 = [];20var array2 = [1, 2, 3, 4, 5];21log(isContained(array1, array2));22var array1 = [];23var array2 = [];24log(isContained(array1, array2));25var array1 = [1, 2, 3, 4, 5];26var array2 = [1, 2, 3, 4, 5];27log(isContained(array1, array2, true));28var array1 = [1, 2, 3, 4, 5];29var array2 = [1, 2, 3, 4, 5];30log(isContained(array1, array2, false));31var array1 = [1, 2, 3, 4, 5];32var array2 = [1, 2, 3, 4, 5];
Using AI Code Generation
1const wptools = require('wptools');2wptools.isContained('en', 'United States', 'California', function(err, res) {3 console.log(res);4});5### `wptools.isContained(lang, parent, child, callback)`6- `lang` - The language of the wiki to use (e.g. `en`, `fr`, etc.)7### `wptools.isContainedSync(lang, parent, child)`
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!!