Comparing version 1.4.1 to 1.4.2
13
index.js
@@ -1,4 +0,4 @@ | ||
const readAsBuffer = (s, maxsize=1e7) => | ||
const readAsBuffer = (s, maxsize = 1e7) => | ||
new Promise((resolve, reject) => { | ||
if (Buffer.isBuffer(s) || Array.isArray(s) || typeof s == 'string') { | ||
if (Buffer.isBuffer(s) || Array.isArray(s) || typeof s === 'string') { | ||
return resolve(Buffer.from(s)); | ||
@@ -15,3 +15,3 @@ } | ||
err.status = 413; | ||
return reject(err); | ||
reject(err); | ||
} | ||
@@ -25,8 +25,9 @@ }); | ||
function onEnd(err) { | ||
if (err) reject(err); | ||
else resolve(s._readableState && s._readableState.objectMode ? bufs : Buffer.concat(bufs)); | ||
if (err) { | ||
return reject(err); | ||
} | ||
resolve(s._readableState && s._readableState.objectMode ? bufs : Buffer.concat(bufs)); | ||
} | ||
}); | ||
module.exports = readAsBuffer; |
{ | ||
"name": "as-buffer", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "stream or anything to buffer as a Promise", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
## Read stream as buffer\* | ||
## Read stream and other types as buffer\* | ||
[![npm version][npm-image]][npm-url] | ||
@@ -3,0 +3,0 @@ [![build status][travis-image]][travis-url] |
2294
27