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

bufferstream

Package Overview
Dependencies
Maintainers
1
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.3.0 to 0.4.0

benchmark

10

example/split.js
var BufferStream = require('../bufferstream');
var stream = new BufferStream('utf8');
var stream = new BufferStream({encoding:'utf8', size:'flexible'});
console.log("stream size is", stream.size);
stream.split('//', ':');

@@ -13,3 +15,5 @@

stream.write("buffer:stream//23:42//disabled");
console.log(stream.toString());
console.log("writing stream is",
stream.write("buffer:stream//23:42//disabled") && "ok" || "failed");
console.log("stream content:", stream.toString());
{ "name": "bufferstream"
, "description": "painless stream buffering and cutting"
, "version": "0.3.0"
, "version": "0.4.0"
, "homepage": "https://github.com/dodo/node-bufferstream"

@@ -11,2 +11,3 @@ , "author": "dodo (https://github.com/dodo)"

, "scripts": {
"test": "./benchmark",
"preinstall": "#preinstall DO NOTHING",

@@ -17,3 +18,6 @@ "install": "node-waf configure build",

"buffertools": ">= 1.0.3",
"coffee-script": ">= 1.1.1"}
"coffee-script": ">= 1.1.2"}
, "devDependencies": {
"cli": ">= 0.3.7",
"express": ">= 2.4.5"}
}

@@ -17,9 +17,26 @@ # BufferStream

BufferStream = require('bufferstream')
stream = new BufferStream([encoding])
```javascript
BufferStream = require('bufferstream')
stream = new BufferStream([{encoding:'utf8', size:'none'}]) // default
```
* `encoding` default encoding for writing strings
* `size` defines buffer level or sets buffer to given size (see ↓`setSize` for more)
### stream.setSize
```javascript
stream.setSize(size) // can be one of ['none', 'flexible', <number>]
```
different buffer behaviors can be triggered by size:
* `none` when output drains, bufferstream drains too
* `flexible` buffers everthing that it gets and not piping out
* `<number>` `TODO` buffer has given size. buffers everthing until buffer is full. when buffer is full then the stream will drain
### stream.enable
stream.enable()
```javascript
stream.enable()
```

@@ -30,3 +47,5 @@ enables stream buffering __default__

stream.disable()
```javascript
stream.disable()
```

@@ -37,4 +56,6 @@ flushes buffer and disables stream buffering.

stream.disable(token, ...)
stream.disable(tokens) // Array
```javascript
stream.disable(token, ...)
stream.disable(tokens) // Array
```
* `token[s]` buffer splitters (should be String or Buffer)

@@ -46,4 +67,6 @@

stream.split(token, ...)
stream.split(tokens) // Array
```javascript
stream.split(token, ...)
stream.split(tokens) // Array
```
* `token[s]` buffer splitters (should be String or Buffer)

@@ -56,4 +79,6 @@

stream.on('split', function (chunk, token) {…})
stream.split(token, function (chunk, token) {…}) // only get called for given token
```javascript
stream.on('split', function (chunk, token) {…})
stream.split(token, function (chunk, token) {…}) // only get called for given token
```

@@ -67,5 +92,7 @@ BufferStream slices its buffer to the first position of on of the splitter tokens and emits it.

stream.getBuffer()
// or just
stream.buffer
```javascript
stream.getBuffer()
// or just
stream.buffer
```

@@ -76,3 +103,5 @@ returns its [Buffer](http://nodejs.org/docs/v0.4.7/api/buffers.html).

stream.toString()
```javascript
stream.toString()
```

@@ -83,3 +112,5 @@ shortcut for `stream.buffer.toString()`

stream.length
```javascript
stream.length
```

@@ -90,4 +121,6 @@ shortcut for `stream.buffer.length`

PostBuffer = require('bufferstream/postbuffer')
post = new PostBuffer(req)
```javascript
PostBuffer = require('bufferstream/postbuffer')
post = new PostBuffer(req)
```
* `req` http.ServerRequest

@@ -101,3 +134,5 @@

post.onEnd(function (data) {…});
```javascript
post.onEnd(function (data) {…});
```

@@ -108,10 +143,12 @@ set a callback to get all post data from a http server request

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())
```javascript
BufferStream = require('bufferstream')
stream = new BufferStream({encoding:'utf8', size:'flexible'})
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())
```

@@ -118,0 +155,0 @@ results in

Sorry, the diff of this file is not supported yet

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