2 * Creates an array of elements split into two groups, the first of which contains elements predicate returns
3 * truthy for, the second of which contains elements predicate returns falsey for.
5 export default function partition<T, K = T>(arr: (T | K)[], predicate: (item: T | K) => item is T): [T[], K[]] {
6 const truthyItems: T[] = [];
7 const falseyItems: K[] = [];
9 for (const item of arr) {
10 if (predicate(item)) {
11 truthyItems.push(item);
13 falseyItems.push(item);
17 return [truthyItems, falseyItems];