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

safe-stack-conversion

v1.0.0

Published

Convert a stack of YC SAFEs (post-money & pre-money) and convertible notes into a pro-forma cap table at a priced round — fixed-point solve, cap/discount best-price, interest accrual. Zero dependencies.

Downloads

24

Readme

safe-stack-conversion

Convert a stack of YC SAFEs (post-money and pre-money) and convertible notes into a pro-forma cap table at a priced round. Fixed-point solve, cap/discount best-price-wins, interest accrual. Zero dependencies.

npm install safe-stack-conversion

Why

Every seed-stage company carries a stack of SAFEs, and "what does the cap table look like after the Series A?" is a genuinely fiddly computation: post-money SAFEs pin ownership (amount ÷ cap), discount instruments convert at a price that depends on the round PPS, and the round PPS itself depends on how many shares the stack converts into. It's a simultaneous system — this package solves it by fixed-point iteration and preserves the YC identities exactly.

import { convertStack } from "safe-stack-conversion";

const pf = convertStack(
  [
    { name: "SAFE-1", kind: "safe-post-money", amount: 1_000_000, cap: 10_000_000 },
    { name: "SAFE-2", kind: "safe-pre-money", amount: 500_000, cap: 8_000_000, discount: 0.2 },
    { name: "Note-1", kind: "note", amount: 250_000, interestRate: 0.06, years: 1.5, discount: 0.2 },
  ],
  { preMoney: 20_000_000, investment: 5_000_000, preRoundFullyDiluted: 10_000_000 },
);

pf.instruments[0].ownership;      // SAFE-1's post-round stake
pf.instruments[0].basis;          // "cap" | "discount" | "price" — which term won
pf.pricePerShare;                 // preMoney / company capitalization (incl. SAFE shares)
pf.ownership;                     // { existing, safesAndNotes, newInvestor } — sums to 1

Semantics (documented, matching the YC post-money SAFE)

  • Post-money SAFE with cap: converts at cap / companyCapitalization — so its ownership of the company capitalization is exactly amount / cap, the YC headline number (verified in tests).
  • Pre-money SAFE / note with cap: converts at cap / preRoundFullyDiluted.
  • Discount: converts at (1 − d) × round PPS. Cap + discount → whichever price is lower wins (basis reports which).
  • Notes: principal accrues simple (default) or annually-compounded interest to the conversion date.
  • Company capitalization = pre-round fully diluted + all converting shares, excluding new money and new pool top-ups; round PPS = preMoney / capitalization, solved simultaneously with the stack.

Also exported: postMoneySafeOwnership(amount, cap) — the one-liner identity.

Related

Part of a cap-table math family: priced-round-math (option-pool shuffle) · exit-waterfall · vesting-schedule-math.

Author

Built by Moshe Malka — engineering leader in New York City. Studio work at Quentin.Code.

MIT © Moshe Malka