MCPcopy Index your code
hub / github.com/Effect-TS/effect / take

Function take

packages/effect/src/internal/sink.ts:1900–1911  ·  view source on GitHub ↗
(n: number)

Source from the content-addressed store, hash-verified

1898
1899/** @internal */
1900export const take = <In>(n: number): Sink.Sink<Chunk.Chunk<In>, In, In> =>
1901 pipe(
1902 foldChunks<Chunk.Chunk<In>, In>(
1903 Chunk.empty(),
1904 (chunk) => chunk.length < n,
1905 (acc, chunk) => pipe(acc, Chunk.appendAll(chunk))
1906 ),
1907 flatMap((acc) => {
1908 const [taken, leftover] = pipe(acc, Chunk.splitAt(n))
1909 return new SinkImpl(pipe(core.write(leftover), channel.zipRight(core.succeedNow(taken))))
1910 })
1911 )
1912
1913/** @internal */
1914export const toChannel = <A, In, L, E, R>(

Callers 3

List.tsFile · 0.50
Array.tsFile · 0.50
Chunk.tsFile · 0.50

Calls 3

foldChunksFunction · 0.85
pipeFunction · 0.70
writeMethod · 0.65

Tested by

no test coverage detected