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

Function onSuccess

packages/effect/src/Stream.ts:7705–7726  ·  view source on GitHub ↗
(arr)

Source from the content-addressed store, hash-verified

7703 E | Cause.Done
7704 > = Effect.matchCauseEffect(upstream, {
7705 onSuccess(arr) {
7706 MutableList.appendAllUnsafe(list, arr)
7707 if (skip > 0) {
7708 const length = list.length
7709 MutableList.takeNVoid(list, skip)
7710 skip = Math.max(0, skip - length)
7711 }
7712 if (list.length < windowSize) return pull
7713 emitted = true
7714 const chunks = [] as any as Arr.NonEmptyArray<Arr.NonEmptyReadonlyArray<A>>
7715 while (list.length >= windowSize) {
7716 if (windowSize === step) {
7717 chunks.push(MutableList.takeN(list, windowSize) as any)
7718 } else {
7719 chunks.push(MutableList.toArrayN(list, windowSize) as any)
7720 const length = list.length
7721 MutableList.takeNVoid(list, step)
7722 skip = Math.max(0, step - length)
7723 }
7724 }
7725 return Effect.succeed(chunks)
7726 },
7727 onFailure(cause_) {
7728 // The buffer has already advanced by step after a full window.
7729 if (list.length === 0 || (emitted && list.length <= windowSize - step)) return Effect.failCause(cause_)

Callers 1

Result.tsFile · 0.70

Calls 3

pushMethod · 0.65
takeNMethod · 0.65
succeedMethod · 0.45

Tested by

no test coverage detected