bl
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
readable-stream | 2.3.8 | 25.14 kB | MIT | prod | |
safe-buffer | 5.2.1 | 9.74 kB | MIT | prod |
Buffer List (bl) is a Node.js storage object mainly designed for managing collections of Node Buffers. The package exposes these buffers with the primary Buffer readable API. Providing versatile functionality, bl can also work as a duplex stream, effectively managing the collection and emission of buffers to and from a stream that produces and consumes them, respectively. Its efficient memory management system ensures the original buffers remain intact, performing copy operations only when needed.
The usage of Buffer List (bl) is straightforward and follows the standard programming practices for JavaScript and Node.js applications.
First, you will have to install the package using npm:
npm install bl
And then, you can include bl
in your code:
const { BufferList } = require('bl')
const bl = new BufferList()
bl.append(Buffer.from('abcd'))
bl.append(Buffer.from('efg'))
bl.append('hi') // bl also accepts & converts Strings
bl.append(Buffer.from('j'))
bl.append(Buffer.from([ 0x3, 0x4 ]))
console.log(bl.length) // 12
// Using the different available methods
console.log(bl.slice(0, 10).toString('ascii')) // 'abcdefghij'
console.log(bl.indexOf('def')) // 3
You can also use it like concat-stream:
const { BufferListStream } = require('bl')
const fs = require('fs')
fs.createReadStream('README.md')
.pipe(BufferListStream((err, data) => {
console.log(data.toString())
}))
The documentation for the bl (Buffer List) npm package can be found here. The README file in the GitHub repository provides comprehensive information regarding the API and usage examples, ensuring developers can effectively incorporate bl into their projects. The code examples provided include different use cases featuring most of the API methods, enabling new users to understand the general functionality and power of bl quickly.