Registry / productivity / si-prefix

si-prefix

JSON →
library0.2.0jsnpmunverified

si-prefix v0.2.0 is a JavaScript library for converting numeric values into human-readable strings with SI or IEC prefixes (e.g., '35 mm', '2 KiB'). It wraps the si-prefix library for Node.js, offering basic formatting via si-prefix. Works with custom units and scales. Last updated 2021, no recent releases; minimal dependencies.

npm install si-prefix
INSTALL
IMPORT
SIG · SI-PREFIX
S
si-prefix
productivityjavascriptv0.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (si)
import si from 'si-prefix'
const si = require('si-prefix')
ESM default import; CJS require also works.
Unit
import { Unit } from 'si-prefix'
const Unit = require('si-prefix').Unit
Named export for Unit class.
Scale
import { Scale } from 'si-prefix'
Named export for Scale class.

Demonstrates basic formatting with SI base units (metre, kilogram, byte) and custom unit creation with Scale and Unit.

import si from 'si-prefix'; // Basic formatting console.log(si.metre.format(0.035, ' ')); // '35 mm' console.log(si.kilogram.suffix(0.00000000094, ' ')); // 'ng' console.log(si.byte.convert(2048)); // [2, 'KiB'] console.log(si.byte.decimal.convert(2048)); // [2.048, 'kB'] // Custom unit const { Scale, Unit } = si; const scale = new Scale({ minor: true }); const unit = new Unit(scale, 'm'); console.log(unit.format(0.03, ' ')); // '3 cm'
Debug
Known issues
gotchakilogram is base unit; gram is not directly available as si.gram.
fix
Use si.kilogram.suffix(value) for grams, or create a custom gram unit.
affects: *
gotchabyte uses IEC binary prefixes (KiB, MiB, etc.) by default; use byte.decimal for SI prefixes.
fix
Access si.byte.decimal for SI prefixes (kB, MB).
affects: *
deprecatedSeparate flags for hecto/deca/deci/centi not implemented yet.
fix
Use Scale({minor: true}) to include these prefixes.
affects: 0.2.0
Errors
Common errors & fixes
Uncaught ReferenceError: Module not found: Can't resolve 'si-prefix'
Missing dependency or incorrect import path.
fix
Run 'npm install si-prefix' and ensure package.json has it.
Cannot find module 'si-prefix'
Package not installed in node_modules.
fix
Run 'npm install si-prefix'.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
si-prefix — npm install si-prefix · libregistry