https://github.com/131/stream-split
Stream split transform
https://github.com/131/stream-split
Last synced: about 1 year ago
JSON representation
Stream split transform
- Host: GitHub
- URL: https://github.com/131/stream-split
- Owner: 131
- Created: 2015-09-20T13:24:29.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-28T22:32:41.000Z (over 9 years ago)
- Last Synced: 2024-06-19T02:05:00.852Z (almost 2 years ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Split stream
A very efficient stream splitter (using buffer delimiters)
Generate a duplex stream (transform) that split your stream into controlled chunks
[](https://travis-ci.org/131/stream-split)
[](https://coveralls.io/github/131/stream-split?branch=master)
[](https://www.npmjs.com/package/stream-split)
# Api
```
var Split = require('stream-split');
var splitter = new Split(buffer_separator[, options]);
//target will receive "buffer_separator" separated chunks
somestream.pipe(splitter).pipe(target);
var options = {
//bufferSize : internal buffer size (default to 1 Mb)
};
```
## Options
* bufferSize
`stream-split` use efficiant buffer copy policy (instead of merging/concat temporary chunk).
This value is an indication on what the working page size might be.
If needed, this value WILL change according to data.
# Example
```
const Split = require('stream-split');
const splitter = new Split(new Buffer("\r\n"));
splitter.on("data", function(){
//got chunk
});
splitter.write("ok");
splitter.write("\r\n"); //got chunk
splitter.write("ok");
```
# Tests
```
npm test
```
Run tests for mocha result & istanbul (100%) coverage