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

deinflation

v1.1.1

Published

Inflate and deflate currency at month accuracy with data from the US Bureau of Labor Statistics.

Downloads

9

Readme

deinflation

This is a simple module that will calculate the inflation or deflation of a value between to date to the month by pulling the consumer price index data from the bureau of labor statistics.

API Key

In order the the script to run it will need an enviromental BLS_API_KEY variable with an API. You can register for one at https://www.bls.gov/data/#api.

Usage

First, it will need to be installed like every other package

npm install deinflation

The primary function is the adjust( value, dateA, dateB ) one, this will adjust a value for the two provided dates. If only one date is provided the other will be set as the latest date in the data set (as close to 'today' as possible). Returns an object with numerous bits of useful values, take for example the returned object for adjust(199.99, '10/1985');

{
request: { value: 199.99, dateA: '10/1985', dateB: '5/2021' },
process: {
    value: 199.99,
    dateA: [ 1985, 10 ],
    dateB: [ 2021, 5 ],
    cpiA: '108.7',
    cpiB: '269.195',
    adjustedValue: 495.27422309107635
},
notices: [],
updatedDate: false,
autoAdjustedDate: false,
type: 'inflation',
value: 495.27422309107635,
valueDiff: 295.28422309107634,
percent: 247.64949402023916,
money: '$495.27',
moneyDiff: '$295.28'
}

The only other function designed for direct use (not that the others are restricted) is the dataLastUpdated() function which returns a pretty string with the date the data was last updated. This is the date of the latest data in the dataset, not the last date the data was checked. For example, when called during development in August it reads;

Inflation data last updated July 2021

About the data

The data used in internal calculations is gathered from the latest report from http://www.bls.gov/cpi/tables.htm in Table 24. It is stored in a json file with a bit of meta data about when it was pulled. The data will attempt to update every 24hrs after the data is officially out of date however the BLS does not publish this data with any regularity I found noted