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

Function loop

packages/effect/src/unstable/encoding/Msgpack.ts:154–184  ·  view source on GitHub ↗
(chunk: Arr.NonEmptyReadonlyArray<Uint8Array<ArrayBuffer>>)

Source from the content-addressed store, hash-verified

152 )
153
154 function loop(chunk: Arr.NonEmptyReadonlyArray<Uint8Array<ArrayBuffer>>): Pull.Pull<
155 Arr.NonEmptyReadonlyArray<unknown>,
156 IE | MsgPackError,
157 Done
158 > {
159 const out = Arr.empty<unknown>()
160 for (let i = 0; i < chunk.length; i++) {
161 let buf = chunk[i]
162 if (incomplete !== undefined) {
163 const prev = buf
164 buf = new Uint8Array(incomplete.bytes.length + buf.length)
165 buf.set(incomplete.bytes)
166 buf.set(prev, incomplete.bytes.length)
167 incomplete = undefined
168 }
169 try {
170 out.push(...unpackr.unpackMultiple(buf))
171 } catch (cause) {
172 const error: any = cause
173 if (error.incomplete) {
174 incomplete = { bytes: buf.subarray(error.lastPosition), cause }
175 if (error.values) {
176 out.push(...error.values)
177 }
178 } else {
179 return Effect.fail(new MsgPackError({ kind: "Unpack", cause }))
180 }
181 }
182 }
183 return Arr.isReadonlyArrayNonEmpty(out) ? Effect.succeed(out) : pull
184 }
185
186 return pull
187 })

Callers

nothing calls this directly

Calls 4

pushMethod · 0.80
setMethod · 0.65
failMethod · 0.45
succeedMethod · 0.45

Tested by

no test coverage detected