Skip to content

Instantly share code, notes, and snippets.

View JustinChristensen's full-sized avatar

Justin Christensen JustinChristensen

  • Minneapolis, MN
View GitHub Profile
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;
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;
};
before access:
foo
baz
quux
accessed foo:
baz
quux
foo
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);
};
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
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) => {
{
"path": "/Users/wroathe/Development/react-tests/app/src/components/EmployeeTable.jsx",
"all": false,
"statementMap": {
"0": {
"start": {
"line": 1,
"column": 0
},
"end": {
;************************** 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:
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);
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 => {