us-inflation
v1.1.0
Published
Convert US prices from one year (and month if you want) to another.
Downloads
29
Maintainers
Readme
US inflation
Convert US prices from one year (and month if you want) to another.
Usage
import inflation from 'us-inflation'
const current = inflation({ year: 1945, amount: 1.23 })
console.log(`$1.23 in 1945 was worth $${current} in 2017`)
Documentation
There is a single function exported by the library that has one required and one optional argument. It returns the converted price.
inflation(from, [to])
The required from
argument and the optional to
argument are similar objects.
from
amount
is the nominal priceyear
is a year between 1913 and 2018month
(optional) if want a more precise measure, you can supply the month the price was observed
to
(optional)
year
is a year between 1913 and 2018 and is 2017 (the last full year of data) by defaultmonth
(optional) if want a more precise measure, you can supply the month you want the new price for
Data source
All data comes from the Bureau of Labor Statistics Consumer Price Index inflation calculator and is therefore limited to years between 1913 and 2018.
Prior art and motivation
I came across @dillonchr/inflation but wanted an implementation that didn't make an HTTP request for every function call and I also wanted to figure out how to calculate inflation using the CPI.