Docs update
Some checks failed
Build / Build NPM Project (push) Failing after 28s
Build / Tag Version (push) Has been skipped

This commit is contained in:
2024-09-22 02:38:13 -04:00
parent a0f0699a85
commit 3896949fc1
15 changed files with 984 additions and 110 deletions

View File

@ -1,5 +1,25 @@
export type ProgressCallback = (progress: number) => any;
/**
* A promise that fires the `onProgress` callback on incremental progress
*
* @example
* ```js
* const promise = new Promise((resolve, reject, progress) => {
* const max = 10;
* for(let i = 0; i < max; i++) progress(i / max);
* resolve(1);
* });
*
* console.log(promise.progress);
*
* promise.onProgress(console.log)
* .then(console.log)
* .catch(console.error)
* .finally(...);
*
* ```
*/
export class PromiseProgress<T> extends Promise<T> {
private listeners: ProgressCallback[] = [];