mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-21 04:19:37 +02:00
import from up to date repo
This commit is contained in:
parent
35f5db62f2
commit
12baf72567
86 changed files with 12080 additions and 13746 deletions
17
client/src/utility/array.ts
Normal file
17
client/src/utility/array.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
export const arrayPartition = <T>(
|
||||
arr: T[],
|
||||
isValid: (e: T) => boolean
|
||||
): T[][] => {
|
||||
let pass: T[] = [];
|
||||
let fail: T[] = [];
|
||||
|
||||
arr.forEach((e) => (isValid(e) ? pass : fail).push(e));
|
||||
|
||||
return [pass, fail];
|
||||
};
|
||||
|
||||
export const insertAt = <T>(arr: T[], index: number, element: T): T[] => [
|
||||
...arr.slice(0, index),
|
||||
element,
|
||||
...arr.slice(index + 1),
|
||||
];
|
Loading…
Add table
Add a link
Reference in a new issue