(array: T[], count: number, filter: (t: T) => boolean)
| 13 | |
| 14 | export const updateListSelection = <T>(t: T, ts: T[]) => (ts.includes(t) ? ts.filter((x) => x !== t) : ts.concat([t])); |
| 15 | |
| 16 | export const takeWithDefault = <T>(array: T[], length: number, fallback: T) => |
| 17 | range(length).map((i) => array[i] ?? fallback); |
| 18 | |
| 19 | export const takeWithFilter = <T>(array: T[], count: number, filter: (t: T) => boolean) => { |
| 20 | let values = []; |
| 21 | |
| 22 | for (let value of array) { |
| 23 | if (filter(value)) { |
| 24 | values.push(value); |
| 25 | if (values.length === count) break; |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | return values; |
no outgoing calls
no test coverage detected