buffed
Acts as a stream to send a buffer, gather a buffer, or both.
Install
npm install --save buffed
Usage
Show:
- using it as a source (a Readable with buffer content)
- using it as a sink (a Writable collecting buffer chunks)
- as both a source and a sink at once
- getting its class
- resetting an instance with a new buffer (to use as a source)
- resetting an instance with
pipe(buffer)
(to use as a source)
var buffer = getSomeBuffer()
var buffed = require('buffed')(buffer)
buffed.pipe(anotherStream)
var Buffed = require('buffed')
Buffed(buffer).pipe(anotherStream)
Buffed.pipe(buffer).pipe(anotherStream)
var Buffed = require('buffed')
var sink = Buffed()
var sink = require('buffed')()
sink.on('finish', function() {
console.log('collected buffers:',sink.buffers)
console.log('as single buffer:', sink.combine())
})
anotherStream.pipe(sink)
var buffed = require('buffed')(buffer)
buffed.on('finish', function() {
console.log('collected buffers:',sink.buffers)
console.log('as single buffer:', sink.combine())
})
buffed.pipe(anotherStream).pipe(buffed)
var buffed = require('buffed')
var source = buffed(buffer)
var sink = buffed()
sink.on('finish', function() {
console.log('collected buffers:',sink.buffers)
console.log('as single buffer:', sink.combine())
})
source.pipe(anotherStream).pipe(sink)
var Buffed = require('buffed').Buffed
var source = new Buffed(buffer)
var sink = new Buffed
var buffed = require('buffed')(buffer)
buffed.on('finish', function() {
console.log('collected buffers:',sink.buffers)
console.log('as single buffer:', sink.combine())
buffed.reset(getNewBuffer()).pipe(differentStream).pipe(buffed)
buffed.pipe(getNewBuffer()).pipe(differentStream).pipe(buffed)
})
buffed.pipe(anotherStream).pipe(buffed)
import Buffed from 'buffed'
const source = new Buffed(buffer)
const sink = new Buffed()
source.pipe(anotherStream).pipe(sink)
sink.on('finish', () =>
console.log('collected buffers:',sink.buffers)
console.log('as single buffer:', sink.combine())
)