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

emccalc-core

v1.0.0

Published

The core mathematical calculations library for Electromagnetic Compatibility (EMC) and Radio Frequency (RF) unit conversions.

Readme

emccalc-core

A clean, zero-dependency JavaScript/TypeScript library for core Electromagnetic Compatibility (EMC) and Radio Frequency (RF) mathematical calculations.

🚀 This core engine powers the live web tools hosted at EMCCalc (emccalc.com).


Language: English | 简体中文


Features

  • 7 Core Conversion Matrices: Seamlessly convert between all units for RF 50Ω System, Voltage, Current, Power, H-Field (Magnetic Field), Capacitance, and B-Field (Magnetic Flux Density).
  • Wavelength & Resonance Calculators: Convert frequencies to wavelengths and calculate dipole/monopole resonance lengths.
  • Antenna Factor Calculations: Convert electric field strengths based on receiver readings and antenna factors.
  • Distance Extrapolation: Extrapolate electric field strengths at different testing distances (e.g., 3m to 10m).
  • VSWR & Return Loss Matrix: Convert between VSWR, Return Loss, Reflection Coefficient, and Mismatch Loss.

Technical Reference: Mathematical Derivations

This library implements industry-standard formulas. Even if you are not using this package directly, you can use this section as a reference for your daily engineering calculations.

1. Decibel & Linear Conversions (Voltage, Current, Power & 50Ω System)

These are the standard formulas used for signal parameter conversions across different physical quantities:

A. RF 50Ω System (Power, Voltage & Current Link)

In a standard $50\ \Omega$ RF system, Power ($dBm$), Voltage ($dB\mu V$), and Current ($dB\mu A$) are directly related:

  • $dB\mu V$ to $dBm$: $$dBm = dB\mu V - 107$$
  • $dB\mu A$ to $dBm$: $$dBm = dB\mu A - 73$$
  • $dB\mu A$ to $dB\mu V$: $$dB\mu V = dB\mu A + 34\ \ (\text{since } R = 50\ \Omega \Rightarrow 20\log_{10}(50) \approx 34\ dB)$$

B. Voltage

  • $dB\mu V$ to $mV$: $$mV = 10^{\frac{dB\mu V - 60}{20}}\ \ \Longleftrightarrow\ \ dB\mu V = 20\log_{10}(mV) + 60$$
  • $dBV$ to $V$: $$V = 10^{\frac{dBV}{20}}\ \ \Longleftrightarrow\ \ dBV = 20\log_{10}(V)$$
  • $dBmV$ to $dB\mu V$: $$dB\mu V = dBmV + 60\ \ \Longleftrightarrow\ \ dBmV = dB\mu V - 60$$
  • $\mu V$ to $dB\mu V$: $$dB\mu V = 20\log_{10}(\mu V)\ \ \Longleftrightarrow\ \ \mu V = 10^{\frac{dB\mu V}{20}}$$

C. Electric Current

  • $dB\mu A$ to $mA$: $$mA = 10^{\frac{dB\mu A - 60}{20}}\ \ \Longleftrightarrow\ \ dB\mu A = 20\log_{10}(mA) + 60$$
  • $mA$ to $dBmA$: $$dBmA = 20\log_{10}(mA)\ \ \Longleftrightarrow\ \ mA = 10^{\frac{dBmA}{20}}$$
  • $\mu A$ to $dB\mu A$: $$dB\mu A = 20\log_{10}(\mu A)\ \ \Longleftrightarrow\ \ \mu A = 10^{\frac{dB\mu A}{20}}$$

D. Power

  • $dBm$ to $mW$: $$mW = 10^{\frac{dBm}{10}}\ \ \Longleftrightarrow\ \ dBm = 10\log_{10}(mW)$$
  • $W$ to $dBW$: $$dBW = 10\log_{10}(W)\ \ \Longleftrightarrow\ \ W = 10^{\frac{dBW}{10}}$$
  • $\mu W$ to $dB\mu W$: $$dB\mu W = 10\log_{10}(\mu W)\ \ \Longleftrightarrow\ \ \mu W = 10^{\frac{dB\mu W}{10}}$$

2. Wavelength & Frequency Conversion

Electromagnetic wave propagation in free space or dielectric media follows: $$f \cdot \lambda = v = c \cdot VF$$

Where:

  • $c \approx 299,792,458\ m/s$ (Speed of light in vacuum)
  • $f$ is the frequency in Hertz ($Hz$)
  • $\lambda$ is the wavelength in meters ($m$)
  • $VF$ is the Velocity Factor of the medium ($0.01 \le VF \le 1.0$, $1.0$ in vacuum/free space)

Formulas (Frequency in $MHz$):

  • Wavelength ($\lambda$): $$\lambda\ (m) = \frac{299.792458 \times VF}{f\ (MHz)}$$
  • Dipole Antenna Length (1/2 Wave Resonance): $$L_{1/2}\ (m) = \frac{\lambda}{2} \approx \frac{150 \times VF}{f\ (MHz)}$$
  • Monopole Antenna Length (1/4 Wave Resonance): $$L_{1/4}\ (m) = \frac{\lambda}{4} \approx \frac{75 \times VF}{f\ (MHz)}$$
  • Max Shielding Aperture Leakage Size (1/20 Wave Limit): $$L_{leakage}\ (m) = \frac{\lambda}{20}$$

3. Antenna Factor & Field Strength Conversion

Antenna Factor ($AF$, in $dB/m$) is the ratio of the incident electric field strength ($E$, in $V/m$) to the voltage at the antenna terminals ($V_{rec}$, in $V$): $$AF = \frac{E}{V_{rec}}$$

In decibel units (standard receiver readings of $dB\mu V$): $$E\ (dB\mu V/m) = V_{rec}\ (dB\mu V) + AF\ (dB/m)$$

Convert to Linear Units ($V/m$):

$$E\ (V/m) = 10^{\frac{E\ (dB\mu V/m) - 120}{20}}$$


4. Field Strength Distance Extrapolation

When testing electromagnetic fields at different distances (e.g., standard limit translations between $3\ m$ and $10\ m$), we assume far-field free-space attenuation following the inverse-distance law ($20\ dB$ per decade): $$\frac{E_2}{E_1} = \frac{d_1}{d_2}$$

In decibels: $$E_2\ (dB\mu V/m) = E_1\ (dB\mu V/m) - 20 \log_{10}\left(\frac{d_2}{d_1}\right)$$


5. VSWR & Return Loss Matrix

Mismatch parameters describe how much RF energy is reflected back from a load (like an antenna or transmission line interface):

  • Reflection Coefficient ($\Gamma$): $$\Gamma = \frac{VSWR - 1}{VSWR + 1}$$
  • Return Loss ($RL$, in $dB$): $$RL = -20 \log_{10}(|\Gamma|)$$
  • Mismatch Loss ($ML$, in $dB$): $$ML = -10 \log_{10}(1 - |\Gamma|^2)$$

6. Electromagnetic Field (E-Field & H-Field) Conversions

In the far-field region of free space, the ratio of the Electric Field ($E$, in $V/m$) to the Magnetic Field ($H$, in $A/m$) is constant and equal to the wave impedance of free space ($Z_0 \approx 120\pi \approx 377\ \Omega$): $$E = H \cdot Z_0 \approx H \cdot 377$$

In decibels: $$E\ (dB\mu V/m) = H\ (dB\mu A/m) + 20 \log_{10}(377) \approx H\ (dB\mu A/m) + 51.5$$


7. Magnetic Field (H-Field) to Magnetic Flux Density (B-Field)

In non-magnetic media (like air or vacuum), the Magnetic Flux Density ($B$, in Tesla) and Magnetic Field Strength ($H$, in $A/m$) are related by the permeability of free space ($\mu_0 = 4\pi \times 10^{-7}\ H/m$): $$B = \mu_0 \cdot H$$

Conversion to Decibel Units:

  • To $dBpT$ (picoTesla, $1\ pT = 10^{-12}\ T$): $$B(dBpT) = H(dB\mu A/m) + 20 \log_{10}\left(4\pi \times 10^{-7} \times 10^{12}\right) - 120 = H(dB\mu A/m) + 1.9842 \approx H(dB\mu A/m) + 2$$ Hence: $$dBpT \approx dB\mu A/m + 2$$

  • To $dB\mu T$ (microTesla, $1\ \mu T = 10^{-6}\ T$): $$dB\mu T \approx dB\mu A/m - 118$$


8. Magnetic Field Strength (H-Field) Decibel Conversions

Magnetic Field Strength $H$ is measured in Amperes per meter ($A/m$) in linear scale, and decibels microamperes per meter ($dB\mu A/m$) in logarithmic scale (referenced to $1\ \mu A/m = 10^{-6}\ A/m$):

  • $A/m$ to $dB\mu A/m$: $$H(dB\mu A/m) = 20 \log_{10}\left(\frac{H(A/m)}{10^{-6}}\right) = 20 \log_{10}(H(A/m)) + 120$$ $$\Longleftrightarrow\ \ H(A/m) = 10^{\frac{H(dB\mu A/m) - 120}{20}}$$
  • $dBmA/m$ to $dB\mu A/m$: $$H(dB\mu A/m) = H(dBmA/m) + 60$$
  • $dB A/m$ to $dB\mu A/m$: $$H(dB\mu A/m) = H(dB A/m) + 120$$

9. Capacitance Unit Scale

Capacitance $C$ uses standard metric prefixes relative to the Farad ($F$). The conversions are purely linear:

  • Millifarad ($mF$): $1\ mF = 10^{-3}\ F$
  • Microfarad ($\mu F$): $1\ \mu F = 10^{-6}\ F$
  • Nanofarad ($nF$): $1\ nF = 10^{-9}\ F$
  • Picofarad ($pF$): $1\ pF = 10^{-12}\ F$
  • Femtofarad ($fF$): $1\ fF = 10^{-15}\ F$

Installation

npm install emccalc-core

Usage

1. RF 50Ω System Conversion

import { convertRF50 } from 'emccalc-core';

// Convert 120 dBµV receiver reading under 50Ω to other units
const result = convertRF50(120, 'dbuv');

console.log(result);
/*
Output:
{
  dbm: 13,
  mw: 19.9526,
  dbuv: 120,
  mv: 1000,
  dbua: 86,
  ma: 20
}
*/

2. VSWR Conversion

import { calculateFromVswr } from 'emccalc-core';

// Convert a VSWR of 1.5 to return loss and mismatch loss
const mismatch = calculateFromVswr(1.5);
console.log(mismatch);
/*
Output:
{
  vswr: 1.5,
  returnLossDb: 13.9794,
  reflectionCoefficient: 0.2,
  mismatchLossDb: 0.177288
}
*/

Documentation

For interactive tools, standard limit databases (CISPR 25, EN 55032, ECE R10), and complete formula explanations, please visit the official web app:


License

This project is licensed under the MIT License.