Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
health-star-rating
Advanced tools
Calculates the ANZ health star rating of a food/beverage product given nutritional information
Calculate the ANZ health star rating of food given nutritional information
Calculates the health star rating of foods based on Australian Government guidelines.
npm install health-star-rating
import { Attributes, Category, calculateHealthStarRating } from 'health-star-rating';
calculateHealthStarRating(Category.DairyFoods, {
totalSugarsGrams: 33,
energykJ: 1100,
sodiumMilligrams: 100,
saturatedFatGrams: 0,
});
//=> 1
calculateHealthStarRating(Category.NonDairyBeverages, {
energykJ: 0,
saturatedFatGrams: 7,
sodiumMilligrams: 400,
totalSugarsGrams: 0,
attributes: [Attributes.ContainsFruitOrVegetable],
percentageFruitVegetableNutLegume: 25,
});
//=> 4
calculateHealthStarRating(Category.OtherFoods, {
saturatedFatGrams: 10.5,
sodiumMilligrams: 400,
totalSugarsGrams: 10.5,
energykJ: 3100,
fibreGrams: 7,
});
//=> 1.5
One of the following values will be returned:
0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5
Type: Category
Category of the food. Use the most specific category possible.
These are the possible categories:
DairyBeverages
DairyFoods
FatsOilsAndSpreads
Cheese
PlainWater
UnsweetenedFlavouredWater
UnprocessedFruitAndVegetables
NonDairyBeverages
Jellies
WaterBasedIcedConfection
OtherFoods
: Any food that doesn't fit in the above categories.Type: object
Required keys:
energykJ
(int
): kilojoule content of the food per 100g or 100ml (note it's lowercase 'k' and uppercase 'J')sodiumMilligrams
(int
): sodium content in mg per 100g or 100mlsaturatedFatGrams
(float
): saturated fat in grams per 100g or 100mltotalSugarsGrams
(float
): sugar content in grams per 100g or 100mlOptional keys:
percentageFruitVegetableNutLegume
(int
): Percentage from 0-100 of fruit, vegetable, nut or legume content. Improves the health star rating. Use with the attributes
value set.fibreGrams
(float
): dietary fibre content in grams per 100g or 100ml. Improves health star ratingproteinGrams
(float
): protein content in grams per 100g or 100ml. Improves health star ratingattributes
(Attributes[]
): If the food contains either non-concentrated fruit/vegetable/nuts/legumes sources or concentrated fruits or vegetables. percentageFruitVegetableNutLegume
must be set if using thisAttributes
Attributes of the food, such as whether the food contains non-concentrated fruit/vegetable/nuts/legumes sources or concentrated fruits or vegetables.
Possible values:
ContainsFruitOrVegetable
ContainsNutsOrLegumes
The calculations and health star rating information is taken from the https://healthstarrating.gov.au website
FAQs
Calculates the ANZ health star rating of a food/beverage product given nutritional information
The npm package health-star-rating receives a total of 1 weekly downloads. As such, health-star-rating popularity was classified as not popular.
We found that health-star-rating demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.