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

Function doBuffer

packages/effect/src/internal/channel.ts:97–124  ·  view source on GitHub ↗
(
      empty: InElem,
      isEmpty: Predicate<InElem>,
      ref: Ref.Ref<InElem>
    )

Source from the content-addressed store, hash-verified

95): Channel.Channel<InElem, InElem, InErr, InErr, InDone, InDone> =>
96 core.suspend(() => {
97 const doBuffer = <InErr, InElem, InDone>(
98 empty: InElem,
99 isEmpty: Predicate<InElem>,
100 ref: Ref.Ref<InElem>
101 ): Channel.Channel<InElem, InElem, InErr, InErr, InDone, InDone> =>
102 unwrap(
103 Ref.modify(ref, (inElem) =>
104 isEmpty(inElem) ?
105 [
106 core.readWith({
107 onInput: (input: InElem) =>
108 core.flatMap(
109 core.write(input),
110 () => doBuffer<InErr, InElem, InDone>(empty, isEmpty, ref)
111 ),
112 onFailure: (error: InErr) => core.fail(error),
113 onDone: (done: InDone) => core.succeedNow(done)
114 }),
115 inElem
116 ] as const :
117 [
118 core.flatMap(
119 core.write(inElem),
120 () => doBuffer<InErr, InElem, InDone>(empty, isEmpty, ref)
121 ),
122 empty
123 ] as const)
124 )
125 return doBuffer(options.empty, options.isEmpty, options.ref)
126 })
127

Callers 1

bufferFunction · 0.85

Calls 5

unwrapFunction · 0.70
isEmptyFunction · 0.70
modifyMethod · 0.65
writeMethod · 0.65
failMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…