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

spicemapper

v1.1.2

Published

a mapper can build SPICE Netlist

Readme

介绍

SpiceMapper是一个专门为了生成SPICE语句的JS库。SpiceMapper提供了一个电路的数据结构,并提供了方便的API用来构建电路,和生成SPICE的Netlist语句。

使用方法

快速开始

使用npm来下载spicemapper

npm install spicemapper

之后在你的文件里面引入spicemapper,其中Circuit是电路类,Components包含常用的电路元件,Types包含电路元件的类型和单位。

import { Circuit, Resistor, VoltageSource, UnitType } from 'spicemapper';

使用SpiceMapper的一步要创建一个电路对象:

const cir = new Circuit();

再调用相关API创建元件,搭建电路:

cir.add(new Resistor(1, 100, UnitType.K));
cir.add(new VoltageSource(1, 10, UnitType.None));
cir.add(new Resistor(2, 1000, UnitType.None));

cir.connectGround('R1', 0);
cir.connectGround('V1', 1);
cir.connect('R1', 1, 'V1', 0);
cir.connect('R2', 1, 'R1', 1);
cir.connect('R2', 0, 'R1', 0);

最后调用电路generate()输出SPICE Netlist:

console.log(cir.generate()); 
//output:
// R1 0 1 100K
// V1 1 0 10
// R2 0 1 1000 

Component

通过此类创建一个Component

const comp = new ComponentBase(obj);
//obj满足以下形式
obj = {
  type, //ComponentType
  name, //string | number
  value, //number
  unit, //UnitType
  maxDegree, //number
}

实际上,这个objIComponent的一个实例。

UnitTypeComponentType

UnitTypeComponentType分别是两个枚举值,其中UnitType表示诸如K,M,P...的倍率单位,ComponentType表示I电流源,R电阻...之类的元件类型。

Circuit

circuit是一个表示电路的数据结构,他是一个图。通过调用API可以构建起一个电路。首先我们创建电路实例:

const cir = new Circuit();
  1. 在电路中加入/删除元件
     cir.add(component); //传入component实例
     cir.delete(component); //传入component实例或元件全名
  2. 将元件接地
    cir.connectGround(component);//传入component实例或元件全名
  3. 将两个元件接通/断开链接
     cir.connect(compA,AIndex,compB,BIndex); //分别为component实例和对应元件端口,对于二端元件为0,1
     cir.disconnect(compA,AIndex,compB,BIndex);//分别为component实例和对应元件端口
  4. 输出SPICE Netlist
     cir.generate(); //返回SPICE Netlist字符串
  5. 输出节点电压方程
      cir.generateFomula(); //返回latex格式的节点电压方程

不足与目标

不足

  1. 本项目暂不支持多端元件
  2. 本项目各方面还未完善
  3. 本项目采用的算法并不高效

目标

  1. 在未来版本中将完善元件,API易用性--已完成 50%
  2. 将支持多端元件,支持元件自定义
  • 1.1.0新增:
    1. 输出节点电压方程
    2. 增加电容、电感、电流源
    3. 增加交流输出