Comparing version 1.3.0 to 1.4.0
const readAsBuffer = (s, maxsize=1e7) => | ||
new Promise((resolve, reject) => { | ||
if (Buffer.isBuffer(s) || typeof s == 'string') { | ||
if (Buffer.isBuffer(s) || Array.isArray(s) || typeof s == 'string') { | ||
return resolve(Buffer.from(s)); | ||
} | ||
if (Array.isArray(s)) { | ||
return resolve(Buffer.concat(s.map(Buffer.from))); | ||
} | ||
@@ -34,2 +31,2 @@ const bufs = []; | ||
module.exports = readAsBuffer; | ||
module.exports = readAsBuffer; |
{ | ||
"name": "as-buffer", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "stream or anything to buffer as a Promise", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -36,5 +36,5 @@ const read = require('../'); | ||
console.log(' - read Array'); | ||
const a = ['test', Buffer.from('hello')]; | ||
const a = [12, 45, 255, 560, 1, 1, 0]; | ||
const buf4 = await read(a); | ||
assert.equal(buf4.toString(), 'testhello'); | ||
assert.equal(buf4.toString(), Buffer.from(a)); | ||
@@ -41,0 +41,0 @@ console.log(' - read Buffer'); |
3276
62