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

Function foldWeightedDecomposeLoop

packages/effect/src/internal/sink.ts:1136–1167  ·  view source on GitHub ↗
(
  s: S,
  cost: number,
  dirty: boolean,
  max: number,
  costFn: (s: S, input: In) => number,
  decompose: (input: In) => Chunk.Chunk<In>,
  f: (s: S, input: In) => S
)

Source from the content-addressed store, hash-verified

1134
1135/** @internal */
1136const foldWeightedDecomposeLoop = <S, In>(
1137 s: S,
1138 cost: number,
1139 dirty: boolean,
1140 max: number,
1141 costFn: (s: S, input: In) => number,
1142 decompose: (input: In) => Chunk.Chunk<In>,
1143 f: (s: S, input: In) => S
1144): Channel.Channel<Chunk.Chunk<In>, Chunk.Chunk<In>, never, never, S, unknown> =>
1145 core.readWith({
1146 onInput: (input: Chunk.Chunk<In>) => {
1147 const [nextS, nextCost, nextDirty, leftovers] = foldWeightedDecomposeFold(
1148 input,
1149 s,
1150 cost,
1151 dirty,
1152 max,
1153 costFn,
1154 decompose,
1155 f
1156 )
1157 if (Chunk.isNonEmpty(leftovers)) {
1158 return pipe(core.write(leftovers), channel.zipRight(core.succeedNow(nextS)))
1159 }
1160 if (cost > max) {
1161 return core.succeedNow(nextS)
1162 }
1163 return foldWeightedDecomposeLoop(nextS, nextCost, nextDirty, max, costFn, decompose, f)
1164 },
1165 onFailure: core.fail,
1166 onDone: () => core.succeedNow(s)
1167 })
1168
1169/** @internal */
1170const foldWeightedDecomposeFold = <In, S>(

Callers 1

foldWeightedDecomposeFunction · 0.85

Calls 3

pipeFunction · 0.70
writeMethod · 0.65

Tested by

no test coverage detected