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

spicets

v0.0.4

Published

`spicets` is a TypeScript-first toolkit for reading, editing, and generating SPICE netlists. The API follows the same pattern as `kicadts`: every logical card is modeled as a class, ordered source is preserved in the root document, and `getString()` emits

Readme

spicets

spicets is a TypeScript-first toolkit for reading, editing, and generating SPICE netlists. The API follows the same pattern as kicadts: every logical card is modeled as a class, ordered source is preserved in the root document, and getString() emits deterministic SPICE text.

Local Setup

This repository uses Bun for scripts and testing.

  • bun install
  • bun test
  • bun run typecheck

Build SPICE Netlists

import { promises as fs } from "node:fs"
import {
  Capacitor,
  Resistor,
  SpiceNetlist,
  Tran,
  VoltageSource,
} from "spicets"

const netlist = new SpiceNetlist({
  title: "RC low-pass demo",
  cards: [
    new VoltageSource({
      name: "V1",
      nodes: ["vin", "0"],
      dc: 5,
    }),
    new Resistor({
      name: "R1",
      nodes: ["vin", "vout"],
      resistance: "10k",
    }),
    new Capacitor({
      name: "C1",
      nodes: ["vout", "0"],
      capacitance: "100n",
    }),
    new Tran({
      step: "1us",
      stop: "10ms",
    }),
  ],
})

await fs.writeFile("rc.cir", netlist.getString({ format: "pretty" }))

Emits:

RC low-pass demo
V1 vin 0 DC 5
R1 vin vout 10k
C1 vout 0 100n
.tran 1us 10ms
.end

Load and Modify Existing Netlists

import { promises as fs } from "node:fs"
import { Resistor, Tran, parseSpiceNetlist } from "spicets"

const netlist = parseSpiceNetlist(await fs.readFile("amplifier.cir", "utf8"), {
  dialect: "ngspice",
})

const rload = netlist.findElement("RLOAD")

if (rload instanceof Resistor) {
  rload.resistance.raw = "2.2k"
}

netlist.add(new Tran({ step: "10n", stop: "10u" }))

await fs.writeFile("amplifier.cir", netlist.getString())

Subcircuits

import { Op, Resistor, SpiceNetlist, Subckt, SubcktInstance, VoltageSource } from "spicets"

const divider = new Subckt({
  name: "divider",
  pins: ["vin", "vout", "0"],
  params: {
    rtop: "10k",
    rbot: "10k",
  },
  cards: [
    new Resistor({
      name: "Rtop",
      nodes: ["vin", "vout"],
      resistance: "{rtop}",
    }),
    new Resistor({
      name: "Rbot",
      nodes: ["vout", "0"],
      resistance: "{rbot}",
    }),
  ],
})

const netlist = new SpiceNetlist({
  title: "divider demo",
  cards: [
    divider,
    new VoltageSource({
      name: "V1",
      nodes: ["vin", "0"],
      dc: 5,
    }),
    new SubcktInstance({
      name: "X1",
      nodes: ["vin", "vout", "0"],
      subckt: "divider",
      params: {
        rtop: "20k",
      },
    }),
    new Op(),
  ],
})

Source Waveforms

import { Pulse, VoltageSource } from "spicets"

const clock = new VoltageSource({
  name: "VCLK",
  nodes: ["clk", "0"],
  transient: new Pulse({
    initial: 0,
    pulsed: 3.3,
    delay: "1ns",
    rise: "100ps",
    fall: "100ps",
    width: "5ns",
    period: "10ns",
  }),
})

API Shape

  • parseToSpiceTokens() / tokenizeSpice() are the low-level tokenizer layer, equivalent in spirit to kicadts's S-expression parser.
  • SpiceCard.register() maps tokenized cards to classes through each class's fromSpiceTokens() static method, mirroring the SxClass.register(...) pattern in kicadts.
  • SpiceNetlist.cards is the ordered source of truth.
  • Typed getters expose elements, directives, subckts, models, and analyses.
  • Every card class extends SpiceCard; element cards extend ElementCard; dot commands extend DotCommand.
  • Values stay source-level by default. Strings such as "10k", "1meg", "{rload}", and "agauss(0,1,1)" are preserved instead of evaluated.
  • Unknown syntax is represented as UnknownElementCard, UnknownDotCommand, or RawCard so files can round-trip without dropping vendor-specific content.

Parse Functions

parseToSpiceTokens(source)
parseSpiceNetlist(source)
parseSpiceLibrary(source)
parseSpiceCards(source)
parseSpiceCard(source)

Use parseToSpiceTokens() for editor tools and low-level inspection, parseSpiceNetlist() for complete decks, and parseSpiceCards() for card-level transforms.