UNPKG

846 BJavaScriptView Raw
1import formatDefault from "./formatDefault";
2import formatPrefixAuto from "./formatPrefixAuto";
3import formatRounded from "./formatRounded";
4
5export default {
6 "": formatDefault,
7 "%": function(x, p) { return (x * 100).toFixed(p); },
8 "b": function(x) { return Math.round(x).toString(2); },
9 "c": function(x) { return x + ""; },
10 "d": function(x) { return Math.round(x).toString(10); },
11 "e": function(x, p) { return x.toExponential(p); },
12 "f": function(x, p) { return x.toFixed(p); },
13 "g": function(x, p) { return x.toPrecision(p); },
14 "o": function(x) { return Math.round(x).toString(8); },
15 "p": function(x, p) { return formatRounded(x * 100, p); },
16 "r": formatRounded,
17 "s": formatPrefixAuto,
18 "X": function(x) { return Math.round(x).toString(16).toUpperCase(); },
19 "x": function(x) { return Math.round(x).toString(16); }
20};