Skip to content

Instantly share code, notes, and snippets.

@Jonathan-Law
Jonathan-Law / Batch.ts
Last active October 2, 2019 21:18 — forked from ccnokes/Batch.ts
A class that manages the logic of batching items together within a timeframe and then passing those items to a function. Sandbox: https://codesandbox.io/s/v86lv7k89l
type Resolve = <T>(value?: T | PromiseLike<T>) => Promise<T>;
type Reject = <T>(reason?: any) => Promise<T>;
/**
* Deferred
*
* A deferred promise class used to create delayed promise resolutions
*/
export class Deferred<T> {
promise: Promise<T>;