re-add partion function

This commit is contained in:
MathMan05 committed 2025-11-26 14:50:44 -06:00
1 parent aa40eee097
commit 8c9e287719
1 file changed
+6
+6
View File
@@ -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);