nutriscore-2022
Version:
51 lines (37 loc) • 1.43 kB
Markdown
# Nutriscore calculator
This is a calculator for the Nutriscore, a French nutrition label.

## Installation
The package is available on NPM
Require or import the package
```js
const nutriscore = require('nutriscore');
```
## Usage
```js
const nutriscore = require('nutriscore');
const nutriments = {
energy: 1000, // in kJ
saturatedFats: 1, // in g
sugar: 10, // in g
fibers: 2, // in g
proteins: 7, // in g
sodium: 0.1, // in g
fruitsPercentage: 40, // in %
};
const score = nutriscore.default(nutriments);
console.log(score); /*
Object {
nutriscore: "A",
logoNutriscore: "https://raw.githubusercontent.com/openfoodfacts/openfoodfacts-server/master/html/images/misc/nutriscore-a.svg"
}
*/
```
## Information
- Energy is in kJ, is you want to use kcal, you need to divide by ```4.184```.
- Fibers, proteins, saturated fats, sodium and sugar are on "g" (grams).
- Fruits percentage is on "%".
- <span style="color:red">All values are required, if you don't have a value, you need to put 0</span>.
## Sources
- [Nutriscore](https://fr.openfoodfacts.org/nutriscore)
