MCPcopy Create free account
hub / github.com/contentlayerdev/contentlayer / partition

Function partition

packages/@contentlayer/utils/src/index.ts:47–62  ·  view source on GitHub ↗
(
  arr: T[],
  isLeft: (_: T) => _ is TLeft,
)

Source from the content-addressed store, hash-verified

45}
46
47export const partition = <T, TLeft extends T>(
48 arr: T[],
49 isLeft: (_: T) => _ is TLeft,
50): [TLeft[], Exclude<T, TLeft>[]] => {
51 return arr.reduce(
52 (acc, el) => {
53 if (isLeft(el)) {
54 acc[0]!.push(el)
55 } else {
56 acc[1]!.push(el as Exclude<T, TLeft>)
57 }
58 return acc as any
59 },
60 [[], []] as [TLeft[], Exclude<T, TLeft>[]],
61 )
62}
63
64export const not =
65 <T, TGuarded extends T>(guard: (_: T) => _ is TGuarded) =>

Callers 2

provideSchemaFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…