MCPcopy Create free account
hub / github.com/Athenodoros/TopHat / takeWithFilter

Function takeWithFilter

src/shared/data.ts:15–26  ·  view source on GitHub ↗
(array: T[], count: number, filter: (t: T) => boolean)

Source from the content-addressed store, hash-verified

13
14export const updateListSelection = <T>(t: T, ts: T[]) => (ts.includes(t) ? ts.filter((x) => x !== t) : ts.concat([t]));
15
16export const takeWithDefault = <T>(array: T[], length: number, fallback: T) =>
17 range(length).map((i) => array[i] ?? fallback);
18
19export 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;

Callers 1

useTransactionsTableDataFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected