numsep

0.1.9 • Public • Published

numsep Build Status

Format numbers.

Split onto triads & wrap with html-elements instead of inserting space separators.

Perfect UX: copying gives no any separators in clipboard.

usage

var triadTmpl = n => `<span>${n}</span>`;
var numTmpl = triadTmpl;
var formatNumber = num => require('numsep')(num, triadTmpl, numTmpl);
 
formatNumber(1) === "<span><span>1</span></span>"
formatNumber(100) === "<span><span>100</span></span>"
formatNumber(10001) === "<span><span>10</span><span>001</span></span>"
formatNumber(-10001) === "<span>-<span>10</span><span>001</span></span>"
formatNumber(-10001.0) === "<span>-<span>10</span><span>001</span></span>"
formatNumber("-10001.0") === "<span>-<span>10</span><span>001</span>.0</span>"
formatNumber(-10001.505) === "<span>-<span>10</span><span>001</span>.505</span>"
formatNumber("-10001.505") === "<span>-<span>10</span><span>001</span>.505</span>"
formatNumber(-0.505) === "<span>-<span>0</span>.505</span>"
formatNumber("-0.505") === "<span>-<span>0</span>.505</span>"
formatNumber("0.505") === "<span><span>0</span>.505</span>"

style

Dirty simple css:

div { text-align: right }
span + span { margin-left: .3em }

Result:

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.92latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.92
0.1.80
0.1.70
0.1.60
0.1.51
0.1.40
0.1.30
0.1.20
0.1.10

Package Sidebar

Install

npm i numsep

Weekly Downloads

3

Version

0.1.9

License

MIT

Unpacked Size

8 kB

Total Files

6

Last publish

Collaborators

  • invntrm