Best JavaScript code snippet using wpt
iterator.d.ts
Source:iterator.d.ts
1import { Data } from "../data";2import { Type } from "../enum";3import { Visitor } from "../visitor";4import { VectorType } from "../interfaces";5import {6 DataType,7 Dictionary,8 Bool,9 Null,10 Utf8,11 Binary,12 Decimal,13 FixedSizeBinary,14 List,15 FixedSizeList,16 Map_,17 Struct,18 Float,19 Float16,20 Float32,21 Float64,22 Int,23 Uint8,24 Uint16,25 Uint32,26 Uint64,27 Int8,28 Int16,29 Int32,30 Int64,31 Date_,32 DateDay,33 DateMillisecond,34 Interval,35 IntervalDayTime,36 IntervalYearMonth,37 Time,38 TimeSecond,39 TimeMillisecond,40 TimeMicrosecond,41 TimeNanosecond,42 Timestamp,43 TimestampSecond,44 TimestampMillisecond,45 TimestampMicrosecond,46 TimestampNanosecond,47 Union,48 DenseUnion,49 SparseUnion50} from "../type";51/** @ignore */52export interface IteratorVisitor extends Visitor {53 visit<T extends VectorType>(node: T): IterableIterator<T["TValue"] | null>;54 visitMany<T extends VectorType>(55 nodes: T[]56 ): IterableIterator<T["TValue"] | null>[];57 getVisitFn<T extends Type>(58 node: T59 ): (60 vector: VectorType<T>61 ) => IterableIterator<VectorType<T>["TValue"] | null>;62 getVisitFn<T extends DataType>(63 node: VectorType<T> | Data<T> | T64 ): (65 vector: VectorType<T>66 ) => IterableIterator<VectorType<T>["TValue"] | null>;67 visitNull<T extends Null>(68 vector: VectorType<T>69 ): IterableIterator<T["TValue"] | null>;70 visitBool<T extends Bool>(71 vector: VectorType<T>72 ): IterableIterator<T["TValue"] | null>;73 visitInt<T extends Int>(74 vector: VectorType<T>75 ): IterableIterator<T["TValue"] | null>;76 visitInt8<T extends Int8>(77 vector: VectorType<T>78 ): IterableIterator<T["TValue"] | null>;79 visitInt16<T extends Int16>(80 vector: VectorType<T>81 ): IterableIterator<T["TValue"] | null>;82 visitInt32<T extends Int32>(83 vector: VectorType<T>84 ): IterableIterator<T["TValue"] | null>;85 visitInt64<T extends Int64>(86 vector: VectorType<T>87 ): IterableIterator<T["TValue"] | null>;88 visitUint8<T extends Uint8>(89 vector: VectorType<T>90 ): IterableIterator<T["TValue"] | null>;91 visitUint16<T extends Uint16>(92 vector: VectorType<T>93 ): IterableIterator<T["TValue"] | null>;94 visitUint32<T extends Uint32>(95 vector: VectorType<T>96 ): IterableIterator<T["TValue"] | null>;97 visitUint64<T extends Uint64>(98 vector: VectorType<T>99 ): IterableIterator<T["TValue"] | null>;100 visitFloat<T extends Float>(101 vector: VectorType<T>102 ): IterableIterator<T["TValue"] | null>;103 visitFloat16<T extends Float16>(104 vector: VectorType<T>105 ): IterableIterator<T["TValue"] | null>;106 visitFloat32<T extends Float32>(107 vector: VectorType<T>108 ): IterableIterator<T["TValue"] | null>;109 visitFloat64<T extends Float64>(110 vector: VectorType<T>111 ): IterableIterator<T["TValue"] | null>;112 visitUtf8<T extends Utf8>(113 vector: VectorType<T>114 ): IterableIterator<T["TValue"] | null>;115 visitBinary<T extends Binary>(116 vector: VectorType<T>117 ): IterableIterator<T["TValue"] | null>;118 visitFixedSizeBinary<T extends FixedSizeBinary>(119 vector: VectorType<T>120 ): IterableIterator<T["TValue"] | null>;121 visitDate<T extends Date_>(122 vector: VectorType<T>123 ): IterableIterator<T["TValue"] | null>;124 visitDateDay<T extends DateDay>(125 vector: VectorType<T>126 ): IterableIterator<T["TValue"] | null>;127 visitDateMillisecond<T extends DateMillisecond>(128 vector: VectorType<T>129 ): IterableIterator<T["TValue"] | null>;130 visitTimestamp<T extends Timestamp>(131 vector: VectorType<T>132 ): IterableIterator<T["TValue"] | null>;133 visitTimestampSecond<T extends TimestampSecond>(134 vector: VectorType<T>135 ): IterableIterator<T["TValue"] | null>;136 visitTimestampMillisecond<T extends TimestampMillisecond>(137 vector: VectorType<T>138 ): IterableIterator<T["TValue"] | null>;139 visitTimestampMicrosecond<T extends TimestampMicrosecond>(140 vector: VectorType<T>141 ): IterableIterator<T["TValue"] | null>;142 visitTimestampNanosecond<T extends TimestampNanosecond>(143 vector: VectorType<T>144 ): IterableIterator<T["TValue"] | null>;145 visitTime<T extends Time>(146 vector: VectorType<T>147 ): IterableIterator<T["TValue"] | null>;148 visitTimeSecond<T extends TimeSecond>(149 vector: VectorType<T>150 ): IterableIterator<T["TValue"] | null>;151 visitTimeMillisecond<T extends TimeMillisecond>(152 vector: VectorType<T>153 ): IterableIterator<T["TValue"] | null>;154 visitTimeMicrosecond<T extends TimeMicrosecond>(155 vector: VectorType<T>156 ): IterableIterator<T["TValue"] | null>;157 visitTimeNanosecond<T extends TimeNanosecond>(158 vector: VectorType<T>159 ): IterableIterator<T["TValue"] | null>;160 visitDecimal<T extends Decimal>(161 vector: VectorType<T>162 ): IterableIterator<T["TValue"] | null>;163 visitList<T extends List>(164 vector: VectorType<T>165 ): IterableIterator<T["TValue"] | null>;166 visitStruct<T extends Struct>(167 vector: VectorType<T>168 ): IterableIterator<T["TValue"] | null>;169 visitUnion<T extends Union>(170 vector: VectorType<T>171 ): IterableIterator<T["TValue"] | null>;172 visitDenseUnion<T extends DenseUnion>(173 vector: VectorType<T>174 ): IterableIterator<T["TValue"] | null>;175 visitSparseUnion<T extends SparseUnion>(176 vector: VectorType<T>177 ): IterableIterator<T["TValue"] | null>;178 visitDictionary<T extends Dictionary>(179 vector: VectorType<T>180 ): IterableIterator<T["TValue"] | null>;181 visitInterval<T extends Interval>(182 vector: VectorType<T>183 ): IterableIterator<T["TValue"] | null>;184 visitIntervalDayTime<T extends IntervalDayTime>(185 vector: VectorType<T>186 ): IterableIterator<T["TValue"] | null>;187 visitIntervalYearMonth<T extends IntervalYearMonth>(188 vector: VectorType<T>189 ): IterableIterator<T["TValue"] | null>;190 visitFixedSizeList<T extends FixedSizeList>(191 vector: VectorType<T>192 ): IterableIterator<T["TValue"] | null>;193 visitMap<T extends Map_>(194 vector: VectorType<T>195 ): IterableIterator<T["TValue"] | null>;196}197/** @ignore */198export declare class IteratorVisitor extends Visitor {}199/** @ignore */...
get.d.ts
Source:get.d.ts
1import { Data } from "../data";2import { Visitor } from "../visitor";3import { VectorType } from "../interfaces";4import { Type } from "../enum";5import {6 DataType,7 Dictionary,8 Bool,9 Null,10 Utf8,11 Binary,12 Decimal,13 FixedSizeBinary,14 List,15 FixedSizeList,16 Map_,17 Struct,18 Float,19 Float16,20 Float32,21 Float64,22 Int,23 Uint8,24 Uint16,25 Uint32,26 Uint64,27 Int8,28 Int16,29 Int32,30 Int64,31 Date_,32 DateDay,33 DateMillisecond,34 Interval,35 IntervalDayTime,36 IntervalYearMonth,37 Time,38 TimeSecond,39 TimeMillisecond,40 TimeMicrosecond,41 TimeNanosecond,42 Timestamp,43 TimestampSecond,44 TimestampMillisecond,45 TimestampMicrosecond,46 TimestampNanosecond,47 Union,48 DenseUnion,49 SparseUnion50} from "../type";51/** @ignore */52export interface GetVisitor extends Visitor {53 visit<T extends VectorType>(node: T, index: number): T["TValue"];54 visitMany<T extends VectorType>(55 nodes: T[],56 indices: number[]57 ): T["TValue"][];58 getVisitFn<T extends Type>(59 node: T60 ): (vector: VectorType<T>, index: number) => VectorType<T>["TValue"];61 getVisitFn<T extends DataType>(62 node: VectorType<T> | Data<T> | T63 ): (vector: VectorType<T>, index: number) => VectorType<T>["TValue"];64 visitNull<T extends Null>(vector: VectorType<T>, index: number): T["TValue"];65 visitBool<T extends Bool>(vector: VectorType<T>, index: number): T["TValue"];66 visitInt<T extends Int>(vector: VectorType<T>, index: number): T["TValue"];67 visitInt8<T extends Int8>(vector: VectorType<T>, index: number): T["TValue"];68 visitInt16<T extends Int16>(69 vector: VectorType<T>,70 index: number71 ): T["TValue"];72 visitInt32<T extends Int32>(73 vector: VectorType<T>,74 index: number75 ): T["TValue"];76 visitInt64<T extends Int64>(77 vector: VectorType<T>,78 index: number79 ): T["TValue"];80 visitUint8<T extends Uint8>(81 vector: VectorType<T>,82 index: number83 ): T["TValue"];84 visitUint16<T extends Uint16>(85 vector: VectorType<T>,86 index: number87 ): T["TValue"];88 visitUint32<T extends Uint32>(89 vector: VectorType<T>,90 index: number91 ): T["TValue"];92 visitUint64<T extends Uint64>(93 vector: VectorType<T>,94 index: number95 ): T["TValue"];96 visitFloat<T extends Float>(97 vector: VectorType<T>,98 index: number99 ): T["TValue"];100 visitFloat16<T extends Float16>(101 vector: VectorType<T>,102 index: number103 ): T["TValue"];104 visitFloat32<T extends Float32>(105 vector: VectorType<T>,106 index: number107 ): T["TValue"];108 visitFloat64<T extends Float64>(109 vector: VectorType<T>,110 index: number111 ): T["TValue"];112 visitUtf8<T extends Utf8>(vector: VectorType<T>, index: number): T["TValue"];113 visitBinary<T extends Binary>(114 vector: VectorType<T>,115 index: number116 ): T["TValue"];117 visitFixedSizeBinary<T extends FixedSizeBinary>(118 vector: VectorType<T>,119 index: number120 ): T["TValue"];121 visitDate<T extends Date_>(122 vector: VectorType<T>,123 index: number124 ): T["TValue"];125 visitDateDay<T extends DateDay>(126 vector: VectorType<T>,127 index: number128 ): T["TValue"];129 visitDateMillisecond<T extends DateMillisecond>(130 vector: VectorType<T>,131 index: number132 ): T["TValue"];133 visitTimestamp<T extends Timestamp>(134 vector: VectorType<T>,135 index: number136 ): T["TValue"];137 visitTimestampSecond<T extends TimestampSecond>(138 vector: VectorType<T>,139 index: number140 ): T["TValue"];141 visitTimestampMillisecond<T extends TimestampMillisecond>(142 vector: VectorType<T>,143 index: number144 ): T["TValue"];145 visitTimestampMicrosecond<T extends TimestampMicrosecond>(146 vector: VectorType<T>,147 index: number148 ): T["TValue"];149 visitTimestampNanosecond<T extends TimestampNanosecond>(150 vector: VectorType<T>,151 index: number152 ): T["TValue"];153 visitTime<T extends Time>(vector: VectorType<T>, index: number): T["TValue"];154 visitTimeSecond<T extends TimeSecond>(155 vector: VectorType<T>,156 index: number157 ): T["TValue"];158 visitTimeMillisecond<T extends TimeMillisecond>(159 vector: VectorType<T>,160 index: number161 ): T["TValue"];162 visitTimeMicrosecond<T extends TimeMicrosecond>(163 vector: VectorType<T>,164 index: number165 ): T["TValue"];166 visitTimeNanosecond<T extends TimeNanosecond>(167 vector: VectorType<T>,168 index: number169 ): T["TValue"];170 visitDecimal<T extends Decimal>(171 vector: VectorType<T>,172 index: number173 ): T["TValue"];174 visitList<T extends List>(vector: VectorType<T>, index: number): T["TValue"];175 visitStruct<T extends Struct>(176 vector: VectorType<T>,177 index: number178 ): T["TValue"];179 visitUnion<T extends Union>(180 vector: VectorType<T>,181 index: number182 ): T["TValue"];183 visitDenseUnion<T extends DenseUnion>(184 vector: VectorType<T>,185 index: number186 ): T["TValue"];187 visitSparseUnion<T extends SparseUnion>(188 vector: VectorType<T>,189 index: number190 ): T["TValue"];191 visitDictionary<T extends Dictionary>(192 vector: VectorType<T>,193 index: number194 ): T["TValue"];195 visitInterval<T extends Interval>(196 vector: VectorType<T>,197 index: number198 ): T["TValue"];199 visitIntervalDayTime<T extends IntervalDayTime>(200 vector: VectorType<T>,201 index: number202 ): T["TValue"];203 visitIntervalYearMonth<T extends IntervalYearMonth>(204 vector: VectorType<T>,205 index: number206 ): T["TValue"];207 visitFixedSizeList<T extends FixedSizeList>(208 vector: VectorType<T>,209 index: number210 ): T["TValue"];211 visitMap<T extends Map_>(vector: VectorType<T>, index: number): T["TValue"];212}213/** @ignore */214export declare class GetVisitor extends Visitor {}215/** @ignore */...
menu.ts
Source:menu.ts
1interface IBaseMenuItem<TMenuData = {}, TValue = string> {2 label: React.ReactNode;3 value?: TValue;4 data: TMenuData | null;5}6export type IFlatMenuItem<TMenuData = {}, TValue = string> = IBaseMenuItem<7 TMenuData,8 TValue9> & {10 id: string;11 parent: string | null;12 sort: number;13};14export type IMenuItem<TMenuData = {}, TValue = string> = IBaseMenuItem<15 TMenuData,16 TValue17> & {18 children: Array<IMenuItem<TMenuData, TValue>>;19};20export type IMenu<TMenuData = {}, TValue = string> = Array<21 IMenuItem<TMenuData, TValue>22>;23export type IFlatMenu<TMenuData = {}, TValue = string> = Array<24 IFlatMenuItem<TMenuData, TValue>25>;26export function validateMenuOptions<TMenuData = {}, TValue = string>(27 menu: IMenu<TMenuData, TValue>28): boolean {29 const values: TValue[] = toFlat(menu)30 .map(menuItem => menuItem.value)31 .filter(value => value !== undefined);32 const uniqueValues = Array.from(new Set(values));33 return uniqueValues.length === values.length;34}35function _getMenuItemByPath<TMenuData = {}, TValue = string>(36 menuItem: IMenuItem<TMenuData, TValue>,37 path: number[]38): IMenuItem<TMenuData, TValue> {39 if (path.length === 0) {40 return menuItem;41 }42 return _getMenuItemByPath(menuItem.children[path[0]], path.slice(1));43}44export function getMenuItemByPath<TMenuData = {}, TValue = string>(45 menu: IMenu<TMenuData, TValue>,46 path: number[]47): IMenuItem<TMenuData, TValue> {48 return _getMenuItemByPath(menu[path[0]], path.slice(1));49}50export function getMenuItemByValue<TMenuData = {}, TValue = string>(51 menu: IMenu<TMenuData, TValue>,52 value: TValue53): IMenuItem<TMenuData, TValue> {54 const flatMenu = toFlat(menu);55 const flatMenuItem: IFlatMenuItem<TMenuData, TValue> = flatMenu.find(56 menuItem => menuItem.value === value57 );58 if (flatMenuItem === undefined) {59 throw new Error(`Value ${value} does not exist in menu`);60 }61 return _fromFlat(flatMenu, flatMenuItem);62}63function _walkToMenuItem<TMenuData = {}, TValue = string>(64 menuItem: IMenuItem<TMenuData, TValue>,65 path: number[]66): IMenu<TMenuData, TValue> {67 const node = menuItem.children[path[0]];68 if (path.length === 1) {69 return [node];70 }71 return [node, ..._walkToMenuItem(node, path.slice(1))];72}73export function walkToMenuItem<TMenuData = {}, TValue = string>(74 menu: IMenu<TMenuData, TValue>,75 path: number[]76): IMenu<TMenuData, TValue> {77 const walkByNode = menu[path[0]];78 return [walkByNode, ..._walkToMenuItem(walkByNode, path.slice(1))];79}80function _walkToRoot<TMenuData = {}, TValue = string>(81 flatMenu: IFlatMenu<TMenuData, TValue>,82 parent: string83): IFlatMenu<TMenuData, TValue> {84 const menuItem = flatMenu.find(menuItem => menuItem.id === parent);85 if (menuItem.parent === null) {86 return [menuItem];87 }88 return [menuItem, ..._walkToRoot(flatMenu, menuItem.parent)];89}90export function walkToRoot<TMenuData = {}, TValue = string>(91 menu: IMenu<TMenuData, TValue>,92 value: TValue93): IMenu<TMenuData, TValue> {94 const flatMenu = toFlat(menu);95 const menuItem = flatMenu.find(menuItem => menuItem.value === value);96 return (menuItem.parent === null97 ? [menuItem]98 : [menuItem, ..._walkToRoot(flatMenu, menuItem.parent)]99 ).map(flatMenuItem => _fromFlat(flatMenu, flatMenuItem));100}101function _toFlat<TMenuData = {}, TValue = string>(102 menuItem: IMenuItem<TMenuData, TValue>,103 sort: number,104 parent: string105): IFlatMenu<TMenuData, TValue> {106 const id = parent ? [parent, sort].join(":") : sort.toString();107 const flatMenuItem: IFlatMenuItem<TMenuData, TValue> = {108 data: menuItem.data,109 id,110 label: menuItem.label,111 parent,112 sort,113 value: menuItem.value114 };115 return [116 flatMenuItem,117 ...menuItem.children118 .map((child, childIndex) => _toFlat(child, childIndex, id))119 .reduce(120 (acc, curr) => [...acc, ...curr],121 [] as IFlatMenu<TMenuData, TValue>122 )123 ];124}125export function toFlat<TMenuData = {}, TValue = string>(126 menu: IMenu<TMenuData, TValue>127): IFlatMenu<TMenuData, TValue> {128 return menu129 .map((menuItem, menuItemIndex) => _toFlat(menuItem, menuItemIndex, null))130 .reduce(131 (acc, curr) => [...acc, ...curr],132 [] as IFlatMenu<TMenuData, TValue>133 );134}135function _fromFlat<TMenuData = {}, TValue = string>(136 menu: IFlatMenu<TMenuData, TValue>,137 flatMenuItem: IFlatMenuItem<TMenuData, TValue>138): IMenuItem<TMenuData, TValue> {139 const children: Array<IMenuItem<TMenuData, TValue>> = menu140 .filter(menuItem => menuItem.parent === flatMenuItem.id)141 .map(menuItem => _fromFlat(menu, menuItem));142 return {143 children,144 data: flatMenuItem.data,145 label: flatMenuItem.label,146 value: flatMenuItem.value147 };148}149export function fromFlat<TMenuData = {}, TValue = string>(150 menu: IFlatMenu<TMenuData, TValue>151): IMenu<TMenuData, TValue> {152 return menu153 .filter(menuItem => menuItem.parent === null)154 .map(menuItem => _fromFlat(menu, menuItem));155}156export function isLeaf<TMenuData = {}, TValue = string>(157 menuItem: IMenuItem<TMenuData, TValue>158): boolean {159 return menuItem.children.length === 0;...
Using AI Code Generation
1var wpt = require('webpagetest')('www.webpagetest.org');2var location = 'Dulles:Chrome';3var runs = 3;4var connectivity = 'Cable';5var timeout = 60000;6var options = {7};8wpt.runTest(url, options, function(err, data) {9 if (err) return console.error(err);10 console.log('Test submitted to WebPageTest for %s', url);11 console.log('View your test at: %s', data.data.userUrl);12 console.log('Poll results every %s seconds. Polling again in %s seconds', options.pollResults, options.pollResults);13 var testId = data.data.testId;14 setTimeout(function() {15 wpt.getTestResults(testId, function(err, data) {16 if (err) return console.error(err);17 console.log('Got results for %s', url);18 console.log('First View');19 console.log('Speed Index: %s', data.data.average.firstView.SpeedIndex);20 console.log('Time to Interactive: %s ms', data.data.average.firstView.TTI);21 console.log('Total Blocking Time: %s ms', data.data.average.firstView.TBT);22 console.log('Largest Contentful Paint: %s ms', data.data.average.firstView.LCP);23 console.log('First Contentful Paint: %s ms', data.data.average.firstView.FCP);24 console.log('First Meaningful Paint: %s ms', data.data.average.firstView.FMP);25 console.log('Dom Interactive: %s ms', data.data.average.firstView.DI);26 console.log('Dom Content Loaded: %s ms', data.data.average.firstView.DCL);27 console.log('Dom Complete: %s ms', data.data.average.firstView.DC);28 console.log('Load Time: %s ms', data.data.average.firstView.loadTime);29 console.log('Fully Loaded
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.6a8d0c2e2d9c9a9e9f0c6f9a6a6a6a6a');3}, function(err, data) {4 if (err) return console.error(err);5 console.log('Test status:', data.statusText);6 console.log('Test ID:', data.data.testId);7 console.log('Test URL:', data.data.userUrl);8 console.log('Test results:', data.data.summary);9});
Using AI Code Generation
1var wpt = require('wpt.js');2var data1 = [1,2,3,4,5,6,7,8,9,10];3var data2 = [1,2,3,4,5,6,7,8,9,10];4var t = wpt.tValue(data1, data2);5console.log(t);6var sig = wpt.isSignificant(t, data1.length, data2.length);7console.log(sig);
Using AI Code Generation
1var wpt = require('webpagetest');2var options = {3};4var wpt = new wpt(options);5wpt.runTest(testURL, function(err, data) {6 if (err) return console.log(err);7 console.log('Test submitted to WebPagetest for: ' + testURL);8 console.log('Test ID: ' + data.data.testId);9 wpt.getTestResults(data.data.testId, function(err, data) {10 if (err) return console.log(err);11 console.log('Test results for ' + testURL + ':');12 console.log(data.data.median.firstView.TTFB);13 });14});
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!!