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 interface Debounced<F extends (...arg: any[]) => any> { | |
(...args: Parameters<F>): void; | |
clear(): void; | |
} | |
/** | |
* Returns a function that executes `func` until after `wait` | |
* milliseconds have elapsed since the last time the debounced function was | |
* invoked. |
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
docker | |
docker-buildx | |
docker-completion | |
docker-compose | |
docker-credential-helper | |
colima |
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
function* primeNumbers() { | |
const primeList = [2, 3]; | |
let nextCandidate = 4; | |
yield 1; | |
yield 2; | |
yield 3; | |
while(true) { | |
if(primeList.every(prime => nextCandidate % prime !== 0)) { |
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
/** | |
* Returns a promise that resolves after `waitMs` milliseconds. | |
* @param waitMs the amount of milliseconds we need to wait. | |
*/ | |
export const delay = (waitMs: number): Promise<void> => new Promise(resolve => setTimeout(resolve, waitMs)); | |
export interface PollOptions { | |
waitMs: number; | |
onError?: (error: unknown, ctx: PollContext) => 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
type InnerPromise2State<T> = | |
| { | |
type: "idle"; | |
} | |
| { type: "resolved"; value: T } | |
| { type: "rejected"; error: unknown }; | |
type Consumer<T> = (value: T) => void; | |
type Promise2Executor<T> = ( |
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
import { linear } from 'https://cdn.jsdelivr.net/npm/[email protected]/easing/index.mjs'; | |
function point(x, y) { | |
return { | |
x, | |
y, | |
}; | |
} | |
function polygon(edges) { |
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
/** | |
* Defines one or more key-value properties | |
*/ | |
export type WithKeyValue<K extends string | number | symbol, Value> = { | |
[k in K]: Value; | |
}; |
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
/** | |
* Locates a descendant of `rootElement` given selector provided | |
* or throws error if output element is not found | |
* or is not an instance of input `DomElementClass`. | |
* | |
* ### Example | |
* | |
* ```ts | |
* const btn = queryElement( | |
* renderRes.container, |
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
// @see https://kentcdodds.com/blog/how-to-use-react-context-effectively | |
// @see https://beta.reactjs.org/learn/scaling-up-with-reducer-and-context | |
import { | |
createContext, | |
Dispatch, | |
useReducer, | |
ReactNode, | |
useContext, | |
} from 'react'; |
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
/* eslint-disable prefer-spread, consistent-return */ | |
import { useEffect, useLayoutEffect, useRef } from 'react' | |
type Nullable<T> = T | null | |
type EventHandler<T, E> = (this: T, evt: E) => any | |
export type GetAddListenerOptions = { | |
(eventType: string): AddEventListenerOptions | boolean | undefined | |
} |
NewerOlder