mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-23 17:23:18 +00:00
re-add partion function
This commit is contained in:
1 parent
aa40eee097
commit
8c9e287719
1 file changed
+6
@@ -23,6 +23,12 @@ declare global {
|
||||
}
|
||||
|
||||
/* https://stackoverflow.com/a/50636286 */
|
||||
export function arrayPartition<T>(array: T[], filter: (elem: T) => boolean): [T[], T[]] {
|
||||
const pass: T[] = [],
|
||||
fail: T[] = [];
|
||||
array.forEach((e) => (filter(e) ? pass : fail).push(e));
|
||||
return [pass, fail];
|
||||
}
|
||||
|
||||
export function arrayRemove<T>(this: T[], item: T): void {
|
||||
const index = this.indexOf(item);
|
||||
|
||||
Reference in new issue
Block a user