highland-repartition
Repartition a highland stream on your own criteria. This module helps you with partitioning strings into lines, arrays into subarrays etc., theoretically anything as long as you can supply a function that splits and one that concatenates.
Install
npm install highland-repartition
Examples:
var _ = var repartition = // =>// Often Guests forget their things,// Leave their hats, their coats and rings,// Other people leave their stains,// Leave their shadows leave their pains
Note that this works even on the 3rd line, where the pattern is split apart. This is because every non-matching part will concatenated and fed into the splitter until it is matched.
To work on arbitrary input streams, the concatenating operator also has to be supplied.
Let's see a bit more complicated example:
var _ = var repartition = // =>// [// [1, 2, 3, 4, 5],// [1, 2, 3, 4, 5, 6],// [1, 2, 3, 4],// [1]// ]
Usage
repartition(split, concatenate)
Accepts a split
and a concatenate
function (both required), and returns a highland
stream.
-
split
should accept an stream element and return a highland stream of elements. -
concatenate
should accept two stream elements and return one stream element.
Contributors
@szdavid92 - David Szakallas
License
Copyright (c) 2016 David Szakallas
MIT License