Socket
Socket
Sign inDemoInstall

stream-with-known-length-to-buffer

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-with-known-length-to-buffer

Convert a Readable Stream with a known length into a Buffer


Version published
Weekly downloads
997
increased by11.27%
Maintainers
1
Weekly downloads
 
Created
Source

stream-with-known-length-to-buffer travis npm downloads javascript style guide

Convert a Readable Stream with a known length into a Buffer

Sauce Test Status

This package converts a Readable Stream into a Buffer, with just one Buffer allocation (excluding allocations done internally by the streams implementation).

This is lighter-weight choice than stream-to-array when the total stream length is known in advance. This whole package is 15 lines.

This module is used by WebTorrent.

install

npm install stream-with-known-length-to-buffer

usage

var toBuffer = require('stream-with-known-length-to-buffer')

toBuffer(fs.createReadStream('file.txt'), 1000, function (err, buf) {
  if (err) return console.error(err.message)
  console.log(buf)
})

license

MIT. Copyright (c) Feross Aboukhadijeh.

Keywords

FAQs

Package last updated on 17 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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