stream-sort
Pick the top n
entries from an object-mode stream.
Install:
npm install stream-sort
// Createconst sorter = ; // Read objects from input...const writable = input; // Returns top 42 sorted entries, sync.console; writable;
API:
sorter(count)
--count
defaults to 1.sorter({ count: n, compare: function(a, b) { ... })
--compare
works as forArray.prototype.sort
.count
can beInfinity
.
License
MIT