(data)
| 8 | const HEADERS = Symbol('Response headers') |
| 9 | |
| 10 | function getString (data) { |
| 11 | if (Buffer.isBuffer(data)) { |
| 12 | return data.toString('utf8') |
| 13 | } else if (typeof data === 'string') { |
| 14 | return data |
| 15 | } else if (data instanceof Uint8Array) { |
| 16 | return new TextDecoder().decode(data) |
| 17 | } else { |
| 18 | throw new Error(`response.write() of unexpected type: ${typeof data}`) |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | function addData (stream, data) { |
| 23 | if (Buffer.isBuffer(data) || typeof data === 'string' || data instanceof Uint8Array) { |
no outgoing calls
no test coverage detected
searching dependent graphs…