
Security News
Node.js TSC Votes to Stop Distributing Corepack
Corepack will be phased out from future Node.js releases following a TSC vote.
bufferstream
Advanced tools
painless stream buffering, cutting and piping.
make sure you have node-waf
installed (contained in nodejs-dev
package).
npm install bufferstream
BufferStream is a full node.js Stream so it has apis of both Writeable Stream and Readable Stream.
stream = new BufferStream([encoding])
encoding
default encoding for writing stringsstream.enable()
enables stream buffering default
stream.disable()
flushes buffer and disables stream buffering. BufferStream now pipes all data as long as the output accepting data. when the output is draining BufferStream will buffer all input temporary.
stream.split(token, ...)
stream.split(tokens) // Array
token[s]
buffer splitters (should be String or Buffer)each time BufferStream finds a splitter token in the input data it will emit a split event. this also works for binary data.
stream.on('split', function (chunk, token) {…})
stream.split(token, function (chunk, token) {…}) // only get called for given token
BufferStream slices its buffer to the first position of on of the splitter tokens and emits it. this data will be lost when not handled.
Warning: try to avoid calling stream.emit('data', newchunk)
more than one time, because this will likely throw Error: Offset is out of bounds
.
stream.getBuffer()
// or just
stream.buffer
returns its Buffer.
stream.toString()
shortcut for stream.buffer.toString()
stream.length
shortcut for stream.buffer.length
BufferStream = require('bufferstream')
stream = new BufferStream('utf8')
stream.split('//', ':')
stream.on('split', function (chunk, token) {
console.log("got '%s' by '%s'", chunk.toString(), token.toString())
})
stream.write("buffer:stream//23")
console.log(stream.toString())
results in
got 'buffer' by ':'
got 'stream' by '//'
23
FAQs
painless stream buffering and cutting
The npm package bufferstream receives a total of 534 weekly downloads. As such, bufferstream popularity was classified as not popular.
We found that bufferstream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.
Research
Security News
Research uncovers Black Basta's plans to exploit package registries for ransomware delivery alongside evidence of similar attacks already targeting open source ecosystems.
Security News
Oxlint's beta release introduces 500+ built-in linting rules while delivering twice the speed of previous versions, with future support planned for custom plugins and improved IDE integration.