UNPKG

thorish

Version:

This is a library of useful JS concepts and data structures for Node and the browser. It it, unashamedly, a dumping ground for code needed by [@samthor](https://twitter.com/samthor)'s projects.

13 lines (12 loc) 520 B
export interface ExpirableResult<R> { signal: AbortSignal; result: R; } /** * Caches the call to an async {@link Function}, which returns a result and a {@link AbortSignal}. * * When the signal is aborted, the result is cleared and new calls trigger the underlying function * again. */ export declare function buildAsyncExpirable<R>(fn: () => Promise<ExpirableResult<R>>): () => Promise<ExpirableResult<R>>; export declare function buildExpirable<R>(fn: () => ExpirableResult<R>): () => ExpirableResult<R>;