How to use duplicates method in wpt

Best JavaScript code snippet using wpt

arrayRemoveDuplicatesSpec.js

Source:arrayRemoveDuplicatesSpec.js Github

copy

Full Screen

1defineSuite([2 'Core/arrayRemoveDuplicates',3 'Core/Cartesian3',4 'Core/Math',5 'Core/Spherical'6 ], function(7 arrayRemoveDuplicates,8 Cartesian3,9 CesiumMath,10 Spherical) {11 'use strict';1213 it('removeDuplicates returns positions if none removed', function() {14 var positions = [Cartesian3.ZERO];15 var noDuplicates = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon);16 expect(noDuplicates).toBe(positions);17 });1819 it('removeDuplicates returns positions if none removed', function() {20 var positions = [Cartesian3.ZERO, Cartesian3.UNIT_X, Cartesian3.UNIT_Y, Cartesian3.UNIT_Z];21 var noDuplicates = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon);22 expect(noDuplicates).toBe(positions);23 });2425 it('removeDuplicates wrapping returns positions if none removed', function() {26 var positions = [Cartesian3.ZERO, Cartesian3.UNIT_X, Cartesian3.UNIT_Y, Cartesian3.UNIT_Z];27 var noDuplicates = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon, true);28 expect(noDuplicates).toBe(positions);29 });3031 it('removeDuplicates to remove duplicates', function() {32 var positions = [33 new Cartesian3(1.0, 1.0, 1.0),34 new Cartesian3(1.0, 1.0, 1.0),35 new Cartesian3(1.0, 1.0, 1.0),36 new Cartesian3(1.0, 1.0, 1.0),37 new Cartesian3(2.0, 2.0, 2.0),38 new Cartesian3(3.0, 3.0, 3.0),39 new Cartesian3(3.0, 3.0, 3.0)];40 var expectedPositions = [41 new Cartesian3(1.0, 1.0, 1.0),42 new Cartesian3(2.0, 2.0, 2.0),43 new Cartesian3(3.0, 3.0, 3.0)];44 var noDuplicates = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon);45 expect(noDuplicates).toEqual(expectedPositions);46 });4748 it('removeDuplicates to remove duplicates with anonymous types', function() {49 var positions = [50 {x:1.0, y:1.0, z:1.0},51 {x:1.0, y:1.0, z:1.0},52 {x:1.0, y:1.0, z:1.0},53 {x:1.0, y:1.0, z:1.0},54 {x:2.0, y:2.0, z:2.0},55 {x:3.0, y:3.0, z:3.0},56 {x:3.0, y:3.0, z:3.0}];57 var expectedPositions = [58 {x:1.0, y:1.0, z:1.0},59 {x:2.0, y:2.0, z:2.0},60 {x:3.0, y:3.0, z:3.0}];61 var noDuplicates = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon);62 expect(noDuplicates).toEqual(expectedPositions);63 });6465 it('removeDuplicates to remove duplicates with Spherical type', function() {66 var positions = [67 new Spherical(1.0, 1.0, 1.0),68 new Spherical(1.0, 1.0, 1.0),69 new Spherical(1.0, 1.0, 1.0),70 new Spherical(1.0, 1.0, 1.0),71 new Spherical(2.0, 2.0, 1.0),72 new Spherical(3.0, 3.0, 1.0),73 new Spherical(3.0, 3.0, 2.0)];74 var expectedPositions = [75 new Spherical(1.0, 1.0, 1.0),76 new Spherical(2.0, 2.0, 1.0),77 new Spherical(3.0, 3.0, 1.0),78 new Spherical(3.0, 3.0, 2.0)];79 var noDuplicates = arrayRemoveDuplicates(positions, Spherical.equalsEpsilon);80 expect(noDuplicates).toEqual(expectedPositions);81 });8283 it('removeDuplicates works with empty array', function() {84 var positions = [];85 var noDuplicates = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon);86 expect(noDuplicates).toEqual(positions);87 });8889 it('removeDuplicates to remove positions within absolute epsilon 10', function() {90 var positions = [91 new Cartesian3(1.0, 1.0, 1.0),92 new Cartesian3(1.0, 2.0, 3.0),93 new Cartesian3(1.0, 2.0, 3.0 + CesiumMath.EPSILON10)];94 var expectedPositions = [95 new Cartesian3(1.0, 1.0, 1.0),96 new Cartesian3(1.0, 2.0, 3.0)];97 var noDuplicates = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon);98 expect(noDuplicates).toEqual(expectedPositions);99 });100101 it('removeDuplicates to remove positions within relative epsilon 10', function() {102 var positions = [103 new Cartesian3(0.0, 0.0, 1000000.0),104 new Cartesian3(0.0, 0.0, 3000000.0),105 new Cartesian3(0.0, 0.0, 3000000.0002)];106 var expectedPositions = [107 new Cartesian3(0.0, 0.0, 1000000.0),108 new Cartesian3(0.0, 0.0, 3000000.0)];109 var noDuplicates = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon);110 expect(noDuplicates).toEqual(expectedPositions);111 });112113 it('removeDuplicates keeps positions that add up past relative epsilon 10', function() {114 var eightyPercentOfEpsilon = 0.8 * CesiumMath.EPSILON10;115 var positions = [116 new Cartesian3(0.0, 0.0, 1.0),117 new Cartesian3(0.0, 0.0, 1.0 + eightyPercentOfEpsilon),118 new Cartesian3(0.0, 0.0, 1.0 + (2 * eightyPercentOfEpsilon)),119 new Cartesian3(0.0, 0.0, 1.0 + (3 * eightyPercentOfEpsilon))];120 var expectedPositions = [121 new Cartesian3(0.0, 0.0, 1.0),122 new Cartesian3(0.0, 0.0, 1.0 + (2 * eightyPercentOfEpsilon))];123 var noDuplicates = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon);124 expect(noDuplicates).toEqual(expectedPositions);125 });126127 it('removeDuplicates returns undefined', function() {128 var noDuplicates = arrayRemoveDuplicates(undefined, Cartesian3.equalsEpsilon);129 expect(noDuplicates).toBe(undefined);130 });131132 it('removeDuplicates wrapping removes duplicate first and last points', function() {133 var positions = [134 new Cartesian3(1.0, 1.0, 1.0),135 new Cartesian3(2.0, 2.0, 2.0),136 new Cartesian3(3.0, 3.0, 3.0),137 new Cartesian3(1.0, 1.0, 1.0)];138139 var expectedPositions = [140 new Cartesian3(2.0, 2.0, 2.0),141 new Cartesian3(3.0, 3.0, 3.0),142 new Cartesian3(1.0, 1.0, 1.0)];143144 var noDuplicates = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon, true);145146 expect(noDuplicates).toEqual(expectedPositions);147 });148149 it('removeDuplicates wrapping removes duplicate including first and last points', function() {150 var positions = [151 new Cartesian3(1.0, 1.0, 1.0),152 new Cartesian3(2.0, 2.0, 2.0),153 new Cartesian3(2.0, 2.0, 2.0),154 new Cartesian3(3.0, 3.0, 3.0),155 new Cartesian3(1.0, 1.0, 1.0)];156157 var expectedPositions = [158 new Cartesian3(2.0, 2.0, 2.0),159 new Cartesian3(3.0, 3.0, 3.0),160 new Cartesian3(1.0, 1.0, 1.0)];161162 var noDuplicates = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon, true);163164 expect(noDuplicates).toEqual(expectedPositions);165 });166 ...

Full Screen

Full Screen

array_utils.test.ts

Source:array_utils.test.ts Github

copy

Full Screen

1// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.2// See LICENSE.txt for license information.3import {insertWithoutDuplicates, insertMultipleWithoutDuplicates, removeItem} from './array_utils';4describe('insertWithoutDuplicates', () => {5 test('should add the item at the given location', () => {6 expect(insertWithoutDuplicates(['a', 'b', 'c', 'd'], 'z', 0)).toEqual(['z', 'a', 'b', 'c', 'd']);7 expect(insertWithoutDuplicates(['a', 'b', 'c', 'd'], 'z', 1)).toEqual(['a', 'z', 'b', 'c', 'd']);8 expect(insertWithoutDuplicates(['a', 'b', 'c', 'd'], 'z', 2)).toEqual(['a', 'b', 'z', 'c', 'd']);9 expect(insertWithoutDuplicates(['a', 'b', 'c', 'd'], 'z', 3)).toEqual(['a', 'b', 'c', 'z', 'd']);10 expect(insertWithoutDuplicates(['a', 'b', 'c', 'd'], 'z', 4)).toEqual(['a', 'b', 'c', 'd', 'z']);11 });12 test('should move an item if it already exists', () => {13 expect(insertWithoutDuplicates(['a', 'b', 'c', 'd'], 'a', 0)).toEqual(['a', 'b', 'c', 'd']);14 expect(insertWithoutDuplicates(['a', 'b', 'c', 'd'], 'a', 1)).toEqual(['b', 'a', 'c', 'd']);15 expect(insertWithoutDuplicates(['a', 'b', 'c', 'd'], 'a', 2)).toEqual(['b', 'c', 'a', 'd']);16 expect(insertWithoutDuplicates(['a', 'b', 'c', 'd'], 'a', 3)).toEqual(['b', 'c', 'd', 'a']);17 });18 test('should return the original array if nothing changed', () => {19 const input = ['a', 'b', 'c', 'd'];20 expect(insertWithoutDuplicates(input, 'a', 0)).toBe(input);21 });22});23describe('insertMultipleWithoutDuplicates', () => {24 test('should add the item at the given location', () => {25 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c', 'd'], ['z', 'y', 'x'], 0)).toEqual(['z', 'y', 'x', 'a', 'b', 'c', 'd']);26 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c', 'd'], ['z', 'y', 'x'], 1)).toEqual(['a', 'z', 'y', 'x', 'b', 'c', 'd']);27 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c', 'd'], ['z', 'y', 'x'], 2)).toEqual(['a', 'b', 'z', 'y', 'x', 'c', 'd']);28 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c', 'd'], ['z', 'y', 'x'], 3)).toEqual(['a', 'b', 'c', 'z', 'y', 'x', 'd']);29 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c', 'd'], ['z', 'y', 'x'], 4)).toEqual(['a', 'b', 'c', 'd', 'z', 'y', 'x']);30 });31 test('should move an item if it already exists', () => {32 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c', 'd'], ['a', 'c'], 0)).toEqual(['a', 'c', 'b', 'd']);33 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c', 'd'], ['a', 'c'], 1)).toEqual(['b', 'a', 'c', 'd']);34 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c', 'd'], ['a', 'c'], 2)).toEqual(['b', 'd', 'a', 'c']);35 });36 test('should properly place new and existing items', () => {37 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c', 'd'], ['z', 'y', 'x', 'a', 'c'], 0)).toEqual(['z', 'y', 'x', 'a', 'c', 'b', 'd']);38 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c', 'd'], ['z', 'y', 'x', 'a', 'c'], 1)).toEqual(['b', 'z', 'y', 'x', 'a', 'c', 'd']);39 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c', 'd'], ['z', 'y', 'x', 'a', 'c'], 2)).toEqual(['b', 'd', 'z', 'y', 'x', 'a', 'c']);40 });41 test('should return the original array if nothing changed', () => {42 const input = ['a', 'b', 'c', 'd'];43 expect(insertMultipleWithoutDuplicates(input, ['a', 'b', 'c'], 0)).toStrictEqual(input);44 });45 test('should just return the array if either the input or items to insert is blank', () => {46 expect(insertMultipleWithoutDuplicates([], ['a', 'b', 'c'], 0)).toStrictEqual(['a', 'b', 'c']);47 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c'], [], 0)).toStrictEqual(['a', 'b', 'c']);48 });49 test('should handle invalid index inputs', () => {50 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c', 'd'], ['e', 'f'], 10)).toStrictEqual(['a', 'b', 'c', 'd', 'e', 'f']);51 expect(insertMultipleWithoutDuplicates(['a', 'b', 'c', 'd'], ['e', 'f'], -2)).toStrictEqual(['a', 'b', 'e', 'f', 'c', 'd']);52 });53});54describe('removeItem', () => {55 test('should remove the given item', () => {56 expect(removeItem(['a', 'b', 'c', 'd'], 'a')).toEqual(['b', 'c', 'd']);57 expect(removeItem(['a', 'b', 'c', 'd'], 'b')).toEqual(['a', 'c', 'd']);58 expect(removeItem(['a', 'b', 'c', 'd'], 'c')).toEqual(['a', 'b', 'd']);59 expect(removeItem(['a', 'b', 'c', 'd'], 'd')).toEqual(['a', 'b', 'c']);60 });61 test('should return the original array if nothing changed', () => {62 const input = ['a', 'b', 'c', 'd'];63 expect(removeItem(input, 'e')).toBe(input);64 });...

Full Screen

Full Screen

MergeDuplicateChunksPlugin.js

Source:MergeDuplicateChunksPlugin.js Github

copy

Full Screen

1/*2 MIT License http://www.opensource.org/licenses/mit-license.php3 Author Tobias Koppers @sokra4*/5"use strict";6const { STAGE_BASIC } = require("../OptimizationStages");7const { runtimeEqual } = require("../util/runtime");8/** @typedef {import("../Compiler")} Compiler */9class MergeDuplicateChunksPlugin {10 /**11 * @param {Compiler} compiler the compiler12 * @returns {void}13 */14 apply(compiler) {15 compiler.hooks.compilation.tap(16 "MergeDuplicateChunksPlugin",17 compilation => {18 compilation.hooks.optimizeChunks.tap(19 {20 name: "MergeDuplicateChunksPlugin",21 stage: STAGE_BASIC22 },23 chunks => {24 const { chunkGraph, moduleGraph } = compilation;25 // remember already tested chunks for performance26 const notDuplicates = new Set();27 // for each chunk28 for (const chunk of chunks) {29 // track a Set of all chunk that could be duplicates30 let possibleDuplicates;31 for (const module of chunkGraph.getChunkModulesIterable(chunk)) {32 if (possibleDuplicates === undefined) {33 // when possibleDuplicates is not yet set,34 // create a new Set from chunks of the current module35 // including only chunks with the same number of modules36 for (const dup of chunkGraph.getModuleChunksIterable(37 module38 )) {39 if (40 dup !== chunk &&41 chunkGraph.getNumberOfChunkModules(chunk) ===42 chunkGraph.getNumberOfChunkModules(dup) &&43 !notDuplicates.has(dup)44 ) {45 // delay allocating the new Set until here, reduce memory pressure46 if (possibleDuplicates === undefined) {47 possibleDuplicates = new Set();48 }49 possibleDuplicates.add(dup);50 }51 }52 // when no chunk is possible we can break here53 if (possibleDuplicates === undefined) break;54 } else {55 // validate existing possible duplicates56 for (const dup of possibleDuplicates) {57 // remove possible duplicate when module is not contained58 if (!chunkGraph.isModuleInChunk(module, dup)) {59 possibleDuplicates.delete(dup);60 }61 }62 // when all chunks has been removed we can break here63 if (possibleDuplicates.size === 0) break;64 }65 }66 // when we found duplicates67 if (68 possibleDuplicates !== undefined &&69 possibleDuplicates.size > 070 ) {71 outer: for (const otherChunk of possibleDuplicates) {72 if (otherChunk.hasRuntime() !== chunk.hasRuntime()) continue;73 if (chunkGraph.getNumberOfEntryModules(chunk) > 0) continue;74 if (chunkGraph.getNumberOfEntryModules(otherChunk) > 0)75 continue;76 if (!runtimeEqual(chunk.runtime, otherChunk.runtime)) {77 for (const module of chunkGraph.getChunkModulesIterable(78 chunk79 )) {80 const exportsInfo = moduleGraph.getExportsInfo(module);81 if (82 !exportsInfo.isEquallyUsed(83 chunk.runtime,84 otherChunk.runtime85 )86 ) {87 continue outer;88 }89 }90 }91 // merge them92 if (chunkGraph.canChunksBeIntegrated(chunk, otherChunk)) {93 chunkGraph.integrateChunks(chunk, otherChunk);94 compilation.chunks.delete(otherChunk);95 }96 }97 }98 // don't check already processed chunks twice99 notDuplicates.add(chunk);100 }101 }102 );103 }104 );105 }106}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools')2const fs = require('fs')3const path = require('path')4const util = require('util')5const writeFile = util.promisify(fs.writeFile)6const appendFile = util.promisify(fs.appendFile)7const mkdir = util.promisify(fs.mkdir)8const readdir = util.promisify(fs.readdir)9const readFile = util.promisify(fs.readFile)10const { get } = require('https')11const { exec } = require('child_process')12const { promisify } = require('util')13const { resolve } = require('path')14const { rejects } = require('assert')15const { request } = require('http')16const { get } = require('https')17const { exec } = require('child_process')18const { promisify } = require('util')19const { resolve } = require('path')20const { rejects } = require('assert')21const { request } = require('http')22const { get } = require('https')23const { exec } = require('child_process')24const { promisify } = require('util')25const { resolve } = require('path')26const { rejects } = require('assert')27const { request } = require('http')28const { get } = require('https')29const { exec } = require('child_process')30const { promisify } = require('util')31const { resolve } = require('path')32const { rejects } = require('assert')33const { request } = require('http')34const { get } = require('https')35const { exec } = require('child_process')36const { promisify } = require('util')37const { resolve } = require('path')38const { rejects } = require('assert')39const { request } = require('http')40const { get } = require('https')41const { exec } = require('child_process')42const { promisify } = require('util')43const { resolve } = require('path')44const { rejects } = require('assert')45const { request } = require('http')46const { get } = require('https')47const { exec } = require('child_process')48const { promisify } = require('util')49const { resolve } = require('path')50const { rejects } = require('assert')51const { request } = require('http')52const { get } = require('https')53const { exec } = require('child_process')54const { promisify } = require

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptoolkit = require('wptoolkit');2const duplicates = wptoolkit.duplicates;3let testArray = [1, 2, 3, 4, 5, 6, 7, 8, 9];4let testArray2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1];5let testArray3 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2];6let testArray4 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 3];7let testArray5 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 3, 4];8let testArray6 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 3, 4, 5];9let testArray7 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 3, 4, 5, 6];10let testArray8 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 3, 4, 5, 6, 7];11let testArray9 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 3, 4, 5, 6, 7, 8];12let testArray10 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 3, 4, 5, 6, 7, 8, 9];

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var array = fs.readFileSync('test.txt').toString().split("\n");4for(i in array) {5 var wiki = wptools.page(array[i]);6 wiki.get(function(err, resp) {7 if (err) {8 console.log(err);9 } else {10 console.log(resp.data.duplicates);11 }12 });13}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wiki = wptools.page('Barack Obama');3wiki.get(function(err, resp) {4 console.log(resp.data.duplicates);5});6var wptools = require('wptools');7var wiki = wptools.page('Barack Obama');8wiki.get(function(err, resp) {9 console.log(resp.data.info);10});11var wptools = require('wptools');12var wiki = wptools.page('Barack Obama');13wiki.get(function(err, resp) {14 console.log(resp.data.images);15});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const fs = require('fs');3const path = require('path');4const argv = require('yargs').argv;5const _ = require('lodash');6const async = require('async');7const request = require('request');8const cheerio = require('cheerio');9const jsonfile = require('jsonfile');10const file = './data.json';11const file2 = './data2.json';12const file3 = './data3.json';13const file4 = './data4.json';14const file5 = './data5.json';15const file6 = './data6.json';16const file7 = './data7.json';17const file8 = './data8.json';18const file9 = './data9.json';19const file10 = './data10.json';20const file11 = './data11.json';21const file12 = './data12.json';22const file13 = './data13.json';23const file14 = './data14.json';24const file15 = './data15.json';25const file16 = './data16.json';26const file17 = './data17.json';27const file18 = './data18.json';28const file19 = './data19.json';29const file20 = './data20.json';30const file21 = './data21.json';31const file22 = './data22.json';32const file23 = './data23.json';33const file24 = './data24.json';34const file25 = './data25.json';35const file26 = './data26.json';36const file27 = './data27.json';37const file28 = './data28.json';38const file29 = './data29.json';39const file30 = './data30.json';40const file31 = './data31.json';41const file32 = './data32.json';42const file33 = './data33.json';43const file34 = './data34.json';44const file35 = './data35.json';45const file36 = './data36.json';46const file37 = './data37.json';47const file38 = './data38.json';48const file39 = './data39.json';49const file40 = './data40.json';50const file41 = './data41.json';51const file42 = './data42.json';52const file43 = './data43.json';53const file44 = './data44.json';54const file45 = './data45.json';

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