MCPcopy Index your code
hub / github.com/nodejs/node / BodyReadable

Class BodyReadable

deps/undici/src/lib/api/readable.js:26–332  ·  view source on GitHub ↗

* @class * @extends {Readable} * @see https://fetch.spec.whatwg.org/#body

Source from the content-addressed store, hash-verified

24 * @see https://fetch.spec.whatwg.org/#body
25 */
26class BodyReadable extends Readable {
27 /**
28 * @param {object} opts
29 * @param {(this: Readable, size: number) => void} opts.resume
30 * @param {() => (void | null)} opts.abort
31 * @param {string} [opts.contentType = '']
32 * @param {number} [opts.contentLength]
33 * @param {number} [opts.highWaterMark = 64 * 1024]
34 */
35 constructor ({
36 resume,
37 abort,
38 contentType = '',
39 contentLength,
40 highWaterMark = 64 * 1024 // Same as nodejs fs streams.
41 }) {
42 super({
43 autoDestroy: true,
44 read: resume,
45 highWaterMark
46 })
47
48 this._readableState.dataEmitted = false
49
50 this[kAbort] = abort
51
52 /** @type {Consume | null} */
53 this[kConsume] = null
54
55 /** @type {number} */
56 this[kBytesRead] = 0
57
58 /** @type {ReadableStream|null} */
59 this[kBody] = null
60
61 /** @type {boolean} */
62 this[kUsed] = false
63
64 /** @type {string} */
65 this[kContentType] = contentType
66
67 /** @type {number|null} */
68 this[kContentLength] = Number.isFinite(contentLength) ? contentLength : null
69
70 /**
71 * Is stream being consumed through Readable API?
72 * This is an optimization so that we avoid checking
73 * for 'data' and 'readable' listeners in the hot path
74 * inside push().
75 *
76 * @type {boolean}
77 */
78 this[kReading] = false
79 }
80
81 /**
82 * @param {Error|null} err
83 * @param {(error:(Error|null)) => void} callback

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…