Skip to content

Commit

Permalink
Added support for abstract streams (#299)
Browse files Browse the repository at this point in the history
* feat(streams): Support abstract streams not inherited from Stream.

* Take advantage of is-stream

* Bumped lockfile

* Also accept normal streams
  • Loading branch information
mikeal authored and leo committed Aug 31, 2017
1 parent 98f5f86 commit 080b159
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 61 deletions.
3 changes: 2 additions & 1 deletion lib/index.js
Expand Up @@ -5,6 +5,7 @@ const { Stream } = require('stream')
// Packages
const getRawBody = require('raw-body')
const typer = require('media-typer')
const { readable } = require('is-stream')

const { NODE_ENV } = process.env
const DEV = NODE_ENV === 'development'
Expand Down Expand Up @@ -42,7 +43,7 @@ const send = (res, code, obj = null) => {
return
}

if (obj instanceof Stream) {
if (obj instanceof Stream || readable(obj)) {
if (!res.getHeader('Content-Type')) {
res.setHeader('Content-Type', 'application/octet-stream')
}
Expand Down
119 changes: 59 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -56,6 +56,7 @@
"xo": "0.18.2"
},
"dependencies": {
"is-stream": "1.1.0",
"media-typer": "0.3.0",
"mri": "1.1.0",
"raw-body": "2.3.0"
Expand Down

0 comments on commit 080b159

Please sign in to comment.