diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-04-11 13:20:09 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-11 13:20:09 +1000 |
commit | f040caa712567ddd01f55bb3a9227f7be350b726 (patch) | |
tree | f7575e45db55e0b799ca9bce9df3c05bdc75fdc9 /src/util | |
parent | Merge pull request #1025 from ochen1/patch-2 (diff) | |
parent | Add erkins note (diff) | |
download | server-f040caa712567ddd01f55bb3a9227f7be350b726.tar.xz |
Merge pull request #1026 from ochen1/patch-3
Add support for Discord's new endpoints to update roles
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/util/Array.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util/util/Array.ts b/src/util/util/Array.ts index 8a141340..082ac307 100644 --- a/src/util/util/Array.ts +++ b/src/util/util/Array.ts @@ -21,3 +21,11 @@ export function containsAll(arr: unknown[], target: unknown[]) { return target.every((v) => arr.includes(v)); } + +/* https://stackoverflow.com/a/50636286 */ +export function partition<T>(array: T[], filter: (elem: T) => boolean) { + const pass: T[] = [], + fail: T[] = []; + array.forEach((e) => (filter(e) ? pass : fail).push(e)); + return [pass, fail]; +} |