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

diode-analyzer

v1.0.2

Published

A JavaScript library for parameter extraction of the Five-Parameter Diode Model. Calculates Vth (Threshold Voltage), Rsh (Shunt Resistance), Rs (Series Resistance), Io (Saturation Current), and n (Ideality Factor).

Readme

Semiconductor Physics Tools

A JavaScript library for Parameter Extraction of the Five-Parameter Diode Model.

Parameters Calculated:

  1. Vth: Threshold Voltage
  2. Rsh: Shunt Resistance (Leakage)
  3. Rs: Series Resistance (Contact quality)
  4. Io: Saturation Current (Material quality)
  5. n (nte/ncc): Ideality Factor (Physics perfection)

Installation

npm install diode-analyzer

Usage

import {
  calculateVth,
  calculateRsh,
  processStepNine,
  findThresholdIndex,
  processStepTen,
} from "diode-analyzer";

// Example: Calculate Threshold Voltage (Vth)
const voltages = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0];
const currents = [
  0.000000035767, 0.00000004389, 0.000000057498, 0.000000076319, 0.000000097812,
  0.000000121201, 0.00000015031, 0.00000018914, 0.000000212217, 0.000000248738,
];

const vth = calculateVth(voltages, currents);
console.log("Threshold Voltage:", vth);

// Example: Calculate Shunt Resistance (Rsh)
const resistances = [28842.998823692906, 5724.990842589983, 3234.683524429178];
const rshResult = calculateRsh(voltages, resistances);
console.log("Rsh:", rshResult.rsh);
console.log("Rsh Formatted:", rshResult.rshFormatted);

// Example: Find threshold index
const thresholdIndex = findThresholdIndex(voltages, vth);
console.log("Threshold Index:", thresholdIndex);

// Example: Process Step 9 (Io and nTE calculation)
const lnlValues = [
  -17.14623801998393, -16.941583763247255, -16.671516179696415,
];
const step9Result = processStepNine(voltages, lnlValues, thresholdIndex);
console.log("Io:", step9Result.io);
console.log("nTE:", step9Result.nte);

// Example: Process Step 10 (Rs and ncc calculation)
const dvdlnI = [0.0026878518619670205, 0.488628976472591, 0.3702776863672527];
const step10Result = processStepTen(currents, dvdlnI);
console.log("Rs:", step10Result.rs);
console.log("ncc:", step10Result.ncc);

API Reference

calculateVth(voltages, currents)

Calculates Threshold Voltage using K-means clustering on rolling slopes.

  • Parameters:
    • voltages (Array): Array of voltage values
    • currents (Array): Array of current values
  • Returns: number - The threshold voltage value

calculateRsh(voltages, resistances)

Calculates Shunt Resistance (Rsh) by finding the maximum resistance value.

  • Parameters:
    • voltages (Array): Array of voltage values
    • resistances (Array): Array of resistance values
  • Returns: Object - { rsh: number, rshFormatted: string, success: boolean }

findThresholdIndex(voltages, vth)

Finds the 1-based index of the threshold voltage in the voltage array.

  • Parameters:
    • voltages (Array | string): Array of voltage values or comma-separated string
    • vth (number): Threshold voltage value
  • Returns: number | null - 1-based index or null if not found

processStepNine(voltages, lnlValues, threshold)

Calculates Io (Saturation Current) and nTE (Ideality Factor) using linear regression.

  • Parameters:
    • voltages (Array): Array of voltage values
    • lnlValues (Array): Array of ln(I) values
    • threshold (number): Threshold index (1-based)
  • Returns: Object - { io: string, nte: string, success: boolean }

processStepTen(currents, dvdlnI)

Calculates Rs (Series Resistance) and ncc (Ideality Factor) using segmentation analysis.

  • Parameters:
    • currents (Array): Array of current values
    • dvdlnI (Array): Array of dV/d(ln(I)) values
  • Returns: Object - { rs: string, ncc: string, success: boolean }

License

ISC