Comparing version 0.3.3 to 0.3.4
@@ -14,2 +14,9 @@ (function (global, factory) { | ||
var svSe = { | ||
decimal: ",", | ||
thousands: "\xa0", | ||
grouping: [3], | ||
currency: ["", "SEK"] | ||
}; | ||
var ruRu = { | ||
@@ -50,2 +57,9 @@ decimal: ",", | ||
var koKr = { | ||
decimal: ".", | ||
thousands: ",", | ||
grouping: [3], | ||
currency: ["₩", ""] | ||
}; | ||
var jaJp = { | ||
@@ -65,2 +79,9 @@ decimal: ".", | ||
var huHu = { | ||
decimal: ",", | ||
thousands: "\xa0", | ||
grouping: [3], | ||
currency: ["", "\xa0Ft"] | ||
}; | ||
var heIl = { | ||
@@ -129,2 +150,9 @@ decimal: ".", | ||
var deCh = { | ||
decimal: ",", | ||
thousands: "'", | ||
grouping: [3], | ||
currency: ["", "\xa0CHF"] | ||
}; | ||
var caEs = { | ||
@@ -137,3 +165,2 @@ decimal: ",", | ||
// Computes the decimal coefficient and exponent of the specified number x with | ||
@@ -152,8 +179,27 @@ // significant digits p, where x is positive and p is in [1, 21] or undefined. | ||
]; | ||
} | ||
}; | ||
function exponent(x) { | ||
function exponent$1(x) { | ||
return x = formatDecimal(Math.abs(x)), x ? x[1] : NaN; | ||
} | ||
}; | ||
function formatGroup(grouping, thousands) { | ||
return function(value, width) { | ||
var i = value.length, | ||
t = [], | ||
j = 0, | ||
g = grouping[0], | ||
length = 0; | ||
while (i > 0 && g > 0) { | ||
if (length + g + 1 > width) g = Math.max(1, width - length); | ||
t.push(value.substring(i -= g, i + g)); | ||
if ((length += g + 1) > width) break; | ||
g = grouping[j = (j + 1) % grouping.length]; | ||
} | ||
return t.reverse().join(thousands); | ||
}; | ||
}; | ||
var prefixExponent; | ||
@@ -171,4 +217,4 @@ | ||
: i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) | ||
: "0." + new Array(1 - i).join("0") + formatDecimal(x, p + i - 1)[0]; // less than 1y! | ||
} | ||
: "0." + new Array(1 - i).join("0") + formatDecimal(x, Math.max(0, p + i - 1))[0]; // less than 1y! | ||
}; | ||
@@ -183,3 +229,3 @@ function formatRounded(x, p) { | ||
: coefficient + new Array(exponent - coefficient.length + 2).join("0"); | ||
} | ||
}; | ||
@@ -199,3 +245,3 @@ function formatDefault(x, p) { | ||
return i0 > 0 ? x.slice(0, i0) + x.slice(i1 + 1) : x; | ||
} | ||
}; | ||
@@ -219,3 +265,2 @@ var formatTypes = { | ||
// [[fill]align][sign][symbol][0][width][,][.precision][type] | ||
@@ -226,3 +271,3 @@ var re = /^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i; | ||
return new FormatSpecifier(specifier); | ||
} | ||
}; | ||
@@ -275,21 +320,2 @@ function FormatSpecifier(specifier) { | ||
function formatGroup(grouping, thousands) { | ||
return function(value, width) { | ||
var i = value.length, | ||
t = [], | ||
j = 0, | ||
g = grouping[0], | ||
length = 0; | ||
while (i > 0 && g > 0) { | ||
if (length + g + 1 > width) g = Math.max(1, width - length); | ||
t.push(value.substring(i -= g, i + g)); | ||
if ((length += g + 1) > width) break; | ||
g = grouping[j = (j + 1) % grouping.length]; | ||
} | ||
return t.reverse().join(thousands); | ||
}; | ||
} | ||
var prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"]; | ||
@@ -395,3 +421,3 @@ | ||
var f = format((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)), | ||
e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3, | ||
e = Math.max(-8, Math.min(8, Math.floor(exponent$1(value) / 3))) * 3, | ||
k = Math.pow(10, -e), | ||
@@ -408,18 +434,19 @@ prefix = prefixes[8 + e / 3]; | ||
}; | ||
} | ||
}; | ||
function precisionRound(step, max) { | ||
return Math.max(0, exponent(Math.abs(max)) - exponent(Math.abs(step))) + 1; | ||
} | ||
return Math.max(0, exponent$1(Math.abs(max)) - exponent$1(Math.abs(step))) + 1; | ||
}; | ||
function precisionFixed(step) { | ||
return Math.max(0, -exponent$1(Math.abs(step))); | ||
}; | ||
function precisionPrefix(step, value) { | ||
return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3 - exponent(Math.abs(step))); | ||
} | ||
return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent$1(value) / 3))) * 3 - exponent$1(Math.abs(step))); | ||
}; | ||
function precisionFixed(step) { | ||
return Math.max(0, -exponent(Math.abs(step))); | ||
} | ||
var localeDefinitions = { | ||
"ca-ES": caEs, | ||
"de-CH": deCh, | ||
"de-DE": deDe, | ||
@@ -434,4 +461,6 @@ "en-CA": enCa, | ||
"he-IL": heIl, | ||
"hu-HU": huHu, | ||
"it-IT": itIt, | ||
"ja-JP": jaJp, | ||
"ko-KR": koKr, | ||
"mk-MK": mkMk, | ||
@@ -442,2 +471,3 @@ "nl-NL": nlNl, | ||
"ru-RU": ruRu, | ||
"sv-SE": svSe, | ||
"zh-CN": zhCn | ||
@@ -447,4 +477,4 @@ }; | ||
var defaultLocale = locale(enUs); | ||
exports.format = defaultLocale.format; | ||
exports.formatPrefix = defaultLocale.formatPrefix; | ||
var format = defaultLocale.format; | ||
var formatPrefix = defaultLocale.formatPrefix; | ||
@@ -457,5 +487,6 @@ function localeFormat(definition) { | ||
return locale(definition); | ||
} | ||
; | ||
}; | ||
exports.format = format; | ||
exports.formatPrefix = formatPrefix; | ||
exports.localeFormat = localeFormat; | ||
@@ -462,0 +493,0 @@ exports.formatSpecifier = formatSpecifier; |
@@ -1,1 +0,1 @@ | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.format={})}(this,function(n){"use strict";function r(n,r){if((t=(n=r?n.toExponential(r-1):n.toExponential()).indexOf("e"))<0)return null;var t,e=n.slice(0,t);return[e.length>1?e[0]+e.slice(2):e,+n.slice(t+1)]}function t(n){return n=r(Math.abs(n)),n?n[1]:NaN}function e(n,t){var e=r(n,t);if(!e)return n+"";var i=e[0],o=e[1],a=o-(m=3*Math.max(-8,Math.min(8,Math.floor(o/3))))+1,u=i.length;return a===u?i:a>u?i+new Array(a-u+1).join("0"):a>0?i.slice(0,a)+"."+i.slice(a):"0."+new Array(1-a).join("0")+r(n,t+a-1)[0]}function i(n,t){var e=r(n,t);if(!e)return n+"";var i=e[0],o=e[1];return 0>o?"0."+new Array(-o).join("0")+i:i.length>o+1?i.slice(0,o+1)+"."+i.slice(o+1):i+new Array(o-i.length+2).join("0")}function o(n,r){n=n.toPrecision(r);n:for(var t,e=n.length,i=1,o=-1;e>i;++i)switch(n[i]){case".":o=t=i;break;case"0":0===o&&(o=i),t=i;break;case"e":break n;default:o>0&&(o=0)}return o>0?n.slice(0,o)+n.slice(t+1):n}function a(n){return new u(n)}function u(n){if(!(r=N.exec(n)))throw new Error("invalid format: "+n);var r,t=r[1]||" ",e=r[2]||">",i=r[3]||"-",o=r[4]||"",a=!!r[5],u=r[6]&&+r[6],c=!!r[7],s=r[8]&&+r[8].slice(1),h=r[9]||"";"n"===h?(c=!0,h="g"):L[h]||(h=""),(a||"0"===t&&"="===e)&&(a=!0,t="0",e="="),this.fill=t,this.align=e,this.sign=i,this.symbol=o,this.zero=a,this.width=u,this.comma=c,this.precision=s,this.type=h}function c(n,r){return function(t,e){for(var i=t.length,o=[],a=0,u=n[0],c=0;i>0&&u>0&&(c+u+1>e&&(u=Math.max(1,e-c)),o.push(t.substring(i-=u,i+u)),!((c+=u+1)>e));)u=n[a=(a+1)%n.length];return o.reverse().join(r)}}function s(n){return n}function h(n){function r(n){n=a(n);var r=n.fill,t=n.align,e=n.sign,c=n.symbol,s=n.zero,h=n.width,l=n.comma,f=n.precision,g=n.type,d="$"===c?o[0]:"#"===c&&/[boxX]/.test(g)?"0"+g.toLowerCase():"",p="$"===c?o[1]:/[%p]/.test(g)?"%":"",y=L[g],M=!g||/[defgprs%]/.test(g);return f=null==f?g?6:12:/[gprs]/.test(g)?Math.max(1,Math.min(21,f)):Math.max(0,Math.min(20,f)),function(n){var o=d,a=p;if("c"===g)a=y(n)+a,n="";else{n=+n;var c=(0>n||0>1/n)&&(n*=-1,!0);if(n=y(n,f),o=(c?"("===e?e:"-":"-"===e||"("===e?"":e)+o,a=a+("s"===g?I[8+m/3]:"")+(c&&"("===e?")":""),M)for(var x,v=-1,w=n.length;++v<w;)if(x=n.charCodeAt(v),48>x||x>57){a=(46===x?u+n.slice(v+1):n.slice(v))+a,n=n.slice(0,v);break}}l&&!s&&(n=i(n,1/0));var b=o.length+n.length+a.length,P=h>b?new Array(h-b+1).join(r):"";switch(l&&s&&(n=i(P+n,P.length?h-a.length:1/0),P=""),t){case"<":return o+n+a+P;case"=":return o+P+n+a;case"^":return P.slice(0,b=P.length>>1)+o+n+a+P.slice(b)}return P+o+n+a}}function e(n,e){var i=r((n=a(n),n.type="f",n)),o=3*Math.max(-8,Math.min(8,Math.floor(t(e)/3))),u=Math.pow(10,-o),c=I[8+o/3];return function(n){return i(u*n)+c}}var i=n.grouping&&n.thousands?c(n.grouping,n.thousands):s,o=n.currency,u=n.decimal;return{format:r,formatPrefix:e}}function l(n,r){return Math.max(0,t(Math.abs(r))-t(Math.abs(n)))+1}function f(n,r){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(t(r)/3)))-t(Math.abs(n)))}function g(n){return Math.max(0,-t(Math.abs(n)))}function d(n){if("string"==typeof n){if(!U.hasOwnProperty(n))return null;n=U[n]}return h(n)}var m,p={decimal:".",thousands:",",grouping:[3],currency:["¥",""]},y={decimal:",",thousands:" ",grouping:[3],currency:[""," руб."]},M={decimal:",",thousands:".",grouping:[3],currency:["R$",""]},x={decimal:",",thousands:".",grouping:[3],currency:["","zł"]},v={decimal:",",thousands:".",grouping:[3],currency:["€ ",""]},w={decimal:",",thousands:".",grouping:[3],currency:[""," ден."]},b={decimal:".",thousands:",",grouping:[3],currency:["","円"]},P={decimal:",",thousands:".",grouping:[3],currency:["€",""]},S={decimal:".",thousands:",",grouping:[3],currency:["₪",""]},j={decimal:",",thousands:".",grouping:[3],currency:[""," €"]},A={decimal:",",thousands:" ",grouping:[3],currency:["","$"]},E={decimal:",",thousands:" ",grouping:[3],currency:[""," €"]},$={decimal:",",thousands:".",grouping:[3],currency:[""," €"]},z={decimal:".",thousands:",",grouping:[3],currency:["$",""]},k={decimal:".",thousands:",",grouping:[3],currency:["£",""]},C={decimal:".",thousands:",",grouping:[3],currency:["$",""]},F={decimal:",",thousands:".",grouping:[3],currency:[""," €"]},R={decimal:",",thousands:".",grouping:[3],currency:[""," €"]},L={"":o,"%":function(n,r){return(100*n).toFixed(r)},b:function(n){return Math.round(n).toString(2)},c:function(n){return n+""},d:function(n){return Math.round(n).toString(10)},e:function(n,r){return n.toExponential(r)},f:function(n,r){return n.toFixed(r)},g:function(n,r){return n.toPrecision(r)},o:function(n){return Math.round(n).toString(8)},p:function(n,r){return i(100*n,r)},r:i,s:e,X:function(n){return Math.round(n).toString(16).toUpperCase()},x:function(n){return Math.round(n).toString(16)}},N=/^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;u.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 I=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],U={"ca-ES":R,"de-DE":F,"en-CA":C,"en-GB":k,"en-US":z,"es-ES":$,"fi-FI":E,"fr-CA":A,"fr-FR":j,"he-IL":S,"it-IT":P,"ja-JP":b,"mk-MK":w,"nl-NL":v,"pl-PL":x,"pt-BR":M,"ru-RU":y,"zh-CN":p},B=h(z);n.format=B.format,n.formatPrefix=B.formatPrefix,n.localeFormat=d,n.formatSpecifier=a,n.precisionFixed=g,n.precisionPrefix=f,n.precisionRound=l}); | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.format={})}(this,function(n){"use strict";function r(n,r){if((t=(n=r?n.toExponential(r-1):n.toExponential()).indexOf("e"))<0)return null;var t,e=n.slice(0,t);return[e.length>1?e[0]+e.slice(2):e,+n.slice(t+1)]}function t(n){return n=r(Math.abs(n)),n?n[1]:NaN}function e(n,r){return function(t,e){for(var i=t.length,o=[],u=0,a=n[0],c=0;i>0&&a>0&&(c+a+1>e&&(a=Math.max(1,e-c)),o.push(t.substring(i-=a,i+a)),!((c+=a+1)>e));)a=n[u=(u+1)%n.length];return o.reverse().join(r)}}function i(n,t){var e=r(n,t);if(!e)return n+"";var i=e[0],o=e[1],u=o-(m=3*Math.max(-8,Math.min(8,Math.floor(o/3))))+1,a=i.length;return u===a?i:u>a?i+new Array(u-a+1).join("0"):u>0?i.slice(0,u)+"."+i.slice(u):"0."+new Array(1-u).join("0")+r(n,Math.max(0,t+u-1))[0]}function o(n,t){var e=r(n,t);if(!e)return n+"";var i=e[0],o=e[1];return 0>o?"0."+new Array(-o).join("0")+i:i.length>o+1?i.slice(0,o+1)+"."+i.slice(o+1):i+new Array(o-i.length+2).join("0")}function u(n,r){n=n.toPrecision(r);n:for(var t,e=n.length,i=1,o=-1;e>i;++i)switch(n[i]){case".":o=t=i;break;case"0":0===o&&(o=i),t=i;break;case"e":break n;default:o>0&&(o=0)}return o>0?n.slice(0,o)+n.slice(t+1):n}function a(n){return new c(n)}function c(n){if(!(r=K.exec(n)))throw new Error("invalid format: "+n);var r,t=r[1]||" ",e=r[2]||">",i=r[3]||"-",o=r[4]||"",u=!!r[5],a=r[6]&&+r[6],c=!!r[7],s=r[8]&&+r[8].slice(1),h=r[9]||"";"n"===h?(c=!0,h="g"):I[h]||(h=""),(u||"0"===t&&"="===e)&&(u=!0,t="0",e="="),this.fill=t,this.align=e,this.sign=i,this.symbol=o,this.zero=u,this.width=a,this.comma=c,this.precision=s,this.type=h}function s(n){return n}function h(n){function r(n){n=a(n);var r=n.fill,t=n.align,e=n.sign,i=n.symbol,s=n.zero,h=n.width,l=n.comma,f=n.precision,g=n.type,d="$"===i?u[0]:"#"===i&&/[boxX]/.test(g)?"0"+g.toLowerCase():"",p="$"===i?u[1]:/[%p]/.test(g)?"%":"",y=I[g],M=!g||/[defgprs%]/.test(g);return f=null==f?g?6:12:/[gprs]/.test(g)?Math.max(1,Math.min(21,f)):Math.max(0,Math.min(20,f)),function(n){var i=d,u=p;if("c"===g)u=y(n)+u,n="";else{n=+n;var a=(0>n||0>1/n)&&(n*=-1,!0);if(n=y(n,f),i=(a?"("===e?e:"-":"-"===e||"("===e?"":e)+i,u=u+("s"===g?B[8+m/3]:"")+(a&&"("===e?")":""),M)for(var x,v=-1,w=n.length;++v<w;)if(x=n.charCodeAt(v),48>x||x>57){u=(46===x?c+n.slice(v+1):n.slice(v))+u,n=n.slice(0,v);break}}l&&!s&&(n=o(n,1/0));var b=i.length+n.length+u.length,S=h>b?new Array(h-b+1).join(r):"";switch(l&&s&&(n=o(S+n,S.length?h-u.length:1/0),S=""),t){case"<":return i+n+u+S;case"=":return i+S+n+u;case"^":return S.slice(0,b=S.length>>1)+i+n+u+S.slice(b)}return S+i+n+u}}function i(n,e){var i=r((n=a(n),n.type="f",n)),o=3*Math.max(-8,Math.min(8,Math.floor(t(e)/3))),u=Math.pow(10,-o),c=B[8+o/3];return function(n){return i(u*n)+c}}var o=n.grouping&&n.thousands?e(n.grouping,n.thousands):s,u=n.currency,c=n.decimal;return{format:r,formatPrefix:i}}function l(n,r){return Math.max(0,t(Math.abs(r))-t(Math.abs(n)))+1}function f(n){return Math.max(0,-t(Math.abs(n)))}function g(n,r){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(t(r)/3)))-t(Math.abs(n)))}function d(n){if("string"==typeof n){if(!G.hasOwnProperty(n))return null;n=G[n]}return h(n)}var m,p={decimal:".",thousands:",",grouping:[3],currency:["¥",""]},y={decimal:",",thousands:" ",grouping:[3],currency:["","SEK"]},M={decimal:",",thousands:" ",grouping:[3],currency:[""," руб."]},x={decimal:",",thousands:".",grouping:[3],currency:["R$",""]},v={decimal:",",thousands:".",grouping:[3],currency:["","zł"]},w={decimal:",",thousands:".",grouping:[3],currency:["€ ",""]},b={decimal:",",thousands:".",grouping:[3],currency:[""," ден."]},S={decimal:".",thousands:",",grouping:[3],currency:["₩",""]},E={decimal:".",thousands:",",grouping:[3],currency:["","円"]},P={decimal:",",thousands:".",grouping:[3],currency:["€",""]},j={decimal:",",thousands:" ",grouping:[3],currency:[""," Ft"]},A={decimal:".",thousands:",",grouping:[3],currency:["₪",""]},C={decimal:",",thousands:".",grouping:[3],currency:[""," €"]},F={decimal:",",thousands:" ",grouping:[3],currency:["","$"]},$={decimal:",",thousands:" ",grouping:[3],currency:[""," €"]},k={decimal:",",thousands:".",grouping:[3],currency:[""," €"]},z={decimal:".",thousands:",",grouping:[3],currency:["$",""]},R={decimal:".",thousands:",",grouping:[3],currency:["£",""]},L={decimal:".",thousands:",",grouping:[3],currency:["$",""]},N={decimal:",",thousands:".",grouping:[3],currency:[""," €"]},U={decimal:",",thousands:"'",grouping:[3],currency:[""," CHF"]},H={decimal:",",thousands:".",grouping:[3],currency:[""," €"]},I={"":u,"%":function(n,r){return(100*n).toFixed(r)},b:function(n){return Math.round(n).toString(2)},c:function(n){return n+""},d:function(n){return Math.round(n).toString(10)},e:function(n,r){return n.toExponential(r)},f:function(n,r){return n.toFixed(r)},g:function(n,r){return n.toPrecision(r)},o:function(n){return Math.round(n).toString(8)},p:function(n,r){return o(100*n,r)},r:o,s:i,X:function(n){return Math.round(n).toString(16).toUpperCase()},x:function(n){return Math.round(n).toString(16)}},K=/^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;c.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 B=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],G={"ca-ES":H,"de-CH":U,"de-DE":N,"en-CA":L,"en-GB":R,"en-US":z,"es-ES":k,"fi-FI":$,"fr-CA":F,"fr-FR":C,"he-IL":A,"hu-HU":j,"it-IT":P,"ja-JP":E,"ko-KR":S,"mk-MK":b,"nl-NL":w,"pl-PL":v,"pt-BR":x,"ru-RU":M,"sv-SE":y,"zh-CN":p},O=h(z),T=O.format,X=O.formatPrefix;n.format=T,n.formatPrefix=X,n.localeFormat=d,n.formatSpecifier=a,n.precisionFixed=f,n.precisionPrefix=g,n.precisionRound=l}); |
@@ -8,2 +8,3 @@ import formatSpecifier from "./src/formatSpecifier"; | ||
import caEs from "./src/locale/ca-ES"; | ||
import deCh from "./src/locale/de-CH"; | ||
import deDe from "./src/locale/de-DE"; | ||
@@ -18,4 +19,6 @@ import enCa from "./src/locale/en-CA"; | ||
import heIl from "./src/locale/he-IL"; | ||
import huHu from "./src/locale/hu-HU"; | ||
import itIt from "./src/locale/it-IT"; | ||
import jaJp from "./src/locale/ja-JP"; | ||
import koKr from "./src/locale/ko-KR"; | ||
import mkMk from "./src/locale/mk-MK"; | ||
@@ -26,2 +29,3 @@ import nlNl from "./src/locale/nl-NL"; | ||
import ruRu from "./src/locale/ru-RU"; | ||
import svSe from "./src/locale/sv-SE"; | ||
import zhCn from "./src/locale/zh-CN"; | ||
@@ -31,2 +35,3 @@ | ||
"ca-ES": caEs, | ||
"de-CH": deCh, | ||
"de-DE": deDe, | ||
@@ -41,4 +46,6 @@ "en-CA": enCa, | ||
"he-IL": heIl, | ||
"hu-HU": huHu, | ||
"it-IT": itIt, | ||
"ja-JP": jaJp, | ||
"ko-KR": koKr, | ||
"mk-MK": mkMk, | ||
@@ -49,2 +56,3 @@ "nl-NL": nlNl, | ||
"ru-RU": ruRu, | ||
"sv-SE": svSe, | ||
"zh-CN": zhCn | ||
@@ -51,0 +59,0 @@ }; |
{ | ||
"name": "d3-format", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Format numbers for human consumption.", | ||
@@ -15,3 +15,3 @@ "keywords": [ | ||
}, | ||
"main": "build/format", | ||
"main": "build/format.cjs", | ||
"jsnext:main": "index", | ||
@@ -23,8 +23,8 @@ "repository": { | ||
"scripts": { | ||
"pretest": "mkdir -p build && d3-bundler --format=umd --name=format -- index.js > build/format.js", | ||
"pretest": "mkdir -p build && d3-bundler -x -f cjs -o build/format.cjs.js", | ||
"test": "faucet `find test -name '*-test.js'`", | ||
"prepublish": "npm run test && uglifyjs build/format.js -c -m -o build/format.min.js && rm -f build/format.zip && zip -j build/format.zip -- LICENSE README.md build/format.js build/format.min.js" | ||
"prepublish": "npm run test && d3-bundler -n format -o build/format.js && uglifyjs build/format.js -c -m -o build/format.min.js && rm -f build/format.zip && zip -j build/format.zip -- LICENSE README.md build/format.js build/format.min.js" | ||
}, | ||
"devDependencies": { | ||
"d3-bundler": "~0.2.5", | ||
"d3-bundler": "~0.4.0", | ||
"faucet": "0.0", | ||
@@ -31,0 +31,0 @@ "tape": "4", |
@@ -176,2 +176,3 @@ # d3-format | ||
* `"ca-ES"` - [Catalan (Spain)](https://github.com/d3/d3-format/tree/master/src/locale/ca-ES.js) | ||
* `"de-CH"` - [German (Switzerland)](https://github.com/d3/d3-format/tree/master/src/locale/de-CH.js) | ||
* `"de-DE"` - [German (Germany)](https://github.com/d3/d3-format/tree/master/src/locale/de-DE.js) | ||
@@ -186,4 +187,6 @@ * `"en-CA"` - [English (Canada)](https://github.com/d3/d3-format/tree/master/src/locale/en-CA.js) | ||
* `"he-IL"` - [Hebrew (Israel)](https://github.com/d3/d3-format/tree/master/src/locale/he-IL.js) | ||
* `"hu-HU"` - [Hungarian (Hungary)](https://github.com/d3/d3-format/tree/master/src/locale/hu-HU.js) | ||
* `"it-IT"` - [Italian (Italy)](https://github.com/d3/d3-format/tree/master/src/locale/it-IT.js) | ||
* `"ja-JP"` - [Japanese (Japan)](https://github.com/d3/d3-format/tree/master/src/locale/ja-JP.js) | ||
* `"ko-KR"` - [Korean (South Korea)](https://github.com/d3/d3-format/tree/master/src/locale/ko-KR.js) | ||
* `"mk-MK"` - [Macedonian (Macedonia)](https://github.com/d3/d3-format/tree/master/src/locale/mk-MK.js) | ||
@@ -194,2 +197,3 @@ * `"nl-NL"` - [Dutch (Netherlands)](https://github.com/d3/d3-format/tree/master/src/locale/nl-NL.js) | ||
* `"ru-RU"` - [Russian (Russia)](https://github.com/d3/d3-format/tree/master/src/locale/ru-RU.js) | ||
* `"sv-SE"` - [Swedish (Sweden)](https://github.com/d3/d3-format/tree/master/src/locale/sv-SE.js) | ||
* `"zh-CN"` - [Chinese (China)](https://github.com/d3/d3-format/tree/master/src/locale/zh-CN.js) | ||
@@ -196,0 +200,0 @@ |
@@ -15,3 +15,3 @@ import formatDecimal from "./formatDecimal"; | ||
: i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) | ||
: "0." + new Array(1 - i).join("0") + formatDecimal(x, p + i - 1)[0]; // less than 1y! | ||
: "0." + new Array(1 - i).join("0") + formatDecimal(x, Math.max(0, p + i - 1))[0]; // less than 1y! | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64160
42
1253
308