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

Function onData

packages/platform/node-shared/src/NodeStream.ts:331–348  ·  view source on GitHub ↗
(chunk: string | Uint8Array)

Source from the content-addressed store, hash-verified

329 }
330 })
331 function onData(chunk: string | Uint8Array) {
332 if (typeof chunk === "string") {
333 string += chunk
334 bytes += Buffer.byteLength(chunk, decodes ? encoding : "utf8")
335 } else {
336 string += decoder.write(chunk)
337 bytes += chunk.byteLength
338 }
339 if (maxBytesNumber !== undefined && bytes > maxBytesNumber) {
340 stream.off("data", onData)
341 if (options?.destroyOnOverflow === false) {
342 drainReadable(stream, cleanup)
343 } else {
344 destroyReadable(stream, cleanup)
345 }
346 resume(Effect.fail(onError(new MaxBytesError(maxBytesNumber)) as E))
347 }
348 }
349 stream.on("data", onData)
350 return Effect.sync(() => {
351 stream.off("data", onData)

Callers

nothing calls this directly

Calls 8

drainReadableFunction · 0.85
byteLengthMethod · 0.80
fromMethod · 0.80
onErrorFunction · 0.70
writeMethod · 0.65
failMethod · 0.65
pushMethod · 0.65
resumeFunction · 0.50

Tested by

no test coverage detected