Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/max-mapper/binary-split
a fast newline (or any delimiter) splitter stream - like require('split') but specific for binary data
https://github.com/max-mapper/binary-split
Last synced: 28 days ago
JSON representation
a fast newline (or any delimiter) splitter stream - like require('split') but specific for binary data
- Host: GitHub
- URL: https://github.com/max-mapper/binary-split
- Owner: max-mapper
- License: bsd-2-clause
- Created: 2013-09-07T12:56:33.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-12-03T13:32:08.000Z (12 months ago)
- Last Synced: 2024-05-19T22:12:22.014Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 59.6 KB
- Stars: 77
- Watchers: 4
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# binary-split
Split streams of binary data. Similar to [split](http://npmjs.org/split) but for Buffers.
Whereas split is String specific, this library never converts binary data into non-binary data.[![travis][travis-image]][travis-url]
[travis-image]: https://img.shields.io/travis/maxogden/binary-split.svg?style=flat
[travis-url]: https://travis-ci.org/maxogden/binary-split## How fast is it?
On a SSD w/ a Haswell i5 1.3ghz CPU and 4GB RAM reading a 2.6GB, 5.2 million entry line delimited JSON file takes 15 seconds. Using `split` for the same benchmark takes 1m23s.
## Example usage
```js
const split = require('binary-split')fs.createReadStream('log.txt')
.pipe(split())
.on('data', line => console.log(line))
```## API
#### split([splitOn])
Returns a stream.
You can `.pipe` other streams to it or `.write` them yourself
(if you `.write` don't forget to `.end`).The stream will emit a stream of binary objects representing the split data.
Pass in the optional `splitOn` argument to specify where to split the data.
The default is your current operating systems EOL sequence (via `require('os').EOL`).For more examples of usage see `test.js`.
## Collaborators
binary-split is only possible due to the excellent work of the following collaborators:
- Max Ogden ([@maxogden](https://github.com/maxogden))
- Vladimir Agafonkin ([@mourner](https://github.com/mourner))
- Martin Raifer ([@tyrasd](https://github.com/tyrasd))
- Julian Gruber ([@juliangruber](https://github.com/juliangruber))