# Installation

Use npm command in order to install bh-scoring:

```bash
npm install [--save] bh-scoring
```

# bh-scoring

The bh-scoring module allows to easily compute a score from numeric samples and specific criterias.

By default it uses a min/max criteria; so for the following samples (0, 5, 10, 15, 20) it gives:

  - 0 -> 0
  - 5 -> 25
  - 10 -> 50
  - 15 -> 75
  - 20 -> 100

# Usage example:

## Using default score computation method

```js
const Assert = require('assert');
const BHScoring = require('bh-scoring');

var scores = new BHScoring();

scores
  .setSamples([[10], [20], [30]])
  .addCriteria(0, 1)
  .populate()
;

Assert.equal([0, 0], scores.getWorst());
Assert.equal([2, 100], scores.getBest());
```

Note on "addCriteria": here it adds a criteria of weight "1" on sample value "0"

## Using custom computation method

```js
const Assert = require('assert');
const BHScoring = require('bh-scoring');

var scores = new BHScoring();

scores
  .setSamples([[0], [1]])
  .addCriteria(0, 1, (value) => {
    return value * 100;
  })
  .populate()
;

Assert.equal([0, 0], scores.getWorst());
Assert.equal([1, 100], scores.getBest());
```
