How to use exclusive method in wpt

Best JavaScript code snippet using wpt

games.js

Source:games.js Github

copy

Full Screen

1export default {2 popular: {3 title: 'Popular Slots',4 link: '/slots/popular',5 desc: 'All the slots that our users love',6 block: 'block',7 data: [8 { name: 'Mayfair Roulette', new: false , exclusive: false },9 { name: 'Eye of Horus', new: false , exclusive: false },10 { name: 'Dragons Luck Megaways™', new: false , exclusive: false },11 { name: 'Diamond Mine Megaways™', new: false , exclusive: true },12 { name: '20p Roulette', new: false , exclusive: false },13 { name: 'Jack in a Pot', new: true , exclusive: false },14 { name: 'Rainbow Jackpots', new: true , exclusive: false },15 { name: 'Dragon\'s Luck Power Reels', new: false , exclusive: false },16 { name: 'Ninja Ways', new: false , exclusive: false },17 { name: 'Genie Jackpot', new: false , exclusive: false },18 { name: '100/1 Roulette', new: false , exclusive: true },19 { name: 'Golden Megaways™', new: false , exclusive: false } 20 ]21 },22 recent: {23 title: 'Recently Played',24 desc: 'All your favourites at your fintertips',25 block: 'blockSingle',26 data: [27 { name: 'John Hunter & the Tomb Raider', new: false , exclusive: false },28 { name: 'Da Vinci\'s Super Liners', new: true , exclusive: false },29 { name: 'Wish Upon a Leprechaun', new: false , exclusive: true },30 { name: 'Dragons Luck Megaways™', new: false , exclusive: false },31 { name: 'Mystery Reels Power Reels', new: false , exclusive: false },32 { name: 'The Luck of the Irish', new: false , exclusive: false },33 { name: 'Starburst', new: true , exclusive: false },34 { name: 'Blackjack C', new: false , exclusive: false } 35 ]36 },37 cardtable: {38 title: 'Card & Table Games',39 link: '/table',40 desc: 'May the cards be ever in your favour',41 block: 'blockTwo',42 data: [43 { name: '20p Roulette', new: false , exclusive: false },44 { name: 'Mayfair Blackjack', new: true , exclusive: false },45 { name: 'Mayfair Roulette', new: false , exclusive: false },46 { name: 'Mississippi Stud', new: false , exclusive: true },47 { name: 'Baccarat', new: false , exclusive: false },48 { name: 'Fortune Pai Gow Poker', new: false , exclusive: true },49 { name: 'Let it Ride', new: false , exclusive: false },50 { name: 'Three Card Poker', new: false , exclusive: false },51 { name: '777 Blazing Blackjack', new: false , exclusive: false },52 { name: 'Ultimate Texas Hold\'em', new: true , exclusive: false },53 { name: '100/1 Roulette', new: false , exclusive: false },54 { name: 'Golden Megaways', new: false , exclusive: false } 55 ]56 },57 live: {58 title: 'Live Games',59 link: '/live',60 desc: 'Get that casino feeling',61 block: 'block',62 data: [63 { name: 'Vegas Speed Roulette', new: false , exclusive: false },64 { name: 'Monopoly Live', new: false , exclusive: false },65 { name: 'Blackjack A', new: false , exclusive: false },66 { name: 'Blackjack B', new: false , exclusive: false },67 { name: 'Blackjack C', new: false , exclusive: false },68 { name: 'Blackjack D', new: false , exclusive: false },69 { name: 'Deal or No Deal', new: false , exclusive: false },70 { name: 'Blackjack F', new: false , exclusive: false },71 { name: 'Lightning Roulette', new: false , exclusive: false },72 { name: 'Blackjack A', new: false , exclusive: false },73 { name: 'Blackjack B', new: false , exclusive: false },74 { name: 'Blackjack C', new: false , exclusive: false }75 ]76 },77 gameshow: {78 title: 'Game Show',79 desc: 'Spin it to win it',80 block: 'block',81 data: [82 { name: 'Monopoly Live', new: false , exclusive: false },83 { name: 'Deal or No Deal', new: false , exclusive: false },84 { name: 'Monopoly Live', new: false , exclusive: false },85 { name: 'Deal or No Deal', new: false , exclusive: false },86 { name: 'Monopoly Live', new: false , exclusive: false },87 { name: 'Deal or No Deal', new: false , exclusive: false },88 { name: 'Monopoly Live', new: false , exclusive: false },89 { name: 'Deal or No Deal', new: false , exclusive: false },90 { name: 'Monopoly Live', new: false , exclusive: false },91 { name: 'Deal or No Deal', new: false , exclusive: false } 92 ]93 },94 liveblackjack: {95 title: 'Live Blackjack',96 link: '/live/blackjack', 97 desc: 'All your favourite Blackjack games, live.',98 block: 'block',99 data: [100 { name: 'Blackjack A', new: false , exclusive: false },101 { name: 'Blackjack B', new: false , exclusive: false },102 { name: 'Blackjack C', new: false , exclusive: false },103 { name: 'Blackjack D', new: false , exclusive: false },104 { name: 'Blackjack A', new: false , exclusive: false },105 { name: 'Blackjack B', new: false , exclusive: false }106 ]107 }, 108 blackjack: {109 title: 'Blackjack',110 link: '/table/blackjack', 111 desc: 'All your favourite Blackjack games.',112 block: 'block',113 data: [114 { name: 'Blackjack A', new: false , exclusive: false },115 { name: 'Blackjack B', new: false , exclusive: false },116 { name: 'Blackjack C', new: false , exclusive: false },117 { name: 'Blackjack D', new: false , exclusive: false },118 { name: 'Blackjack A', new: false , exclusive: false },119 { name: 'Blackjack B', new: false , exclusive: false }120 ]121 },122 baccarat: {123 title: 'Baccarat',124 desc: 'Time to back the banker.',125 block: 'block',126 data: [127 { name: 'Fortune Pai Gow Poker', new: false , exclusive: true },128 { name: 'Let it Ride', new: false , exclusive: false },129 { name: 'Three Card Poker', new: false , exclusive: false },130 { name: '777 Blazing Blackjack', new: false , exclusive: false },131 { name: 'Ultimate Texas Hold\'em', new: true , exclusive: false },132 { name: 'Fortune Pai Gow Poker', new: false , exclusive: true },133 { name: 'Let it Ride', new: false , exclusive: false },134 { name: 'Three Card Poker', new: false , exclusive: false },135 { name: '777 Blazing Blackjack', new: false , exclusive: false },136 { name: 'Ultimate Texas Hold\'em', new: true , exclusive: false } 137 ]138 }, 139 roulette: {140 title: 'Roulette',141 link: '/table/roulette', 142 desc: 'Fancy a game of Roulette?',143 block: 'block',144 data: [145 { name: 'Vegas Speed Roulette', new: false , exclusive: false },146 { name: 'Lightning Roulette', new: false , exclusive: false },147 { name: '20p Roulette', new: false , exclusive: false },148 { name: 'Mayfair Roulette', new: false , exclusive: false },149 { name: 'Vegas Speed Roulette', new: false , exclusive: false },150 { name: 'Lightning Roulette', new: false , exclusive: false },151 { name: '20p Roulette', new: false , exclusive: false },152 { name: 'Mayfair Roulette', new: false , exclusive: false } 153 ]154 },155 liveroulette: {156 title: 'Live Roulette',157 link: '/live/roulette',158 desc: 'Fancy a game of Live Roulette?',159 block: 'block',160 data: [161 { name: 'Vegas Speed Roulette', new: false , exclusive: false },162 { name: 'Lightning Roulette', new: false , exclusive: false },163 { name: '20p Roulette', new: false , exclusive: false },164 { name: 'Mayfair Roulette', new: false , exclusive: false },165 { name: 'Vegas Speed Roulette', new: false , exclusive: false },166 { name: 'Lightning Roulette', new: false , exclusive: false },167 { name: '20p Roulette', new: false , exclusive: false },168 { name: 'Mayfair Roulette', new: false , exclusive: false } 169 ]170 }, 171 exclusives: {172 title: 'Exclusive Games',173 link: '/slots/exclusives',174 desc: 'You won\'t find these slots anywhere else!' ,175 block: 'blockTwo',176 data: [177 { name: 'The Pig Wizard Megaways', new: true , exclusive: false },178 { name: 'King Arthur', new: false , exclusive: false },179 { name: 'Kingdom of Wealth', new: false , exclusive: true },180 { name: 'Once upon a Rhyme', new: false , exclusive: false },181 { name: 'Top Cat', new: true , exclusive: false },182 { name: 'Thai Princess', new: false , exclusive: false },183 { name: 'Festival of Lights', new: false , exclusive: false },184 { name: 'Egyptian Goddess', new: false , exclusive: false },185 { name: 'Ninja Monkey', new: false , exclusive: true },186 { name: 'Senor Burrito', new: false , exclusive: false },187 { name: 'Jewel Strike', new: true , exclusive: false },188 { name: 'Lucky Duck', new: false , exclusive: false }189 ]190 },191 multiline: {192 title: 'Multi-Line Slots',193 desc: 'Get all the paylines you can handle',194 link: '/slots/multiline',195 block: 'blockTwo',196 data: [197 { name: 'King Arthur', new: false , exclusive: false },198 { name: 'Kingdom of Wealth', new: false , exclusive: true },199 { name: 'Once upon a Rhyme', new: false , exclusive: false },200 { name: 'Top Cat', new: true , exclusive: false },201 { name: 'Thai Princess', new: false , exclusive: false },202 { name: 'Festival of Lights', new: false , exclusive: false },203 { name: 'Egyptian Goddess', new: false , exclusive: false },204 { name: 'Ninja Monkey', new: false , exclusive: true },205 { name: 'Senor Burrito', new: false , exclusive: false },206 { name: 'Jewel Strike', new: true , exclusive: false },207 { name: 'Lucky Duck', new: false , exclusive: false }208 ]209 },210 themes: {211 title: 'Themes',212 desc: 'Find games that strike your fancy.',213 block: 'blockTwo',214 data: [215 { name: 'Classic Slots', new: false , exclusive: false },216 { name: 'Table Games', new: false , exclusive: false },217 { name: 'High Volatility', new: false , exclusive: false },218 { name: 'Multi-Line Slots', new: false , exclusive: false },219 { name: 'Trending', new: false , exclusive: false },220 { name: 'Sticky Wilds', new: false , exclusive: false }221 ]222 },223 az: {224 title: 'A-Z',225 desc: 'All our games from A to Z',226 block: 'block',227 data: [228 { name: 'Mayfair Roulette', new: false , exclusive: false },229 { name: 'Eye of Horus', new: false , exclusive: false },230 { name: 'Dragons Luck Megaways™', new: false , exclusive: false },231 { name: 'Diamond Mine Megaways™', new: false , exclusive: true },232 { name: '20p Roulette', new: false , exclusive: false },233 { name: 'Jack in a Pot', new: true , exclusive: false },234 { name: 'Rainbow Jackpots', new: true , exclusive: false },235 { name: 'Dragon\'s Luck Power Reels', new: false , exclusive: false },236 { name: 'Ninja Ways', new: false , exclusive: false },237 { name: 'Genie Jackpot', new: false , exclusive: false },238 { name: '100/1 Roulette', new: false , exclusive: true },239 { name: 'Golden Megaways™', new: false , exclusive: false } 240 ]241 }, 242 mustdrop: {243 title: 'Must Drop Jackpots',244 link: '/jackpots/mustdrop',245 desc: 'Look out for the Hourly and Daily drops.',246 block: 'blockJackpot',247 data: [248 { name: 'Dice Dice Dice', new: false , exclusive: false },249 { name: 'Da Vinci\'s Super Liners', new: false , exclusive: false },250 { name: 'Mystery Reels Power Reels', new: false , exclusive: false },251 { name: 'Well of Wishes', new: false , exclusive: false },252 { name: 'Hagar the Horrible', new: false , exclusive: false },253 { name: 'Wish Upon a Leprechaun', new: false , exclusive: false },254 { name: 'The Pig Wizard Megaways', new: false , exclusive: false },255 { name: 'Angel Princess', new: false , exclusive: false },256 { name: 'Dice Dice Dice', new: false , exclusive: false },257 { name: 'Da Vinci\'s Super Liners', new: false , exclusive: false },258 { name: 'Mystery Reels Power Reels', new: false , exclusive: false },259 { name: 'Well of Wishes', new: false , exclusive: false },260 { name: 'Hagar the Horrible', new: false , exclusive: false },261 { name: 'Wish Upon a Leprechaun', new: false , exclusive: false },262 { name: 'The Pig Wizard Megaways', new: false , exclusive: false } 263 ]264 },265 vegasmillions: {266 title: 'Vegas Millions',267 link: '/jackpots/vegasmillions', 268 desc: 'Win the Vegas Jackpot from anywhere.',269 block: 'blockJackpot',270 data: [271 { name: 'Hagar the Horrible', new: false , exclusive: false },272 { name: 'Wish Upon a Leprechaun', new: false , exclusive: false },273 { name: 'The Pig Wizard Megaways', new: false , exclusive: false },274 { name: 'Angel Princess', new: false , exclusive: false },275 { name: 'Dice Dice Dice', new: false , exclusive: false },276 { name: 'Da Vinci\'s Super Liners', new: false , exclusive: false },277 { name: 'Mystery Reels Power Reels', new: false , exclusive: false },278 { name: 'Well of Wishes', new: false , exclusive: false } 279 ]280 } ...

Full Screen

Full Screen

selectors.js

Source:selectors.js Github

copy

Full Screen

1/**2 * External dependencies3 */4import deepFreeze from 'deep-freeze';5/**6 * Internal dependencies7 */8import { getPendingLockRequests, isLockAvailable } from '../selectors';9import { deepCopyLocksTreePath, getNode } from '../utils';10describe( 'getPendingLockRequests', () => {11 it( 'returns pending lock requests', () => {12 const state = deepFreeze( {13 requests: [ 1, 2, 3 ],14 } );15 expect( getPendingLockRequests( state ) ).toEqual( [ 1, 2, 3 ] );16 } );17} );18describe( 'isLockAvailable', () => {19 describe( 'smoke tests', () => {20 it( 'returns true if lock is available', () => {21 const state = deepFreeze( {22 tree: {23 children: {},24 locks: [],25 },26 } );27 expect(28 isLockAvailable( state, 'core', [], {29 exclusive: true,30 } )31 ).toBe( true );32 } );33 it( 'returns false if lock is not available', () => {34 const state = deepFreeze( {35 tree: {36 children: {},37 locks: [ { exclusive: false } ],38 },39 } );40 expect(41 isLockAvailable( state, 'core', [], {42 exclusive: true,43 } )44 ).toBe( false );45 } );46 } );47 describe( 'Advanced cases - exclusive lock', () => {48 let state;49 beforeEach( () => {50 state = buildState( [51 [ 'core', 'entities', 'root', 'template_part', '3' ],52 [ 'core', 'queries' ],53 [ 'vendor' ],54 ] );55 } );56 it( `returns true if no parent or descendant has any locks`, () => {57 expect(58 isLockAvailable(59 deepFreeze( state ),60 'core',61 [ 'entities', 'root' ],62 { exclusive: true }63 )64 ).toBe( true );65 } );66 it( `returns true if another branch holds a locks (1)`, () => {67 appendLock( state, 'core', [ 'queries' ], {68 exclusive: true,69 } );70 expect(71 isLockAvailable(72 deepFreeze( state ),73 'core',74 [ 'entities', 'root' ],75 { exclusive: true }76 )77 ).toBe( true );78 } );79 it( `returns true if another branch holds a locks (2)`, () => {80 appendLock( state, 'vendor', [], {81 exclusive: true,82 } );83 expect(84 isLockAvailable(85 deepFreeze( state ),86 'core',87 [ 'entities', 'root' ],88 { exclusive: true }89 )90 ).toBe( true );91 } );92 it( `returns true if another branch holds a locks (3)`, () => {93 const subState = {94 tree: {95 locks: [],96 children: {97 postType: {98 locks: [],99 children: {100 post: {101 locks: [],102 children: {103 16: {104 locks: [105 {106 store: 'core',107 path: [108 'entities',109 'data',110 'postType',111 'post',112 16,113 ],114 exclusive: true,115 },116 ],117 children: {},118 },119 },120 },121 wp_template_part: {122 locks: [],123 children: {124 17: {125 locks: [],126 children: {},127 },128 },129 },130 },131 },132 },133 },134 };135 expect(136 isLockAvailable(137 deepFreeze( subState ),138 'core',139 [ 'postType', 'wp_template_part', 17 ],140 { exclusive: true }141 )142 ).toBe( true );143 } );144 it( `returns true if another branch holds a locks (4)`, () => {145 const subState = {146 tree: {147 locks: [],148 children: {149 core: {150 locks: [],151 children: {152 entities: {153 locks: [],154 children: {155 data: {156 locks: [],157 children: {158 postType: {159 locks: [],160 children: {161 book: {162 locks: [],163 children: {164 67: {165 locks: [166 {167 path: [168 'core',169 'entities',170 'data',171 'postType',172 'book',173 67,174 ],175 exclusive: true,176 },177 ],178 children: {},179 },180 },181 },182 },183 },184 },185 },186 },187 },188 },189 },190 },191 },192 };193 expect(194 isLockAvailable(195 deepFreeze( subState ),196 'core',197 [ 'entities', 'data', 'postType', 'book', 67 ],198 { exclusive: false }199 )200 ).toBe( false );201 } );202 [ true, false ].forEach( ( exclusive ) => {203 it( `returns true if the path is not accessible and no parent holds a lock`, () => {204 expect(205 isLockAvailable(206 deepFreeze( state ),207 'core',208 [ 'fake', 'path' ],209 { exclusive: true }210 )211 ).toBe( true );212 } );213 it( `returns false if the path is not accessible and any parent holds a lock`, () => {214 appendLock( state, 'core', [], {215 exclusive,216 } );217 expect(218 isLockAvailable(219 deepFreeze( state ),220 'core',221 [ 'fake', 'path' ],222 { exclusive: true }223 )224 ).toBe( false );225 } );226 it( `returns false if top-level parent already has a lock with exclusive=${ exclusive }`, () => {227 appendLock( state, 'core', [], {228 exclusive,229 } );230 expect(231 isLockAvailable(232 deepFreeze( state ),233 'core',234 [ 'entities', 'root' ],235 { exclusive: true }236 )237 ).toBe( false );238 } );239 it( `returns false if a direct parent already has a lock with exclusive=${ exclusive }`, () => {240 appendLock( state, 'core', [ 'entities' ], {241 exclusive,242 } );243 expect(244 isLockAvailable(245 deepFreeze( state ),246 'core',247 [ 'entities', 'root' ],248 { exclusive: true }249 )250 ).toBe( false );251 } );252 it( `returns false if the target node already has a lock with exclusive=${ exclusive }`, () => {253 appendLock( state, 'core', [ 'entities', 'root' ], {254 exclusive,255 } );256 expect(257 isLockAvailable(258 deepFreeze( state ),259 'core',260 [ 'entities', 'root' ],261 { exclusive: true }262 )263 ).toBe( false );264 } );265 it( `returns false if a children node already has a lock with exclusive=${ exclusive }`, () => {266 appendLock(267 state,268 'core',269 [ 'entities', 'root', 'template_part' ],270 {271 exclusive,272 }273 );274 expect(275 isLockAvailable(276 deepFreeze( state ),277 'core',278 [ 'entities', 'root' ],279 { exclusive: true }280 )281 ).toBe( false );282 } );283 it( `returns false if a grand-children node already has a lock with exclusive=${ exclusive }`, () => {284 appendLock(285 state,286 'core',287 [ 'entities', 'root', 'template_part', '3' ],288 {289 exclusive,290 }291 );292 expect(293 isLockAvailable(294 deepFreeze( state ),295 'core',296 [ 'entities', 'root' ],297 { exclusive: true }298 )299 ).toBe( false );300 } );301 } );302 } );303 describe( 'Advanced cases - shared lock', () => {304 let state;305 beforeEach( () => {306 state = buildState( [307 [ 'core', 'entities', 'root', 'template_part', '3' ],308 ] );309 } );310 it( `returns true if no parent or descendant has any locks`, () => {311 expect(312 isLockAvailable(313 deepFreeze( state ),314 'core',315 [ 'entities', 'root' ],316 { exclusive: true }317 )318 ).toBe( true );319 } );320 [ true, false ].forEach( ( isOtherLockExclusive ) => {321 const expectation = ! isOtherLockExclusive;322 it( `returns ${ expectation } if the path is not accessible and any parent holds a lock exclusive=${ isOtherLockExclusive }`, () => {323 appendLock( state, 'core', [], {324 exclusive: isOtherLockExclusive,325 } );326 expect(327 isLockAvailable(328 deepFreeze( state ),329 'core',330 [ 'fake', 'path' ],331 { exclusive: false }332 )333 ).toBe( expectation );334 } );335 it( `returns ${ expectation } if top-level parent already has a lock with exclusive=${ isOtherLockExclusive }`, () => {336 appendLock( state, 'core', [], {337 exclusive: isOtherLockExclusive,338 } );339 expect(340 isLockAvailable(341 deepFreeze( state ),342 'core',343 [ 'entities', 'root' ],344 { exclusive: false }345 )346 ).toBe( expectation );347 } );348 it( `returns ${ expectation } if a direct parent already has a lock with exclusive=${ isOtherLockExclusive }`, () => {349 appendLock( state, 'core', [ 'entities' ], {350 exclusive: isOtherLockExclusive,351 } );352 expect(353 isLockAvailable(354 deepFreeze( state ),355 'core',356 [ 'entities', 'root' ],357 { exclusive: false }358 )359 ).toBe( expectation );360 } );361 it( `returns ${ expectation } if the target node already has a lock with exclusive=${ isOtherLockExclusive }`, () => {362 appendLock( state, 'core', [ 'entities', 'root' ], {363 exclusive: isOtherLockExclusive,364 } );365 expect(366 isLockAvailable(367 deepFreeze( state ),368 'core',369 [ 'entities', 'root' ],370 { exclusive: false }371 )372 ).toBe( expectation );373 } );374 it( `returns ${ expectation } if a children node already has a lock with exclusive=${ isOtherLockExclusive }`, () => {375 appendLock(376 state,377 'core',378 [ 'entities', 'root', 'template_part' ],379 {380 exclusive: isOtherLockExclusive,381 }382 );383 expect(384 isLockAvailable(385 deepFreeze( state ),386 'core',387 [ 'entities', 'root' ],388 { exclusive: false }389 )390 ).toBe( expectation );391 } );392 it( `returns ${ expectation } if a grand-children node already has a lock with exclusive=${ isOtherLockExclusive }`, () => {393 appendLock(394 state,395 'core',396 [ 'entities', 'root', 'template_part', '3' ],397 {398 exclusive: isOtherLockExclusive,399 }400 );401 expect(402 isLockAvailable(403 deepFreeze( state ),404 'core',405 [ 'entities', 'root' ],406 { exclusive: false }407 )408 ).toBe( expectation );409 } );410 } );411 } );412} );413function appendLock( state, store, path, lock ) {414 getNode( state.tree, [ store, ...path ] ).locks.push( lock );415}416function buildState( paths ) {417 return {418 requests: [],419 tree: paths.reduce(420 ( tree, path ) => deepCopyLocksTreePath( tree, path ),421 {422 locks: [],423 children: {},424 }425 ),426 };...

Full Screen

Full Screen

Range.js

Source:Range.js Github

copy

Full Screen

1"use strict";2/**3 * @typedef {[number, boolean]} RangeValue4 */5/**6 * @callback RangeValueCallback7 * @param {RangeValue} rangeValue8 * @returns {boolean}9 */10class Range {11 /**12 * @param {"left" | "right"} side13 * @param {boolean} exclusive14 * @returns {">" | ">=" | "<" | "<="}15 */16 static getOperator(side, exclusive) {17 if (side === 'left') {18 return exclusive ? '>' : '>=';19 }20 return exclusive ? '<' : '<=';21 }22 /**23 * @param {number} value24 * @param {boolean} logic is not logic applied25 * @param {boolean} exclusive is range exclusive26 * @returns {string}27 */28 static formatRight(value, logic, exclusive) {29 if (logic === false) {30 return Range.formatLeft(value, !logic, !exclusive);31 }32 return `should be ${Range.getOperator('right', exclusive)} ${value}`;33 }34 /**35 * @param {number} value36 * @param {boolean} logic is not logic applied37 * @param {boolean} exclusive is range exclusive38 * @returns {string}39 */40 static formatLeft(value, logic, exclusive) {41 if (logic === false) {42 return Range.formatRight(value, !logic, !exclusive);43 }44 return `should be ${Range.getOperator('left', exclusive)} ${value}`;45 }46 /**47 * @param {number} start left side value48 * @param {number} end right side value49 * @param {boolean} startExclusive is range exclusive from left side50 * @param {boolean} endExclusive is range exclusive from right side51 * @param {boolean} logic is not logic applied52 * @returns {string}53 */54 static formatRange(start, end, startExclusive, endExclusive, logic) {55 let result = 'should be';56 result += ` ${Range.getOperator(logic ? 'left' : 'right', logic ? startExclusive : !startExclusive)} ${start} `;57 result += logic ? 'and' : 'or';58 result += ` ${Range.getOperator(logic ? 'right' : 'left', logic ? endExclusive : !endExclusive)} ${end}`;59 return result;60 }61 /**62 * @param {Array<RangeValue>} values63 * @param {boolean} logic is not logic applied64 * @return {RangeValue} computed value and it's exclusive flag65 */66 static getRangeValue(values, logic) {67 let minMax = logic ? Infinity : -Infinity;68 let j = -1;69 const predicate = logic ?70 /** @type {RangeValueCallback} */71 ([value]) => value <= minMax :72 /** @type {RangeValueCallback} */73 ([value]) => value >= minMax;74 for (let i = 0; i < values.length; i++) {75 if (predicate(values[i])) {76 [minMax] = values[i];77 j = i;78 }79 }80 if (j > -1) {81 return values[j];82 }83 return [Infinity, true];84 }85 constructor() {86 /** @type {Array<RangeValue>} */87 this._left = [];88 /** @type {Array<RangeValue>} */89 this._right = [];90 }91 /**92 * @param {number} value93 * @param {boolean=} exclusive94 */95 left(value, exclusive = false) {96 this._left.push([value, exclusive]);97 }98 /**99 * @param {number} value100 * @param {boolean=} exclusive101 */102 right(value, exclusive = false) {103 this._right.push([value, exclusive]);104 }105 /**106 * @param {boolean} logic is not logic applied107 * @return {string} "smart" range string representation108 */109 format(logic = true) {110 const [start, leftExclusive] = Range.getRangeValue(this._left, logic);111 const [end, rightExclusive] = Range.getRangeValue(this._right, !logic);112 if (!Number.isFinite(start) && !Number.isFinite(end)) {113 return '';114 }115 const realStart = leftExclusive ? start + 1 : start;116 const realEnd = rightExclusive ? end - 1 : end; // e.g. 5 < x < 7, 5 < x <= 6, 6 <= x <= 6117 if (realStart === realEnd) {118 return `should be ${logic ? '' : '!'}= ${realStart}`;119 } // e.g. 4 < x < ∞120 if (Number.isFinite(start) && !Number.isFinite(end)) {121 return Range.formatLeft(start, logic, leftExclusive);122 } // e.g. ∞ < x < 4123 if (!Number.isFinite(start) && Number.isFinite(end)) {124 return Range.formatRight(end, logic, rightExclusive);125 }126 return Range.formatRange(start, end, leftExclusive, rightExclusive, logic);127 }128}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('www.webpagetest.org');3test.runTest(url, {location: 'Dulles:Chrome'}, function(err, data) {4 if (err) return console.error(err);5 console.log('Test status:', data.statusText);6 test.getTestStatus(data.data.testId, function(err, data) {7 if (err) return console.error(err);8 console.log('Test status:', data.statusText);9 });10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var Wp = require('wptools');2wpt.page('Barack Obama').then(function(page){3 return page.get();4}).then(function(page){5 console.log(page);6});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt-api');2var options = {3};4wpt.runTest(options, function(err, data) {5 if (err) {6 console.log(err);7 } else {8 console.log(data);9 }10});11#### runTest(options, callback)12Default: `{}`

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var webpagetest = wpt(options);5webpagetest.runTest(url, {6}, function(err, data) {7 if (err) return console.error(err);8 console.log('Test status:', data.statusText);9 console.log('Test ID:', data.data.testId);10 console.log('Test URL:', data.data.summary);11 console.log('Test results:', data.data.runs[1].firstView);12 console.log('Test results:', data.data.runs[1].firstView.TTFB);13 console.log('Test results:', data.data.runs[1].firstView.render);14 console.log('Test results:', data.data.runs[1].firstView.fullyLoaded);15 console.log('Test results:', data.data.runs[1].firstView.SpeedIndex);16 console.log('Test results:', data.data.runs[1].firstView.docTime);17 console.log('Test results:', data.data.runs[1].firstView.domElements);18 console.log('Test results:', data.data.runs[1].firstView.requestsDoc);19 console.log('Test results:', data.data.runs[1].firstView.requestsFull);20 console.log('Test results:', data.data.runs[1].firstView.responses_200);21 console.log('Test results:', data.data.runs[1].firstView.responses_404);22 console.log('Test results:', data.data.runs[1].firstView.responses_other);23 console.log('Test results:', data.data.runs[1].firstView.bytesInDoc);24 console.log('Test results:', data.data.runs[1].firstView.bytesIn);25 console.log('Test results:', data.data.runs[1].firstView.breakdown);26 console.log('Test results:', data.data.runs[1].firstView

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