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
{ | |
"vim.easymotion": true, | |
"vim.leader": "<space>", | |
"files.autoSave": "afterDelay", | |
"editor.formatOnSave": true, | |
"editor.codeActionsOnSave": ["source.addMissingImports"], | |
"vim.visualModeKeyBindingsNonRecursive": [ | |
{ | |
"before": ["<leader>", "g"], | |
"commands": ["editor.action.smartSelect.grow"] |
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 { useCallback, useEffect, useMemo } from 'react' | |
export class Poller<T> { | |
private interval: ReturnType<typeof setInterval> | null = null | |
constructor( | |
private readonly callback: (arg: { didCancelRef: { current: boolean } }) => T, | |
private readonly intervalMs: number | |
) {} | |
readonly didCancelRef = { current: false } | |
start() { |
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
class Stats { | |
periods = 0 | |
totals = {} as Record<string, number> | |
starts = {} as Record<string, number> | |
start(name: string) { | |
this.starts[name] = performance.now() | |
} | |
end(name: string) { | |
if (!this.starts[name]) throw new Error(`No start for ${name}`) |
OlderNewer