MCPcopy Create free account
hub / github.com/Effect-TS/effect / compact

Function compact

packages/effect/src/Chunk.ts:1104–1112  ·  view source on GitHub ↗
(self: Chunk<Option<A>>)

Source from the content-addressed store, hash-verified

1102 * @since 2.0.0
1103 */
1104export const compact = <A>(self: Chunk<Option<A>>): Chunk<A> => {
1105 const out: Array<A> = []
1106 for (const option of self) {
1107 if (O.isSome(option)) {
1108 out.push(option.value)
1109 }
1110 }
1111 return fromArrayUnsafe(out)
1112}
1113
1114/**
1115 * Applies a function to each element in a chunk and returns a new chunk containing the concatenated mapped elements.

Callers

nothing calls this directly

Calls 2

fromArrayUnsafeFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected