5.0.1 • Published 12 months ago

@johngw/async v5.0.1

Weekly downloads
68
License
MIT
Repository
-
Last release
12 months ago

@johngw/async

accumulateRace(AsyncIterator, number) => Promise<T[]>

Returns an array of results, that have been accumulated from an async interator, within an amount of milliseconds.

cancelablePromise(resolve, reject): Promise & { cancel: () => void }

Creates a promise that can be cancelled. Cancelling a promise is the same as rejecting it with CancelPromiseError.

mapP<T, R>(T[], (T, number) => Promise): Promise<R[]>

Shortcut for:

Promise.all(array.map(fn))

timeout(number = 0): Promise

Returns a promise that resolves in ms milliseconds.

defer(): { promise: Promise, resolve: (value: T | PromiseLike) => void }

Returns a promise and a resolve function that resolves the promise.

debounceP<Args extends unknown[], Return>(fn: (...args: Args) => Promise, ms: number) => typeof fn

Debounces fn to ms milliseconds. The debounced function will always return the last result (Promise<Return>).

detonate(number = 0, Error = TimeoutError): Promise

Returns a promise that rejects in ms milliseconds with the given Error.

detonateRace(Promise, number = 0, Error = TimeoutError): Promise

Returns a promise that resolves the given promise or rejects after ms milliseconds.

5.0.1

12 months ago

5.0.0

12 months ago

4.1.1

2 years ago

4.1.0

3 years ago

4.0.2

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

3.0.0

3 years ago

2.10.5

3 years ago

2.10.4

3 years ago

2.5.0

3 years ago

2.7.0

3 years ago

2.6.0

3 years ago

2.8.1

3 years ago

2.8.0

3 years ago

2.4.0

3 years ago

2.3.0

3 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.0

3 years ago