MCPcopy Create free account
hub / github.com/nodejs/node / textStream

Function textStream

deps/undici/undici.js:6904–6926  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6902 }, instance, getInternalState);
6903 },
6904 textStream() {
6905 const this_ = getInternalState(this);
6906 if (bodyUnusable(this_)) {
6907 throw new TypeError("Body is unusable: Body has already been read");
6908 }
6909 if (this_.body == null) {
6910 let controller;
6911 const emptyStream = new ReadableStream({
6912 start: /* @__PURE__ */ __name((c) => {
6913 controller = c;
6914 }, "start"),
6915 pull: /* @__PURE__ */ __name(() => Promise.resolve(), "pull"),
6916 cancel: /* @__PURE__ */ __name(() => Promise.resolve(), "cancel")
6917 }, {
6918 size: /* @__PURE__ */ __name(() => 1, "size")
6919 });
6920 controller.close();
6921 return emptyStream;
6922 }
6923 const stream = this_.body.stream;
6924 const decoder = new TextDecoderStream("UTF-8");
6925 return stream.pipeThrough(decoder);
6926 }
6927 };
6928 return methods;
6929 }

Callers

nothing calls this directly

Calls 5

__nameFunction · 0.85
pipeThroughMethod · 0.80
bodyUnusableFunction · 0.70
closeMethod · 0.65
resolveMethod · 0.45

Tested by

no test coverage detected