stream-sort

1.1.0 • Public • Published

stream-sort

NPM Version NPM Downloads Build Status Coverage Status Dependency Status

Pick the top n entries from an object-mode stream.

Install: npm install stream-sort

// Create
const sorter = require('stream-sort');
 
// Read objects from input...
const writable = input.pipe(sorter(42));
 
// Returns top 42 sorted entries, sync.
console.log(writable.get());
 
writable.on('result', (sorted) => { ... });

API:

  • sorter(count) -- count defaults to 1.
  • sorter({ count: n, compare: function(a, b) { ... }) -- compare works as for Array.prototype.sort.
  • count can be Infinity.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i stream-sort

Weekly Downloads

24

Version

1.1.0

License

MIT

Last publish

Collaborators

  • addaleax