This file contains hidden or 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
| import { summary, bench, run, do_not_optimize } from 'mitata'; | |
| bench('noop', () => { }); | |
| bench('noop', () => { }); | |
| bench('noop', () => { }); | |
| summary(() => { | |
| { | |
| const fn = (a: number, b: number) => a * 2 + b + Math.random(); | |
| do_not_optimize(fn); |
This file contains hidden or 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
| declare const _: unique symbol; | |
| export interface Redacted<out T> extends Symbol { | |
| [_]: T | |
| } | |
| const redactMap = new WeakMap(); | |
| export const init = <const T>(val: T): Redacted<T> => { | |
| const sym = Symbol('<redacted>'); | |
| redactMap.set(sym, val); |
This file contains hidden or 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 getFinishedState = async (s: [string], p: Promise<any>) => { | |
| try { | |
| await p; | |
| s[0] = 'resolved'; | |
| } catch (e) { | |
| s[0] = 'rejected'; | |
| // Don't swallow error | |
| return p; | |
| } |
This file contains hidden or 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
| { | |
| // DisposableStack fork | |
| using parentStack = new DisposableStack(); | |
| const childStack = parentStack.use(new DisposableStack()); | |
| // DisposableStack register with dispose callback (should be cached) | |
| const stack = new DisposableStack(); | |
| stack.adopt(resource, (resource) => { | |
| // Dispose resource | |
| }); |
OlderNewer