forked from Arquisoft/wichat_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e03ff76
commit 988a7e0
Showing
6 changed files
with
42 additions
and
396 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
declare global { | ||
interface Array<T> { | ||
/* | ||
* Return an array, containing the elements of this | ||
* array, split into n chunks | ||
**/ | ||
chunks(n: number) : Array<Array<T>>; | ||
} | ||
} | ||
|
||
export function chunks<T>(this: Array<T>, n: number) : Array<Array<T>> { | ||
return this.filter((_,i) => i % n === 0).map((_,i) => this.slice(i,i+n)) | ||
} | ||
|
||
Array.prototype.chunks = chunks; |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
export interface IPromiseStore { | ||
addPromise(p: Promise<any>) : void; | ||
syncPendingPromises() : void; | ||
} | ||
|
||
export class PromiseStore implements IPromiseStore { | ||
private pendingPromises: Promise<any>[] = []; | ||
|
||
addPromise(p: Promise<any>) : void { | ||
this.pendingPromises.push(p); | ||
} | ||
|
||
async syncPendingPromises() : Promise<void> { | ||
await Promise.all(this.pendingPromises); | ||
this.pendingPromises = []; | ||
} | ||
} |
Oops, something went wrong.