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

bl

Package Overview
Dependencies
Maintainers
2
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bl

Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!

  • 2.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
36M
increased by2.45%
Maintainers
2
Weekly downloads
 
Created

What is bl?

The 'bl' (Buffer List) npm package is a utility that provides a storage mechanism for Node.js Buffer data. It allows for the collection of Buffer objects, and provides a way to access the combined data as a single contiguous Buffer or a stream. It is useful for handling streams of binary data and can simplify the process of collecting and manipulating this data.

What are bl's main functionalities?

Collecting stream data

This code sample demonstrates how to collect data from an HTTP response stream and convert it to a string once the stream ends.

const { BufferList } = require('bl');
const bl = new BufferList();
require('http').get('http://example.com', (res) => {
  res.pipe(bl);
  res.on('end', () => {
    console.log(bl.toString());
  });
});

Appending buffers and strings

This code sample shows how to append both strings and Buffer objects to a BufferList instance, and then convert the entire list to a string.

const { BufferList } = require('bl');
const bl = new BufferList();
bl.append('first string ');
bl.append(Buffer.from('second string'));
console.log(bl.toString());

Random access to data

This code sample illustrates how to perform random access on the data within a BufferList by using the slice method to retrieve a portion of the data.

const { BufferList } = require('bl');
const bl = new BufferList();
bl.append('hello ');
bl.append('world');
console.log(bl.slice(0, 5).toString()); // 'hello'

Duplex stream compatibility

This code sample demonstrates how BufferList can be used as a duplex stream, where data piped into it can be manipulated and then piped out to another destination.

const { BufferListStream } = require('bl');
const blStream = new BufferListStream();
process.stdin.pipe(blStream).pipe(process.stdout);

Other packages similar to bl

Keywords

FAQs

Package last updated on 08 Oct 2018

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