Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion __tests__/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const {
makeResponse,
EACH_MATRIX
} = require('../jest-helpers')

const jestHelpersPath = path.join(__dirname, '..', 'jest-helpers')

let app, router, serverlessExpressInstance
Expand Down
4 changes: 3 additions & 1 deletion src/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ function getString (data) {
return data.toString('utf8')
} else if (typeof data === 'string') {
return data
} else if (data instanceof Uint8Array) {
return new TextDecoder().decode(data)
} else {
throw new Error(`response.write() of unexpected type: ${typeof data}`)
}
}

function addData (stream, data) {
if (Buffer.isBuffer(data) || typeof data === 'string') {
if (Buffer.isBuffer(data) || typeof data === 'string' || data instanceof Uint8Array) {
stream[BODY].push(Buffer.from(data))
} else {
throw new Error(`response.write() of unexpected type: ${typeof data}`)
Expand Down