This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type HasForEach<T> = ArrayLike<T> & { | |
readonly forEach: (fn: (x: T, i: number, arr: HasForEach<T>) => void, thisArg?: any) => void | |
}; | |
export type DelegatedEvent = Event & { | |
delegate: Element | null | |
}; | |
export type DelegatedEventListener = (e: DelegatedEvent) => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isObject = o => String(o) === '[object Object]'; | |
const isArray = o => Array.isArray(o); | |
const objContains = (x, o) => { | |
if (isObject(o)) return Object.values(o).some(v => objContains(x, v)); | |
else if (isArray(o)) return o.some(v => objContains(x, v)); | |
else return x === o; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before access: | |
foo | |
baz | |
quux | |
accessed foo: | |
baz | |
quux | |
foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const stepErr = i => err => { | |
err.step = i; | |
return Promise.reject(err); | |
}; | |
const inSteps = (...[step, ...steps]) => x => { | |
if (!step) return x; | |
[stepFn, errFn] = step; | |
return Promise.resolve(stepFn(x)).then(inSteps(...steps), errFn); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CDP = require('chrome-remote-interface'); | |
async function example() { | |
let client; | |
try { | |
// connect to endpoint | |
client = await CDP(); | |
// extract domains | |
const {Network, Page, Runtime} = client; | |
// setup handlers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const curry = fn => (...args) => { | |
if (args.length >= fn.length) return fn(...args); | |
return (...nextArgs) => curry(fn)(...args.concat(nextArgs)); | |
} | |
const pinReq = curry((req, x) => (x.request = req, x)); | |
const pinResp = curry((resp, x) => (x.response = resp, x)); | |
const reject = curry((fn, err) => Promise.reject(fn(err))); | |
const mapApply = async (x, y, ...fns) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"path": "/Users/wroathe/Development/react-tests/app/src/components/EmployeeTable.jsx", | |
"all": false, | |
"statementMap": { | |
"0": { | |
"start": { | |
"line": 1, | |
"column": 0 | |
}, | |
"end": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;************************** strlen64.asm ********************************** | |
; Author: Agner Fog | |
; Date created: 2008-07-19 | |
; Last modified: 2008-10-16 | |
; Description: | |
; Faster version of the standard strlen function: | |
; size_t strlen(const char * str); | |
; Finds the length of a zero-terminated string of bytes, optimized for speed. | |
; | |
; Overriding standard function strlen: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { createCoverageMap } = require('istanbul-lib-coverage'); | |
const { createContext } = require('istanbul-lib-report'); | |
const { create: createReporter } = require('istanbul-reports'); | |
const v8ToIstanbul = require('v8-to-istanbul'); | |
const { test: { beforeEach, afterEach } } = require('@playwright/test'); | |
const coverageMap = createCoverageMap(); | |
const reportCoverage = () => { | |
console.log(coverageMap); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { bench, times, rand } = require('./bench.js'); | |
console.log('map:'); | |
let N = 100; | |
let timings = {}; | |
while (N <= 1000000) { | |
const map = new Map(); | |
times(N, i => { |