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

Function mapper

packages/effect/test/Channel/reading.test.ts:16–28  ·  view source on GitHub ↗
(
  f: (a: A) => B
)

Source from the content-addressed store, hash-verified

14import * as Ref from "effect/Ref"
15
16export const mapper = <A, B>(
17 f: (a: A) => B
18): Channel.Channel<B, A, never, unknown, void, unknown> => {
19 return Channel.readWith({
20 onInput: (a: A) =>
21 Channel.flatMap(
22 Channel.write(f(a)),
23 () => mapper(f)
24 ),
25 onFailure: () => Channel.void,
26 onDone: () => Channel.void
27 })
28}
29
30export const refWriter = <A>(
31 ref: Ref.Ref<ReadonlyArray<A>>

Callers 1

reading.test.tsFile · 0.85

Calls 2

fFunction · 0.70
writeMethod · 0.65

Tested by

no test coverage detected