1.0.0 • Published 3 years ago

nutriscore-2022 v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Nutriscore calculator

This is a calculator for the Nutriscore, a French nutrition label.

Nutriscore

Installation

The package is available on NPM

Require or import the package

const nutriscore = require('nutriscore');

Usage

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 "%".
  • All values are required, if you don't have a value, you need to put 0.

Sources

Nutriscore