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

Function compact

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

Source from the content-addressed store, hash-verified

1155 * @since 2.0.0
1156 */
1157export const compact = <A>(self: Chunk<Option<A>>): Chunk<A> => {
1158 const out: Array<A> = []
1159 for (const option of self) {
1160 if (O.isSome(option)) {
1161 out.push(option.value)
1162 }
1163 }
1164 return fromArrayUnsafe(out)
1165}
1166
1167/**
1168 * 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.65

Tested by

no test coverage detected