Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-format

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-format - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

7

build/d3-format.js

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

// https://d3js.org/d3-format/ Version 1.1.1. Copyright 2017 Mike Bostock.
// https://d3js.org/d3-format/ Version 1.2.0. Copyright 2017 Mike Bostock.
(function (global, factory) {

@@ -176,3 +176,4 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

decimal = locale.decimal,
numerals = locale.numerals ? formatNumerals(locale.numerals) : identity;
numerals = locale.numerals ? formatNumerals(locale.numerals) : identity,
percent = locale.percent || "%";

@@ -195,3 +196,3 @@ function newFormat(specifier) {

var prefix = symbol === "$" ? currency[0] : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
suffix = symbol === "$" ? currency[1] : /[%p]/.test(type) ? "%" : "";
suffix = symbol === "$" ? currency[1] : /[%p]/.test(type) ? percent : "";

@@ -198,0 +199,0 @@ // What format function should we use?

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

// https://d3js.org/d3-format/ Version 1.1.1. Copyright 2017 Mike Bostock.
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.d3=t.d3||{})}(this,function(t){"use strict";function n(t){return new r(t)}function r(t){if(!(n=m.exec(t)))throw new Error("invalid format: "+t);var n,r=n[1]||" ",e=n[2]||">",i=n[3]||"-",o=n[4]||"",a=!!n[5],u=n[6]&&+n[6],s=!!n[7],c=n[8]&&+n[8].slice(1),f=n[9]||"";"n"===f?(s=!0,f="g"):l[f]||(f=""),(a||"0"===r&&"="===e)&&(a=!0,r="0",e="="),this.fill=r,this.align=e,this.sign=i,this.symbol=o,this.zero=a,this.width=u,this.comma=s,this.precision=c,this.type=f}function e(n){return p=M(n),t.format=p.format,t.formatPrefix=p.formatPrefix,p}var i,o=function(t,n){if((r=(t=n?t.toExponential(n-1):t.toExponential()).indexOf("e"))<0)return null;var r,e=t.slice(0,r);return[e.length>1?e[0]+e.slice(2):e,+t.slice(r+1)]},a=function(t){return t=o(Math.abs(t)),t?t[1]:NaN},u=function(t,n){return function(r,e){for(var i=r.length,o=[],a=0,u=t[0],s=0;i>0&&u>0&&(s+u+1>e&&(u=Math.max(1,e-s)),o.push(r.substring(i-=u,i+u)),!((s+=u+1)>e));)u=t[a=(a+1)%t.length];return o.reverse().join(n)}},s=function(t){return function(n){return n.replace(/[0-9]/g,function(n){return t[+n]})}},c=function(t,n){t=t.toPrecision(n);t:for(var r,e=t.length,i=1,o=-1;i<e;++i)switch(t[i]){case".":o=r=i;break;case"0":0===o&&(o=i),r=i;break;case"e":break t;default:o>0&&(o=0)}return o>0?t.slice(0,o)+t.slice(r+1):t},f=function(t,n){var r=o(t,n);if(!r)return t+"";var e=r[0],a=r[1],u=a-(i=3*Math.max(-8,Math.min(8,Math.floor(a/3))))+1,s=e.length;return u===s?e:u>s?e+new Array(u-s+1).join("0"):u>0?e.slice(0,u)+"."+e.slice(u):"0."+new Array(1-u).join("0")+o(t,Math.max(0,n+u-1))[0]},h=function(t,n){var r=o(t,n);if(!r)return t+"";var e=r[0],i=r[1];return i<0?"0."+new Array(-i).join("0")+e:e.length>i+1?e.slice(0,i+1)+"."+e.slice(i+1):e+new Array(i-e.length+2).join("0")},l={"":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 h(100*t,n)},r:h,s:f,X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}},m=/^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;n.prototype=r.prototype,r.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(null==this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(null==this.precision?"":"."+Math.max(0,0|this.precision))+this.type};var p,g=function(t){return t},d=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],M=function(t){function r(t){function r(t){var n,r,s,c=y,l=b;if("c"===x)l=v(t)+l,t="";else{t=+t;var j=t<0;if(t=v(Math.abs(t),M),j&&0==+t&&(j=!1),c=(j?"("===u?u:"-":"-"===u||"("===u?"":u)+c,l=l+("s"===x?d[8+i/3]:"")+(j&&"("===u?")":""),w)for(n=-1,r=t.length;++n<r;)if(48>(s=t.charCodeAt(n))||s>57){l=(46===s?f+t.slice(n+1):t.slice(n))+l,t=t.slice(0,n);break}}g&&!m&&(t=o(t,1/0));var k=c.length+t.length+l.length,P=k<p?new Array(p-k+1).join(e):"";switch(g&&m&&(t=o(P+t,P.length?p-l.length:1/0),P=""),a){case"<":t=c+t+l+P;break;case"=":t=c+P+t+l;break;case"^":t=P.slice(0,k=P.length>>1)+c+t+l+P.slice(k);break;default:t=P+c+t+l}return h(t)}t=n(t);var e=t.fill,a=t.align,u=t.sign,s=t.symbol,m=t.zero,p=t.width,g=t.comma,M=t.precision,x=t.type,y="$"===s?c[0]:"#"===s&&/[boxX]/.test(x)?"0"+x.toLowerCase():"",b="$"===s?c[1]:/[%p]/.test(x)?"%":"",v=l[x],w=!x||/[defgprs%]/.test(x);return M=null==M?x?6:12:/[gprs]/.test(x)?Math.max(1,Math.min(21,M)):Math.max(0,Math.min(20,M)),r.toString=function(){return t+""},r}function e(t,e){var i=r((t=n(t),t.type="f",t)),o=3*Math.max(-8,Math.min(8,Math.floor(a(e)/3))),u=Math.pow(10,-o),s=d[8+o/3];return function(t){return i(u*t)+s}}var o=t.grouping&&t.thousands?u(t.grouping,t.thousands):g,c=t.currency,f=t.decimal,h=t.numerals?s(t.numerals):g;return{format:r,formatPrefix:e}};e({decimal:".",thousands:",",grouping:[3],currency:["$",""]});var x=function(t){return Math.max(0,-a(Math.abs(t)))},y=function(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(a(n)/3)))-a(Math.abs(t)))},b=function(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,a(n)-a(t))+1};t.formatDefaultLocale=e,t.formatLocale=M,t.formatSpecifier=n,t.precisionFixed=x,t.precisionPrefix=y,t.precisionRound=b,Object.defineProperty(t,"__esModule",{value:!0})});
// https://d3js.org/d3-format/ Version 1.2.0. Copyright 2017 Mike Bostock.
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.d3=t.d3||{})}(this,function(t){"use strict";function n(t){return new r(t)}function r(t){if(!(n=m.exec(t)))throw new Error("invalid format: "+t);var n,r=n[1]||" ",e=n[2]||">",i=n[3]||"-",o=n[4]||"",a=!!n[5],u=n[6]&&+n[6],s=!!n[7],c=n[8]&&+n[8].slice(1),f=n[9]||"";"n"===f?(s=!0,f="g"):l[f]||(f=""),(a||"0"===r&&"="===e)&&(a=!0,r="0",e="="),this.fill=r,this.align=e,this.sign=i,this.symbol=o,this.zero=a,this.width=u,this.comma=s,this.precision=c,this.type=f}function e(n){return p=M(n),t.format=p.format,t.formatPrefix=p.formatPrefix,p}var i,o=function(t,n){if((r=(t=n?t.toExponential(n-1):t.toExponential()).indexOf("e"))<0)return null;var r,e=t.slice(0,r);return[e.length>1?e[0]+e.slice(2):e,+t.slice(r+1)]},a=function(t){return t=o(Math.abs(t)),t?t[1]:NaN},u=function(t,n){return function(r,e){for(var i=r.length,o=[],a=0,u=t[0],s=0;i>0&&u>0&&(s+u+1>e&&(u=Math.max(1,e-s)),o.push(r.substring(i-=u,i+u)),!((s+=u+1)>e));)u=t[a=(a+1)%t.length];return o.reverse().join(n)}},s=function(t){return function(n){return n.replace(/[0-9]/g,function(n){return t[+n]})}},c=function(t,n){t=t.toPrecision(n);t:for(var r,e=t.length,i=1,o=-1;i<e;++i)switch(t[i]){case".":o=r=i;break;case"0":0===o&&(o=i),r=i;break;case"e":break t;default:o>0&&(o=0)}return o>0?t.slice(0,o)+t.slice(r+1):t},f=function(t,n){var r=o(t,n);if(!r)return t+"";var e=r[0],a=r[1],u=a-(i=3*Math.max(-8,Math.min(8,Math.floor(a/3))))+1,s=e.length;return u===s?e:u>s?e+new Array(u-s+1).join("0"):u>0?e.slice(0,u)+"."+e.slice(u):"0."+new Array(1-u).join("0")+o(t,Math.max(0,n+u-1))[0]},h=function(t,n){var r=o(t,n);if(!r)return t+"";var e=r[0],i=r[1];return i<0?"0."+new Array(-i).join("0")+e:e.length>i+1?e.slice(0,i+1)+"."+e.slice(i+1):e+new Array(i-e.length+2).join("0")},l={"":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 h(100*t,n)},r:h,s:f,X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}},m=/^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;n.prototype=r.prototype,r.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(null==this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(null==this.precision?"":"."+Math.max(0,0|this.precision))+this.type};var p,g=function(t){return t},d=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],M=function(t){function r(t){function r(t){var n,r,s,c=b,l=v;if("c"===y)l=w(t)+l,t="";else{t=+t;var m=t<0;if(t=w(Math.abs(t),x),m&&0==+t&&(m=!1),c=(m?"("===u?u:"-":"-"===u||"("===u?"":u)+c,l=l+("s"===y?d[8+i/3]:"")+(m&&"("===u?")":""),j)for(n=-1,r=t.length;++n<r;)if(48>(s=t.charCodeAt(n))||s>57){l=(46===s?f+t.slice(n+1):t.slice(n))+l,t=t.slice(0,n);break}}M&&!p&&(t=o(t,1/0));var k=c.length+t.length+l.length,P=k<g?new Array(g-k+1).join(e):"";switch(M&&p&&(t=o(P+t,P.length?g-l.length:1/0),P=""),a){case"<":t=c+t+l+P;break;case"=":t=c+P+t+l;break;case"^":t=P.slice(0,k=P.length>>1)+c+t+l+P.slice(k);break;default:t=P+c+t+l}return h(t)}t=n(t);var e=t.fill,a=t.align,u=t.sign,s=t.symbol,p=t.zero,g=t.width,M=t.comma,x=t.precision,y=t.type,b="$"===s?c[0]:"#"===s&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",v="$"===s?c[1]:/[%p]/.test(y)?m:"",w=l[y],j=!y||/[defgprs%]/.test(y);return x=null==x?y?6:12:/[gprs]/.test(y)?Math.max(1,Math.min(21,x)):Math.max(0,Math.min(20,x)),r.toString=function(){return t+""},r}function e(t,e){var i=r((t=n(t),t.type="f",t)),o=3*Math.max(-8,Math.min(8,Math.floor(a(e)/3))),u=Math.pow(10,-o),s=d[8+o/3];return function(t){return i(u*t)+s}}var o=t.grouping&&t.thousands?u(t.grouping,t.thousands):g,c=t.currency,f=t.decimal,h=t.numerals?s(t.numerals):g,m=t.percent||"%";return{format:r,formatPrefix:e}};e({decimal:".",thousands:",",grouping:[3],currency:["$",""]});var x=function(t){return Math.max(0,-a(Math.abs(t)))},y=function(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(a(n)/3)))-a(Math.abs(t)))},b=function(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,a(n)-a(t))+1};t.formatDefaultLocale=e,t.formatLocale=M,t.formatSpecifier=n,t.precisionFixed=x,t.precisionPrefix=y,t.precisionRound=b,Object.defineProperty(t,"__esModule",{value:!0})});

@@ -5,3 +5,4 @@ {

"grouping": [3],
"currency": ["", "\u00a0€"]
"currency": ["", "\u00a0€"],
"percent": "\u202f%"
}
{
"name": "d3-format",
"version": "1.1.1",
"version": "1.2.0",
"description": "Format numbers for human consumption.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -309,2 +309,3 @@ # d3-format

* `numerals` - optional; an array of ten strings to replace the numerals 0-9.
* `percent` - optional; the percent suffix (defaults to `"%"`).

@@ -311,0 +312,0 @@ Note that the *thousands* property is a misnomer, as the grouping definition allows groups other than thousands.

@@ -15,3 +15,4 @@ import exponent from "./exponent";

decimal = locale.decimal,
numerals = locale.numerals ? formatNumerals(locale.numerals) : identity;
numerals = locale.numerals ? formatNumerals(locale.numerals) : identity,
percent = locale.percent || "%";

@@ -34,3 +35,3 @@ function newFormat(specifier) {

var prefix = symbol === "$" ? currency[0] : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "",
suffix = symbol === "$" ? currency[1] : /[%p]/.test(type) ? "%" : "";
suffix = symbol === "$" ? currency[1] : /[%p]/.test(type) ? percent : "";

@@ -37,0 +38,0 @@ // What format function should we use?

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc