group-stream
Group a sorted stream by key.
npm install group-stream
group([toKey])
A transform stream that groups objects by key.
Keys are mapped by value.key
or value
itself. Pass toKey
function for custom key mapping.
var group = var from = var stream = from stream // result key: 1 value: 1 1 key: 2 value: 2 2 key: 3 value: 3
Combine with sorted-merge-stream and custom key mapping:
var group = var merge = var from = var a = fromvar b = fromvar c = from { return dataid} // sorted merge streamvar stream = a b c // group stream, object extendstream // result key: 1 value: id: 1 a: true id: 1 b: true key: 2 value: id: 2 b: true key: 3 value: id: 3 a: true id: 3 c: true key: 5 value: id: 5 c: true key: 6 value: id: 6 a: true id: 6 b: true id: 6 c: true
License
MIT