
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Module for converting SI base units into human readable form. It can also be easily extended to create other units.
$ npm install si-prefix
var si = require('si-prefix');
var millimetres = si.metre.format(0.035, ' '), //=> '35 mm'
nanograms = si.kilogram.suffix(0.00000000094, ' '), //=> 'ng'
kibibytes = si.byte.convert(2048), //=> [ 2, 'KiB' ]
kilobytes = si.byte.decimal.convert(2048); //=> [ 2.048, 'kB' ]
Units available by default are:
metre
kilogram
- note that the base unit for mass is a kilogram
, NOT a gramsecond
ampere
kelvin
mole
candela
litre
byte
- using IEC binary prefixesbyte.decimal
- using SI prefixesmeter
- alias of metre
liter
- alias of litre
var si = require('si-prefix');
// scale with hecto and deca prefixes
var scale = new si.Scale({minor: true}),
unit = new si.Unit(scale, 'm');
var centimetres = unit.format(0.03, ' '); //=> '3 cm'
Other ways you can customise units include changing the prefixes, removing some exponents, altering the logarithm base and shifting prefixes up or down. You can see examples of this in scale.coffee
where Scale.Binary
and Scale.Mass
are defined.
mc
and µ
for micro prefixWhy is it called si-prefix
when it deals with suffixes?
<_<;;
_>;;
FAQs
SI and IEC compatible numeric formatter
The npm package si-prefix receives a total of 226 weekly downloads. As such, si-prefix popularity was classified as not popular.
We found that si-prefix demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.