Socket
Socket
Sign inDemoInstall

d3-format

Package Overview
Dependencies
0
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-rc.1 to 2.0.0

55

dist/d3-format.js

@@ -1,12 +0,18 @@

// https://d3js.org/d3-format/ v2.0.0-rc.1 Copyright 2020 Mike Bostock
// https://d3js.org/d3-format/ v2.0.0 Copyright 2020 Mike Bostock
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.d3 = global.d3 || {}));
}(this, function (exports) { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}));
}(this, (function (exports) { 'use strict';
function formatDecimal(x) {
return Math.abs(x = Math.round(x)) >= 1e21
? x.toLocaleString("en").replace(/,/g, "")
: x.toString(10);
}
// Computes the decimal coefficient and exponent of the specified number x with
// significant digits p, where x is positive and p is in [1, 21] or undefined.
// For example, formatDecimal(1.23) returns ["123", 0].
function formatDecimal(x, p) {
// For example, formatDecimalParts(1.23) returns ["123", 0].
function formatDecimalParts(x, p) {
if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity

@@ -24,3 +30,3 @@ var i, coefficient = x.slice(0, i);

function exponent(x) {
return x = formatDecimal(Math.abs(x)), x ? x[1] : NaN;
return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN;
}

@@ -118,3 +124,3 @@

function formatPrefixAuto(x, p) {
var d = formatDecimal(x, p);
var d = formatDecimalParts(x, p);
if (!d) return x + "";

@@ -128,7 +134,7 @@ var coefficient = d[0],

: i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i)
: "0." + new Array(1 - i).join("0") + formatDecimal(x, Math.max(0, p + i - 1))[0]; // less than 1y!
: "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y!
}
function formatRounded(x, p) {
var d = formatDecimal(x, p);
var d = formatDecimalParts(x, p);
if (!d) return x + "";

@@ -143,18 +149,20 @@ var coefficient = d[0],

var formatTypes = {
"%": function(x, p) { return (x * 100).toFixed(p); },
"b": function(x) { return Math.round(x).toString(2); },
"c": function(x) { return x + ""; },
"d": function(x) { return Math.round(x).toString(10); },
"e": function(x, p) { return x.toExponential(p); },
"f": function(x, p) { return x.toFixed(p); },
"g": function(x, p) { return x.toPrecision(p); },
"o": function(x) { return Math.round(x).toString(8); },
"p": function(x, p) { return formatRounded(x * 100, p); },
"%": (x, p) => (x * 100).toFixed(p),
"b": (x) => Math.round(x).toString(2),
"c": (x) => x + "",
"d": formatDecimal,
"e": (x, p) => x.toExponential(p),
"f": (x, p) => x.toFixed(p),
"g": (x, p) => x.toPrecision(p),
"o": (x) => Math.round(x).toString(8),
"p": (x, p) => formatRounded(x * 100, p),
"r": formatRounded,
"s": formatPrefixAuto,
"X": function(x) { return Math.round(x).toString(16).toUpperCase(); },
"x": function(x) { return Math.round(x).toString(16); }
"X": (x) => Math.round(x).toString(16).toUpperCase(),
"x": (x) => Math.round(x).toString(16)
};
var identity = x => x;
function identity(x) {
return x;
}

@@ -171,3 +179,3 @@ var map = Array.prototype.map,

percent = locale.percent === undefined ? "%" : locale.percent + "",
minus = locale.minus === undefined ? "-" : locale.minus + "",
minus = locale.minus === undefined ? "−" : locale.minus + "",
nan = locale.nan === undefined ? "NaN" : locale.nan + "";

@@ -305,3 +313,2 @@

defaultLocale({
decimal: ".",
thousands: ",",

@@ -342,2 +349,2 @@ grouping: [3],

}));
})));

@@ -1,2 +0,2 @@

// https://d3js.org/d3-format/ v2.0.0-rc.1 Copyright 2020 Mike Bostock
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).d3=t.d3||{})}(this,function(t){"use strict";function n(t,n){if((i=(t=n?t.toExponential(n-1):t.toExponential()).indexOf("e"))<0)return null;var i,r=t.slice(0,i);return[r.length>1?r[0]+r.slice(2):r,+t.slice(i+1)]}function i(t){return(t=n(Math.abs(t)))?t[1]:NaN}var r,e=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function o(t){if(!(n=e.exec(t)))throw new Error("invalid format: "+t);var n;return new a({fill:n[1],align:n[2],sign:n[3],symbol:n[4],zero:n[5],width:n[6],comma:n[7],precision:n[8]&&n[8].slice(1),trim:n[9],type:n[10]})}function a(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function s(t,i){var r=n(t,i);if(!r)return t+"";var e=r[0],o=r[1];return o<0?"0."+new Array(-o).join("0")+e:e.length>o+1?e.slice(0,o+1)+"."+e.slice(o+1):e+new Array(o-e.length+2).join("0")}o.prototype=a.prototype,a.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var u,c={"%":function(t,n){return(100*t).toFixed(n)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.round(t).toString(10)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},g:function(t,n){return t.toPrecision(n)},o:function(t){return Math.round(t).toString(8)},p:function(t,n){return s(100*t,n)},r:s,s:function(t,i){var e=n(t,i);if(!e)return t+"";var o=e[0],a=e[1],s=a-(r=3*Math.max(-8,Math.min(8,Math.floor(a/3))))+1,u=o.length;return s===u?o:s>u?o+new Array(s-u+1).join("0"):s>0?o.slice(0,s)+"."+o.slice(s):"0."+new Array(1-s).join("0")+n(t,Math.max(0,i+s-1))[0]},X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}},f=t=>t,h=Array.prototype.map,l=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function d(t){var n,e,a=void 0===t.grouping||void 0===t.thousands?f:(n=h.call(t.grouping,Number),e=t.thousands+"",function(t,i){for(var r=t.length,o=[],a=0,s=n[0],u=0;r>0&&s>0&&(u+s+1>i&&(s=Math.max(1,i-u)),o.push(t.substring(r-=s,r+s)),!((u+=s+1)>i));)s=n[a=(a+1)%n.length];return o.reverse().join(e)}),s=void 0===t.currency?"":t.currency[0]+"",u=void 0===t.currency?"":t.currency[1]+"",d=void 0===t.decimal?".":t.decimal+"",m=void 0===t.numerals?f:function(t){return function(n){return n.replace(/[0-9]/g,function(n){return t[+n]})}}(h.call(t.numerals,String)),p=void 0===t.percent?"%":t.percent+"",g=void 0===t.minus?"-":t.minus+"",v=void 0===t.nan?"NaN":t.nan+"";function M(t){var n=(t=o(t)).fill,i=t.align,e=t.sign,f=t.symbol,h=t.zero,M=t.width,y=t.comma,x=t.precision,b=t.trim,w=t.type;"n"===w?(y=!0,w="g"):c[w]||(void 0===x&&(x=12),b=!0,w="g"),(h||"0"===n&&"="===i)&&(h=!0,n="0",i="=");var S="$"===f?s:"#"===f&&/[boxX]/.test(w)?"0"+w.toLowerCase():"",j="$"===f?u:/[%p]/.test(w)?p:"",k=c[w],z=/[defgprs%]/.test(w);function A(t){var o,s,u,c=S,f=j;if("c"===w)f=k(t)+f,t="";else{var p=(t=+t)<0||1/t<0;if(t=isNaN(t)?v:k(Math.abs(t),x),b&&(t=function(t){t:for(var n,i=t.length,r=1,e=-1;r<i;++r)switch(t[r]){case".":e=n=r;break;case"0":0===e&&(e=r),n=r;break;default:if(!+t[r])break t;e>0&&(e=0)}return e>0?t.slice(0,e)+t.slice(n+1):t}(t)),p&&0==+t&&"+"!==e&&(p=!1),c=(p?"("===e?e:g:"-"===e||"("===e?"":e)+c,f=("s"===w?l[8+r/3]:"")+f+(p&&"("===e?")":""),z)for(o=-1,s=t.length;++o<s;)if(48>(u=t.charCodeAt(o))||u>57){f=(46===u?d+t.slice(o+1):t.slice(o))+f,t=t.slice(0,o);break}}y&&!h&&(t=a(t,1/0));var A=c.length+t.length+f.length,N=A<M?new Array(M-A+1).join(n):"";switch(y&&h&&(t=a(N+t,N.length?M-f.length:1/0),N=""),i){case"<":t=c+t+f+N;break;case"=":t=c+N+t+f;break;case"^":t=N.slice(0,A=N.length>>1)+c+t+f+N.slice(A);break;default:t=N+c+t+f}return m(t)}return x=void 0===x?6:/[gprs]/.test(w)?Math.max(1,Math.min(21,x)):Math.max(0,Math.min(20,x)),A.toString=function(){return t+""},A}return{format:M,formatPrefix:function(t,n){var r=M(((t=o(t)).type="f",t)),e=3*Math.max(-8,Math.min(8,Math.floor(i(n)/3))),a=Math.pow(10,-e),s=l[8+e/3];return function(t){return r(a*t)+s}}}}function m(n){return u=d(n),t.format=u.format,t.formatPrefix=u.formatPrefix,u}m({decimal:".",thousands:",",grouping:[3],currency:["$",""]}),t.FormatSpecifier=a,t.formatDefaultLocale=m,t.formatLocale=d,t.formatSpecifier=o,t.precisionFixed=function(t){return Math.max(0,-i(Math.abs(t)))},t.precisionPrefix=function(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(i(n)/3)))-i(Math.abs(t)))},t.precisionRound=function(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,i(n)-i(t))+1},Object.defineProperty(t,"__esModule",{value:!0})});
// https://d3js.org/d3-format/ v2.0.0 Copyright 2020 Mike Bostock
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).d3=t.d3||{})}(this,(function(t){"use strict";function i(t,i){if((n=(t=i?t.toExponential(i-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)]}function n(t){return(t=i(Math.abs(t)))?t[1]:NaN}var r,e=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function o(t){if(!(i=e.exec(t)))throw new Error("invalid format: "+t);var i;return new a({fill:i[1],align:i[2],sign:i[3],symbol:i[4],zero:i[5],width:i[6],comma:i[7],precision:i[8]&&i[8].slice(1),trim:i[9],type:i[10]})}function a(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function s(t,n){var r=i(t,n);if(!r)return t+"";var e=r[0],o=r[1];return o<0?"0."+new Array(-o).join("0")+e:e.length>o+1?e.slice(0,o+1)+"."+e.slice(o+1):e+new Array(o-e.length+2).join("0")}o.prototype=a.prototype,a.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var c={"%":(t,i)=>(100*t).toFixed(i),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,i)=>t.toExponential(i),f:(t,i)=>t.toFixed(i),g:(t,i)=>t.toPrecision(i),o:t=>Math.round(t).toString(8),p:(t,i)=>s(100*t,i),r:s,s:function(t,n){var e=i(t,n);if(!e)return t+"";var o=e[0],a=e[1],s=a-(r=3*Math.max(-8,Math.min(8,Math.floor(a/3))))+1,c=o.length;return s===c?o:s>c?o+new Array(s-c+1).join("0"):s>0?o.slice(0,s)+"."+o.slice(s):"0."+new Array(1-s).join("0")+i(t,Math.max(0,n+s-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function h(t){return t}var l,u=Array.prototype.map,f=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function d(t){var i,e,a=void 0===t.grouping||void 0===t.thousands?h:(i=u.call(t.grouping,Number),e=t.thousands+"",function(t,n){for(var r=t.length,o=[],a=0,s=i[0],c=0;r>0&&s>0&&(c+s+1>n&&(s=Math.max(1,n-c)),o.push(t.substring(r-=s,r+s)),!((c+=s+1)>n));)s=i[a=(a+1)%i.length];return o.reverse().join(e)}),s=void 0===t.currency?"":t.currency[0]+"",l=void 0===t.currency?"":t.currency[1]+"",d=void 0===t.decimal?".":t.decimal+"",m=void 0===t.numerals?h:function(t){return function(i){return i.replace(/[0-9]/g,(function(i){return t[+i]}))}}(u.call(t.numerals,String)),p=void 0===t.percent?"%":t.percent+"",g=void 0===t.minus?"−":t.minus+"",v=void 0===t.nan?"NaN":t.nan+"";function M(t){var i=(t=o(t)).fill,n=t.align,e=t.sign,h=t.symbol,u=t.zero,M=t.width,y=t.comma,x=t.precision,b=t.trim,w=t.type;"n"===w?(y=!0,w="g"):c[w]||(void 0===x&&(x=12),b=!0,w="g"),(u||"0"===i&&"="===n)&&(u=!0,i="0",n="=");var S="$"===h?s:"#"===h&&/[boxX]/.test(w)?"0"+w.toLowerCase():"",j="$"===h?l:/[%p]/.test(w)?p:"",k=c[w],z=/[defgprs%]/.test(w);function A(t){var o,s,c,h=S,l=j;if("c"===w)l=k(t)+l,t="";else{var p=(t=+t)<0||1/t<0;if(t=isNaN(t)?v:k(Math.abs(t),x),b&&(t=function(t){t:for(var i,n=t.length,r=1,e=-1;r<n;++r)switch(t[r]){case".":e=i=r;break;case"0":0===e&&(e=r),i=r;break;default:if(!+t[r])break t;e>0&&(e=0)}return e>0?t.slice(0,e)+t.slice(i+1):t}(t)),p&&0==+t&&"+"!==e&&(p=!1),h=(p?"("===e?e:g:"-"===e||"("===e?"":e)+h,l=("s"===w?f[8+r/3]:"")+l+(p&&"("===e?")":""),z)for(o=-1,s=t.length;++o<s;)if(48>(c=t.charCodeAt(o))||c>57){l=(46===c?d+t.slice(o+1):t.slice(o))+l,t=t.slice(0,o);break}}y&&!u&&(t=a(t,1/0));var A=h.length+t.length+l.length,N=A<M?new Array(M-A+1).join(i):"";switch(y&&u&&(t=a(N+t,N.length?M-l.length:1/0),N=""),n){case"<":t=h+t+l+N;break;case"=":t=h+N+t+l;break;case"^":t=N.slice(0,A=N.length>>1)+h+t+l+N.slice(A);break;default:t=N+h+t+l}return m(t)}return x=void 0===x?6:/[gprs]/.test(w)?Math.max(1,Math.min(21,x)):Math.max(0,Math.min(20,x)),A.toString=function(){return t+""},A}return{format:M,formatPrefix:function(t,i){var r=M(((t=o(t)).type="f",t)),e=3*Math.max(-8,Math.min(8,Math.floor(n(i)/3))),a=Math.pow(10,-e),s=f[8+e/3];return function(t){return r(a*t)+s}}}}function m(i){return l=d(i),t.format=l.format,t.formatPrefix=l.formatPrefix,l}m({thousands:",",grouping:[3],currency:["$",""]}),t.FormatSpecifier=a,t.formatDefaultLocale=m,t.formatLocale=d,t.formatSpecifier=o,t.precisionFixed=function(t){return Math.max(0,-n(Math.abs(t)))},t.precisionPrefix=function(t,i){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(n(i)/3)))-n(Math.abs(t)))},t.precisionRound=function(t,i){return t=Math.abs(t),i=Math.abs(i)-t,Math.max(0,n(i)-n(t))+1},Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "d3-format",
"version": "2.0.0-rc.1",
"publishConfig": {
"tag": "next"
},
"version": "2.0.0",
"description": "Format numbers for human consumption.",

@@ -43,7 +40,7 @@ "keywords": [

"devDependencies": {
"eslint": "6",
"rollup": "1",
"rollup-plugin-terser": "5",
"tape": "4"
"eslint": "7",
"rollup": "2",
"rollup-plugin-terser": "7",
"tape": "5"
}
}

@@ -70,6 +70,6 @@ # d3-format

If you use NPM, `npm install d3-format`. Otherwise, download the [latest release](https://github.com/d3/d3-format/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-format.v1.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
If you use NPM, `npm install d3-format`. Otherwise, download the [latest release](https://github.com/d3/d3-format/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-format.v2.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
```html
<script src="https://d3js.org/d3-format.v1.min.js"></script>
<script src="https://d3js.org/d3-format.v2.min.js"></script>
<script>

@@ -85,3 +85,3 @@

```js
d3.json("https://cdn.jsdelivr.net/npm/d3-format@1/locale/ru-RU.json", function(error, locale) {
d3.json("https://cdn.jsdelivr.net/npm/d3-format@2/locale/ru-RU.json", function(error, locale) {
if (error) throw error;

@@ -338,3 +338,3 @@

* `percent` - optional; the percent sign (defaults to `"%"`).
* `minus` - optional; the minus sign (defaults to hyphen-minus, `"-"`).
* `minus` - optional; the minus sign (defaults to `"−"`).
* `nan` - optional; the not-a-number value (defaults `"NaN"`).

@@ -341,0 +341,0 @@

@@ -8,3 +8,2 @@ import formatLocale from "./locale.js";

defaultLocale({
decimal: ".",
thousands: ",",

@@ -11,0 +10,0 @@ grouping: [3],

@@ -1,5 +0,5 @@

import formatDecimal from "./formatDecimal.js";
import {formatDecimalParts} from "./formatDecimal.js";
export default function(x) {
return x = formatDecimal(Math.abs(x)), x ? x[1] : NaN;
return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN;
}

@@ -0,5 +1,11 @@

export default function(x) {
return Math.abs(x = Math.round(x)) >= 1e21
? x.toLocaleString("en").replace(/,/g, "")
: x.toString(10);
}
// Computes the decimal coefficient and exponent of the specified number x with
// significant digits p, where x is positive and p is in [1, 21] or undefined.
// For example, formatDecimal(1.23) returns ["123", 0].
export default function(x, p) {
// For example, formatDecimalParts(1.23) returns ["123", 0].
export function formatDecimalParts(x, p) {
if ((i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e")) < 0) return null; // NaN, ±Infinity

@@ -6,0 +12,0 @@ var i, coefficient = x.slice(0, i);

@@ -1,2 +0,2 @@

import formatDecimal from "./formatDecimal.js";
import {formatDecimalParts} from "./formatDecimal.js";

@@ -6,3 +6,3 @@ export var prefixExponent;

export default function(x, p) {
var d = formatDecimal(x, p);
var d = formatDecimalParts(x, p);
if (!d) return x + "";

@@ -16,3 +16,3 @@ var coefficient = d[0],

: i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i)
: "0." + new Array(1 - i).join("0") + formatDecimal(x, Math.max(0, p + i - 1))[0]; // less than 1y!
: "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y!
}

@@ -1,5 +0,5 @@

import formatDecimal from "./formatDecimal.js";
import {formatDecimalParts} from "./formatDecimal.js";
export default function(x, p) {
var d = formatDecimal(x, p);
var d = formatDecimalParts(x, p);
if (!d) return x + "";

@@ -6,0 +6,0 @@ var coefficient = d[0],

@@ -0,1 +1,2 @@

import formatDecimal from "./formatDecimal.js";
import formatPrefixAuto from "./formatPrefixAuto.js";

@@ -5,15 +6,15 @@ import formatRounded from "./formatRounded.js";

export default {
"%": function(x, p) { return (x * 100).toFixed(p); },
"b": function(x) { return Math.round(x).toString(2); },
"c": function(x) { return x + ""; },
"d": function(x) { return Math.round(x).toString(10); },
"e": function(x, p) { return x.toExponential(p); },
"f": function(x, p) { return x.toFixed(p); },
"g": function(x, p) { return x.toPrecision(p); },
"o": function(x) { return Math.round(x).toString(8); },
"p": function(x, p) { return formatRounded(x * 100, p); },
"%": (x, p) => (x * 100).toFixed(p),
"b": (x) => Math.round(x).toString(2),
"c": (x) => x + "",
"d": formatDecimal,
"e": (x, p) => x.toExponential(p),
"f": (x, p) => x.toFixed(p),
"g": (x, p) => x.toPrecision(p),
"o": (x) => Math.round(x).toString(8),
"p": (x, p) => formatRounded(x * 100, p),
"r": formatRounded,
"s": formatPrefixAuto,
"X": function(x) { return Math.round(x).toString(16).toUpperCase(); },
"x": function(x) { return Math.round(x).toString(16); }
"X": (x) => Math.round(x).toString(16).toUpperCase(),
"x": (x) => Math.round(x).toString(16)
};

@@ -1,1 +0,3 @@

export default x => x;
export default function(x) {
return x;
}

@@ -20,3 +20,3 @@ import exponent from "./exponent.js";

percent = locale.percent === undefined ? "%" : locale.percent + "",
minus = locale.minus === undefined ? "-" : locale.minus + "",
minus = locale.minus === undefined ? "−" : locale.minus + "",
nan = locale.nan === undefined ? "NaN" : locale.nan + "";

@@ -23,0 +23,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc