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 🙏

© 2026 – Pkg Stats / Ryan Hefner

jackpot-annuity

v0.1.0

Published

Cent-exact growing annuity schedules, present value and CSV export for Node.js and browsers.

Readme

jackpot-annuity

Generate growing annuity schedules, compare their present value and export CSV files. Works in Node.js and modern browsers, with no runtime dependencies. Monetary outputs are integer cents, and payments always add up to the exact input total.

This is the standalone annuity component from Jackpot Calculator. Compare the generated schedule with the interactive lottery annuity calculator when you need federal and state tax estimates. This package computes amounts before tax; it does not predict future tax rules or winning numbers.

Install

npm install jackpot-annuity

Node.js 20 or newer. This package is an ES module.

Library

import { calculateAnnuity, toCSV, presentValue } from 'jackpot-annuity';

const result = calculateAnnuity({
  total: '450M',
  payments: 30,
  growthRate: 0.05,
  discountRate: 0.04,
  timing: 'due', // first payment immediately, at year 0
});

console.log(result.totalCents); // 45000000000
console.log(result.rows[0]); // payment, year, amountCents, presentValueCents
console.log(toCSV(result));

// If you already have after-tax cash flows, pass integer cents directly:
console.log(presentValue([6300, 6930], 0.1, 'due')); // 12600 cents

API rates are decimal fractions: 0.05 means 5%. total is in dollars; annuitySchedule and presentValue take integer cents. All returned money fields are cents.

CLI

npx jackpot-annuity 450M --format csv > schedule.csv
npx jackpot-annuity 1.2B --discount 5 --timing ordinary --format json
npx jackpot-annuity 1000 --payments 10 --growth 0 --discount 0

CLI rates are percentages: --growth 5 means 5%. Defaults: 30 payments, 5% growth, 4% discount, first payment immediately, CSV output. Use --help for options.

Browser demo

Serve this repository with any static HTTP server and open examples/. It includes input controls, a payment table, present-value comparison and a CSV download. No analytics or network calls are used by the calculator.

The hosted browser demo and API documentation are deployed from this repository.

python -m http.server 4187 --bind 127.0.0.1
# Open http://127.0.0.1:4187/examples/

Browser imports can also use a pinned published npm version:

import { calculateAnnuity } from 'https://unpkg.com/[email protected]/src/index.js';

API and limits

| Function | Input | Output | |---|---|---| | parseAmount(value) | Dollar number or string; optional $, grouped commas, K/M/B | Integer cents | | annuitySchedule(totalCents, payments=30, growthRate=0.05) | Total in cents, 1–1000 payments, decimal growth | Integer-cent payment array | | presentValue(cashFlows, discountRate=0.04, timing='due') | 1–1000 nonnegative integer-cent flows | Present value in integer cents | | calculateAnnuity(options) | Dollar total, optional count, rates, timing | Result object and payment rows | | toCSV(result) | Result from calculateAnnuity | CSV with fixed two-decimal USD columns |

Amounts must resolve to whole cents and must not exceed Number.MAX_SAFE_INTEGER cents. For large values use strings to avoid precision loss before the API receives a JavaScript number. Scientific-notation strings are not accepted. Growth must be greater than -100% and at most 100%; discount must be 0–100%. Both rates are annual and constant. There are no payment fees, inflation adjustments or tax assumptions.

timing: 'due' pays at years 0 through n−1; ordinary pays at years 1 through n. A payment number is one-based in both cases.

Formula and rounding

For n payments and annual growth g, unrounded amounts are proportional to (1+g)^k, for k=0…n−1. If g=0, they are equal. The implementation normalizes these weights to avoid numeric overflow, rounds cumulative allocations to cents and takes successive differences. This guarantees that even a one-cent payout split into 30 payments has no negative payments and sums to one cent. Individual rounded payments can differ from the exact geometric ratio by cents.

Present value is sum(payment[k] / (1+r)^(k+t)), with t=0 for due and t=1 for ordinary. The aggregate is rounded once. Each displayed row is rounded separately, so adding displayed row present values can differ from the aggregate by a few cents. Very long schedules with extreme rates can have weights below floating-point precision; their allocated payments round to zero.

The default 30-payment, 5%-growth scenario follows the annuity structure described in the Powerball FAQ. Inputs are configurable; the package does not fetch current jackpot amounts.

Development and release

npm ci
npm run check
npm test
npm run verify:package

Package verification builds a tarball, checks the public file allowlist, installs it into a temporary project and invokes both the installed API and CLI. CI runs on Windows and Linux with Node 20, 22 and 24. The documentation source is in docs/ with a Read the Docs configuration.

See CHANGELOG.md for versions and LICENSE for the MIT license. Report bugs through GitHub Issues.