frontend client for gemstone. decentralised workplace app
1export const partition = <T>(
2 array: Array<T>,
3 predicate: (value: T, index: number, array: Array<T>) => boolean,
4): [Array<T>, Array<T>] => {
5 const truthy: Array<T> = [];
6 const falsy: Array<T> = [];
7
8 array.forEach((value, index, arr) => {
9 if (predicate(value, index, arr)) {
10 truthy.push(value);
11 } else {
12 falsy.push(value);
13 }
14 });
15
16 return [truthy, falsy];
17};