Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

as-buffer

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

as-buffer - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

7

index.js
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');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc