segmenter

To segment a set of chunks from strings or streams

Segmenter for NodeJS

To segment a set of chunks from strings or streams

Installation

With npm do:

$ npm install segmenter

Examples

var Segmenter = require('segmenter'),
seg = new Segmenter({ delimiter: "." });
 
    seg.fecth('a.b.c.');

Output:

[ 'a', 'b', 'c' ]
var seg = new Segmenter(),
readStream = require('fs').createReadStream('dataset.txt'),
res = [];
 
readStream.on('data', function (chunk) {
res = res.concat(seg.fetch(chunk));
    });
    readStream.on('end', function () {
console.log('Array of lines', lines);
});
 

Output:

[ 'Line 1', 'Line 2', 'etc.', ... ]

Tests

Use mocha to run the tests.

$ npm install mocha
$ mocha test

API Documentation

Create the object.

Options are :

  • delimiter - String : Char or String that separe the segments. Default : \n

Fetch segments in a String.

Fetch segments in a Buffer.

Also

License

MIT/X11