rankerjs
v0.0.1
Published
An npm package to rank data and return the top n results in an array with the highest ranked items first
Downloads
5
Maintainers
Readme
Rankerjs
A light weight NPM module to rank data.
Installation
Use the package manager npm to install rankerjs.
npm i rankerjs
Usage
const ranker = require('rankerjs');
returns []
ranker({ useTestData: true })
returns [
{ name: 'test-1', rating: 100, rank: 1 },
{ name: 'test-2', rating: 50, rank: 2, tie: true },
{ name: 'test-3', rating: 50, rank: 2, tie: true }
]
const testData = [
{ name: 'test-1', rating: 100 },
{ name: 'test-2', rating: 50 },
{ name: 'test-3', rating: 50 },
];
ranker({ data: testData, key: 'rating' });
//Additional fields:
//rank:number, tie: boolean
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
[MIT](https://choosealicense.com/licenses/mit/)