New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bufferstream

Package Overview
Dependencies
Maintainers
0
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bufferstream - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

example/split.js

2

package.json
{ "name": "bufferstream"
, "description": "painless stream buffering and cutting"
, "version": "0.1.1"
, "version": "0.1.2"
, "homepage": "https://github.com/dodo/node-bufferstream"

@@ -5,0 +5,0 @@ , "author": "dodo (https://github.com/dodo)"

@@ -0,2 +1,80 @@

# BufferStream
painless stream buffering, cutting and piping.
## install
npm install bufferstream
## api
BufferStream is a full node.js [Stream](http://nodejs.org/docs/v0.4.7/api/streams.html) so it has apis of both [Writeable Stream](http://nodejs.org/docs/v0.4.7/api/streams.html#writable_Stream) and [Readable Stream](http://nodejs.org/docs/v0.4.7/api/streams.html#readable_Stream).
### BufferStream
stream = new BufferStream([encoding])
* `encoding` default encoding for writing strings
### stream.enable
stream.enable()
enables stream buffering __default__
### stream.disable
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
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.
### Event: 'split'
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.
### stream.getBuffer
stream.getBuffer()
// or just
stream.buffer
returns its [Buffer](http://nodejs.org/docs/v0.4.7/api/buffers.html).
### stream.toString
stream.toString()
shortcut for `stream.buffer.toString()`
## example
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
* https://github.com/dodo/node-bufferstream/blob/master/example/split.js

Sorry, the diff of this file is not supported yet

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