MCPcopy
hub / github.com/tldraw/tldraw / partition

Function partition

packages/utils/src/lib/array.ts:195–206  ·  view source on GitHub ↗
(arr: T[], predicate: (item: T) => boolean)

Source from the content-addressed store, hash-verified

193 * @internal
194 */
195export function partition<T>(arr: T[], predicate: (item: T) => boolean): [T[], T[]] {
196 const satisfies: T[] = []
197 const doesNotSatisfy: T[] = []
198 for (const item of arr) {
199 if (predicate(item)) {
200 satisfies.push(item)
201 } else {
202 doesNotSatisfy.push(item)
203 }
204 }
205 return [satisfies, doesNotSatisfy]
206}
207
208/**
209 * Check if two arrays are shallow equal.

Callers 1

array.test.tsFile · 0.90

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…