npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

recipe-nutritional-profile-calculator

v1.0.7

Published

A recipe nutritional calculator

Downloads

22

Readme

Recipe Nutritional Profile Calculator

Based on the USDA api This package will only work with usda objects and any other object passed in as a nutrientProfile value will throw error!

How to get nutrient profile of an ingredient from usda api:

basic api call:-- https://api.nal.usda.gov/fdc/v1/foods/search?query=${ingredient_name}&api_key=${your_key}

to get an api key:-- https://fdc.nal.usda.gov/api-key-signup.html

For more information please visit the usda website: https://fdc.nal.usda.gov/api-spec/fdc_api.html#/

How to require the module

const getNutriProfile = require('recipe-nutritional-profile-calculator');

How to pass an ingredients list object:

Pass the USDA object as value to the "nutrientProfile" key as shown below

Units accepted are mentioned below

"mcg", "mg", "g", "kg", "oz", "lb", "ml", "l", "tsp", "Tbs", "cup", "ug",

Users can provide units of the ingredients from the above list which will then be converted to "g" for solids and "ml" for liquids for further calculations.

const ingredientsList = [
  {
    name: "MILK",
    quantity: 200,
    unit: "ml",
    nutrientProfile: {
      // ... usda object
    },
  },
  {
    name: "JAGGERY",
    quantity: 10,
    unit: "g",
    nutrientProfile: {
      // ... usda object
    },
  },
  {
    name: "OATS",
    quantity: 60,
    unit: "g",
    userInputed: "true",
    nutrientProfile: {
      // ... usda object
    },
  },
];

const nutriProfile = getNutriProfile(ingredientsList);

OUTPUT OBJECT:

nutriProfile = {
        //ENERGY IN KCAL
        totEnergy: {
            nutrientId: 1008,
            nutrientName: "Energy",
            nutrientNumber: "208",
            unitName: "KCAL",
            derivationCode: "LCCS",
            derivationDescription: "Calculated from value per serving size measure",
            value: 482.5
        },

        //TOTAL MACRO NUTRIENTS
        totMacros: [
            {
                nutrientId: 1003,
                nutrientName: "Protein",
                nutrientNumber: "203",
                unitName: "G",
                derivationCode: "LCCS",
                derivationDescription: "Calculated from value per serving size measure",
                value: 14.2
            },
            {
                nutrientId: 1004,
                nutrientName: "Total lipid (fat)",
                nutrientNumber: "204",
                unitName: "G",
                derivationCode: "LCCS",
                derivationDescription: "Calculated from value per serving size measure",
                value: 7.55
            },
            // ... rest
        ],

        //TOTAL MICRO NUTRIENTS
        totMicros: [
            {
                nutrientId: 1087,
                nutrientName: "Calcium, Ca",
                nutrientNumber: "301",
                unitName: "MG",
                derivationCode: "LCCD",
                derivationDescription: "Calculated from a daily value percentage per serving size measure",
                value: 252
            },
            {
                nutrientId: 1089,
                nutrientName: "Iron, Fe",
                nutrientNumber: "303",
                unitName: "MG",
                derivationCode: "LCCD",
                derivationDescription: "Calculated from a daily value percentage per serving size measure",
                value: 5.3999999999999995
            },
            // ... rest
        ],

        //A Notes array to inform if nutrient profile of any ingredient is missing!
        note: []
    }
}

PLEASE NOTE: This package has not under went extreme testing and may throw error in some edge cases!!