num

numsep

Format numbers. Perfect UX: copying gives no any separators in clipboard

Showing:

Popularity

Downloads/wk

17

GitHub Stars

2

Maintenance

Last Commit

4yrs ago

Contributors

4

Package

Dependencies

0

Size (min+gzip)

0.5KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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:

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100