MCPcopy Create free account
hub / github.com/Snapchat/Valdi / bisectArray

Function bisectArray

valdi/vscode_debugger/src/common/objUtils.ts:263–278  ·  view source on GitHub ↗
(
  items: ReadonlyArray<T>,
  predicate: (item: T) => boolean,
)

Source from the content-addressed store, hash-verified

261 * in which the predicate returned true, the second where it returned false.
262 */
263export function bisectArray<T>(
264 items: ReadonlyArray<T>,
265 predicate: (item: T) => boolean,
266): [T[], T[]] {
267 const a: T[] = [];
268 const b: T[] = [];
269 for (const item of items) {
270 if (predicate(item)) {
271 a.push(item);
272 } else {
273 b.push(item);
274 }
275 }
276
277 return [a, b];
278}
279
280/**
281 * Flattens an array of arrays into a single-dimensional array.

Callers 1

tryUpdateLocationsMethod · 0.90

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected