()
| 395 | }, |
| 396 | |
| 397 | textStream () { |
| 398 | const this_ = getInternalState(this) |
| 399 | |
| 400 | // 1. If this is unusable, then throw a TypeError. |
| 401 | if (bodyUnusable(this_)) { |
| 402 | throw new TypeError('Body is unusable: Body has already been read') |
| 403 | } |
| 404 | |
| 405 | // 2. If this’s body is null: |
| 406 | if (this_.body == null) { |
| 407 | // 2.1. Let emptyStream be a new ReadableStream in this’s relevant realm. |
| 408 | // 2.2. Set up emptyStream. |
| 409 | /** @type {ReadableStreamDefaultController<any>} */ |
| 410 | let controller |
| 411 | const emptyStream = new ReadableStream({ |
| 412 | start: (c) => { |
| 413 | controller = c |
| 414 | }, |
| 415 | pull: () => Promise.resolve(), |
| 416 | cancel: () => Promise.resolve() |
| 417 | }, { |
| 418 | size: () => 1 |
| 419 | }) |
| 420 | |
| 421 | // 2.3. Close emptyStream. |
| 422 | controller.close() |
| 423 | |
| 424 | // 2.4. Return emptyStream. |
| 425 | return emptyStream |
| 426 | } |
| 427 | |
| 428 | // 3. Let stream be this’s body’s stream. |
| 429 | /** @type {ReadableStream} */ |
| 430 | const stream = this_.body.stream |
| 431 | |
| 432 | // 4. Let decoder be a new TextDecoderStream object in this’s relevant realm. |
| 433 | // 5. Set up decoder with UTF-8. |
| 434 | const decoder = new TextDecoderStream('UTF-8') |
| 435 | |
| 436 | // 6. Return the result of stream, piped through decoder. |
| 437 | return stream.pipeThrough(decoder) |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | return methods |
nothing calls this directly
no test coverage detected