* @param {Consume} consume * @param {BufferEncoding} encoding * @returns {void}
(consume, encoding)
| 560 | * @returns {void} |
| 561 | */ |
| 562 | function consumeEnd (consume, encoding) { |
| 563 | const { type, body, resolve, stream, length } = consume |
| 564 | |
| 565 | try { |
| 566 | if (type === 'text') { |
| 567 | resolve(chunksDecode(body, length, encoding)) |
| 568 | } else if (type === 'json') { |
| 569 | resolve(JSON.parse(chunksDecode(body, length, encoding))) |
| 570 | } else if (type === 'arrayBuffer') { |
| 571 | resolve(chunksConcat(body, length).buffer) |
| 572 | } else if (type === 'blob') { |
| 573 | resolve(new Blob(body, { type: stream[kContentType] })) |
| 574 | } else if (type === 'bytes') { |
| 575 | resolve(chunksConcat(body, length)) |
| 576 | } |
| 577 | |
| 578 | consumeFinish(consume) |
| 579 | } catch (err) { |
| 580 | stream.destroy(err) |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | /** |
| 585 | * @param {Consume} consume |
no test coverage detected
searching dependent graphs…