Comparing version 0.5.1 to 0.6.0
@@ -0,5 +1,6 @@ | ||
// https://d3js.org/d3-format/ Version 0.6.0. Copyright 2016 Mike Bostock. | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.d3_format = {}))); | ||
(factory((global.d3 = global.d3 || {}))); | ||
}(this, function (exports) { 'use strict'; | ||
@@ -161,3 +162,13 @@ | ||
function locale(locale) { | ||
var defaultLocale = formatLocale({ | ||
decimal: ".", | ||
thousands: ",", | ||
grouping: [3], | ||
currency: ["$", ""] | ||
}); | ||
var format = defaultLocale.format; | ||
var formatPrefix = defaultLocale.formatPrefix; | ||
function formatLocale(locale) { | ||
var group = locale.grouping && locale.thousands ? formatGroup(locale.grouping, locale.thousands) : identity, | ||
@@ -292,163 +303,2 @@ currency = locale.currency, | ||
var defaultLocale = locale({ | ||
decimal: ".", | ||
thousands: ",", | ||
grouping: [3], | ||
currency: ["$", ""] | ||
}); | ||
var caES = locale({ | ||
decimal: ",", | ||
thousands: ".", | ||
grouping: [3], | ||
currency: ["", "\xa0€"] | ||
}); | ||
var csCZ = locale({ | ||
decimal: ",", | ||
thousands: "\xa0", | ||
grouping: [3], | ||
currency: ["", "\xa0Kč"] | ||
}); | ||
var deCH = locale({ | ||
decimal: ",", | ||
thousands: "'", | ||
grouping: [3], | ||
currency: ["", "\xa0CHF"] | ||
}); | ||
var deDE = locale({ | ||
decimal: ",", | ||
thousands: ".", | ||
grouping: [3], | ||
currency: ["", "\xa0€"] | ||
}); | ||
var enCA = locale({ | ||
decimal: ".", | ||
thousands: ",", | ||
grouping: [3], | ||
currency: ["$", ""] | ||
}); | ||
var enGB = locale({ | ||
decimal: ".", | ||
thousands: ",", | ||
grouping: [3], | ||
currency: ["£", ""] | ||
}); | ||
var esES = locale({ | ||
decimal: ",", | ||
thousands: ".", | ||
grouping: [3], | ||
currency: ["", "\xa0€"] | ||
}); | ||
var fiFI = locale({ | ||
decimal: ",", | ||
thousands: "\xa0", | ||
grouping: [3], | ||
currency: ["", "\xa0€"] | ||
}); | ||
var frCA = locale({ | ||
decimal: ",", | ||
thousands: "\xa0", | ||
grouping: [3], | ||
currency: ["", "$"] | ||
}); | ||
var frFR = locale({ | ||
decimal: ",", | ||
thousands: ".", | ||
grouping: [3], | ||
currency: ["", "\xa0€"] | ||
}); | ||
var heIL = locale({ | ||
decimal: ".", | ||
thousands: ",", | ||
grouping: [3], | ||
currency: ["₪", ""] | ||
}); | ||
var huHU = locale({ | ||
decimal: ",", | ||
thousands: "\xa0", | ||
grouping: [3], | ||
currency: ["", "\xa0Ft"] | ||
}); | ||
var itIT = locale({ | ||
decimal: ",", | ||
thousands: ".", | ||
grouping: [3], | ||
currency: ["€", ""] | ||
}); | ||
var jaJP = locale({ | ||
decimal: ".", | ||
thousands: ",", | ||
grouping: [3], | ||
currency: ["", "円"] | ||
}); | ||
var koKR = locale({ | ||
decimal: ".", | ||
thousands: ",", | ||
grouping: [3], | ||
currency: ["₩", ""] | ||
}); | ||
var mkMK = locale({ | ||
decimal: ",", | ||
thousands: ".", | ||
grouping: [3], | ||
currency: ["", "\xa0ден."] | ||
}); | ||
var nlNL = locale({ | ||
decimal: ",", | ||
thousands: ".", | ||
grouping: [3], | ||
currency: ["€\xa0", ""] | ||
}); | ||
var plPL = locale({ | ||
decimal: ",", | ||
thousands: ".", | ||
grouping: [3], | ||
currency: ["", "zł"] | ||
}); | ||
var ptBR = locale({ | ||
decimal: ",", | ||
thousands: ".", | ||
grouping: [3], | ||
currency: ["R$", ""] | ||
}); | ||
var ruRU = locale({ | ||
decimal: ",", | ||
thousands: "\xa0", | ||
grouping: [3], | ||
currency: ["", "\xa0руб."] | ||
}); | ||
var svSE = locale({ | ||
decimal: ",", | ||
thousands: "\xa0", | ||
grouping: [3], | ||
currency: ["", "SEK"] | ||
}); | ||
var zhCN = locale({ | ||
decimal: ".", | ||
thousands: ",", | ||
grouping: [3], | ||
currency: ["¥", ""] | ||
}); | ||
function precisionFixed(step) { | ||
@@ -467,34 +317,5 @@ return Math.max(0, -exponent(Math.abs(step))); | ||
var format = defaultLocale.format; | ||
var formatPrefix = defaultLocale.formatPrefix; | ||
var version = "0.5.1"; | ||
exports.version = version; | ||
exports.formatLocale = formatLocale; | ||
exports.format = format; | ||
exports.formatPrefix = formatPrefix; | ||
exports.formatLocale = locale; | ||
exports.formatCaEs = caES; | ||
exports.formatCsCz = csCZ; | ||
exports.formatDeCh = deCH; | ||
exports.formatDeDe = deDE; | ||
exports.formatEnCa = enCA; | ||
exports.formatEnGb = enGB; | ||
exports.formatEnUs = defaultLocale; | ||
exports.formatEsEs = esES; | ||
exports.formatFiFi = fiFI; | ||
exports.formatFrCa = frCA; | ||
exports.formatFrFr = frFR; | ||
exports.formatHeIl = heIL; | ||
exports.formatHuHu = huHU; | ||
exports.formatItIt = itIT; | ||
exports.formatJaJp = jaJP; | ||
exports.formatKoKr = koKR; | ||
exports.formatMkMk = mkMK; | ||
exports.formatNlNl = nlNL; | ||
exports.formatPlPl = plPL; | ||
exports.formatPtBr = ptBR; | ||
exports.formatRuRu = ruRU; | ||
exports.formatSvSe = svSE; | ||
exports.formatZhCn = zhCN; | ||
exports.formatSpecifier = formatSpecifier; | ||
@@ -505,2 +326,4 @@ exports.precisionFixed = precisionFixed; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); |
@@ -1,1 +0,2 @@ | ||
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(r.d3_format={})}(this,function(r){"use strict";function n(r,n){if((t=(r=n?r.toExponential(n-1):r.toExponential()).indexOf("e"))<0)return null;var t,e=r.slice(0,t);return[e.length>1?e[0]+e.slice(2):e,+r.slice(t+1)]}function t(r){return r=n(Math.abs(r)),r?r[1]:NaN}function e(r,n){return function(t,e){for(var i=t.length,o=[],a=0,u=r[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=r[a=(a+1)%r.length];return o.reverse().join(n)}}function i(r,n){r=r.toPrecision(n);r:for(var t,e=r.length,i=1,o=-1;e>i;++i)switch(r[i]){case".":o=t=i;break;case"0":0===o&&(o=i),t=i;break;case"e":break r;default:o>0&&(o=0)}return o>0?r.slice(0,o)+r.slice(t+1):r}function o(r,t){var e=n(r,t);if(!e)return r+"";var i=e[0],o=e[1],a=o-(g=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")+n(r,Math.max(0,t+a-1))[0]}function a(r,t){var e=n(r,t);if(!e)return r+"";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(r){return new c(r)}function c(r){if(!(n=p.exec(r)))throw new Error("invalid format: "+r);var n,t=n[1]||" ",e=n[2]||">",i=n[3]||"-",o=n[4]||"",a=!!n[5],u=n[6]&&+n[6],c=!!n[7],s=n[8]&&+n[8].slice(1),f=n[9]||"";"n"===f?(c=!0,f="g"):d[f]||(f=""),(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=f}function s(r){return r}function f(r){function n(r){function n(r){var n,a,u,s=M,d=x;if("c"===p)d=v(r)+d,r="";else{r=+r;var w=(0>r||0>1/r)&&(r*=-1,!0);if(r=v(r,m),w)for(n=-1,a=r.length,w=!1;++n<a;)if(u=r.charCodeAt(n),u>48&&58>u||"x"===p&&u>96&&103>u||"X"===p&&u>64&&71>u){w=!0;break}if(s=(w?"("===i?i:"-":"-"===i||"("===i?"":i)+s,d=d+("s"===p?y[8+g/3]:"")+(w&&"("===i?")":""),b)for(n=-1,a=r.length;++n<a;)if(u=r.charCodeAt(n),48>u||u>57){d=(46===u?c+r.slice(n+1):r.slice(n))+d,r=r.slice(0,n);break}}l&&!f&&(r=o(r,1/0));var C=s.length+r.length+d.length,E=h>C?new Array(h-C+1).join(t):"";switch(l&&f&&(r=o(E+r,E.length?h-d.length:1/0),E=""),e){case"<":return s+r+d+E;case"=":return s+E+r+d;case"^":return E.slice(0,C=E.length>>1)+s+r+d+E.slice(C)}return E+s+r+d}r=u(r);var t=r.fill,e=r.align,i=r.sign,s=r.symbol,f=r.zero,h=r.width,l=r.comma,m=r.precision,p=r.type,M="$"===s?a[0]:"#"===s&&/[boxX]/.test(p)?"0"+p.toLowerCase():"",x="$"===s?a[1]:/[%p]/.test(p)?"%":"",v=d[p],b=!p||/[defgprs%]/.test(p);return m=null==m?p?6:12:/[gprs]/.test(p)?Math.max(1,Math.min(21,m)):Math.max(0,Math.min(20,m)),n.toString=function(){return r+""},n}function i(r,e){var i=n((r=u(r),r.type="f",r)),o=3*Math.max(-8,Math.min(8,Math.floor(t(e)/3))),a=Math.pow(10,-o),c=y[8+o/3];return function(r){return i(a*r)+c}}var o=r.grouping&&r.thousands?e(r.grouping,r.thousands):s,a=r.currency,c=r.decimal;return{format:n,formatPrefix:i}}function h(r){return Math.max(0,-t(Math.abs(r)))}function l(r,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(t(n)/3)))-t(Math.abs(r)))}function m(r,n){return r=Math.abs(r),n=Math.abs(n)-r,Math.max(0,t(n)-t(r))+1}var g,d={"":i,"%":function(r,n){return(100*r).toFixed(n)},b:function(r){return Math.round(r).toString(2)},c:function(r){return r+""},d:function(r){return Math.round(r).toString(10)},e:function(r,n){return r.toExponential(n)},f:function(r,n){return r.toFixed(n)},g:function(r,n){return r.toPrecision(n)},o:function(r){return Math.round(r).toString(8)},p:function(r,n){return a(100*r,n)},r:a,s:o,X:function(r){return Math.round(r).toString(16).toUpperCase()},x:function(r){return Math.round(r).toString(16)}},p=/^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(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 y=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],M=f({decimal:".",thousands:",",grouping:[3],currency:["$",""]}),x=f({decimal:",",thousands:".",grouping:[3],currency:[""," €"]}),v=f({decimal:",",thousands:" ",grouping:[3],currency:[""," Kč"]}),b=f({decimal:",",thousands:"'",grouping:[3],currency:[""," CHF"]}),w=f({decimal:",",thousands:".",grouping:[3],currency:[""," €"]}),C=f({decimal:".",thousands:",",grouping:[3],currency:["$",""]}),E=f({decimal:".",thousands:",",grouping:[3],currency:["£",""]}),S=f({decimal:",",thousands:".",grouping:[3],currency:[""," €"]}),F=f({decimal:",",thousands:" ",grouping:[3],currency:[""," €"]}),P=f({decimal:",",thousands:" ",grouping:[3],currency:["","$"]}),k=f({decimal:",",thousands:".",grouping:[3],currency:[""," €"]}),$=f({decimal:".",thousands:",",grouping:[3],currency:["₪",""]}),j=f({decimal:",",thousands:" ",grouping:[3],currency:[""," Ft"]}),z=f({decimal:",",thousands:".",grouping:[3],currency:["€",""]}),A=f({decimal:".",thousands:",",grouping:[3],currency:["","円"]}),H=f({decimal:".",thousands:",",grouping:[3],currency:["₩",""]}),K=f({decimal:",",thousands:".",grouping:[3],currency:[""," ден."]}),N=f({decimal:",",thousands:".",grouping:[3],currency:["€ ",""]}),R=f({decimal:",",thousands:".",grouping:[3],currency:["","zł"]}),D=f({decimal:",",thousands:".",grouping:[3],currency:["R$",""]}),I=f({decimal:",",thousands:" ",grouping:[3],currency:[""," руб."]}),X=f({decimal:",",thousands:" ",grouping:[3],currency:["","SEK"]}),G=f({decimal:".",thousands:",",grouping:[3],currency:["¥",""]}),J=M.format,L=M.formatPrefix,U="0.5.1";r.version=U,r.format=J,r.formatPrefix=L,r.formatLocale=f,r.formatCaEs=x,r.formatCsCz=v,r.formatDeCh=b,r.formatDeDe=w,r.formatEnCa=C,r.formatEnGb=E,r.formatEnUs=M,r.formatEsEs=S,r.formatFiFi=F,r.formatFrCa=P,r.formatFrFr=k,r.formatHeIl=$,r.formatHuHu=j,r.formatItIt=z,r.formatJaJp=A,r.formatKoKr=H,r.formatMkMk=K,r.formatNlNl=N,r.formatPlPl=R,r.formatPtBr=D,r.formatRuRu=I,r.formatSvSe=X,r.formatZhCn=G,r.formatSpecifier=u,r.precisionFixed=h,r.precisionPrefix=l,r.precisionRound=m}); | ||
// https://d3js.org/d3-format/ Version 0.6.0. Copyright 2016 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,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)]}function r(t){return t=n(Math.abs(t)),t?t[1]:NaN}function e(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)}}function i(t,n){t=t.toPrecision(n);t:for(var r,e=t.length,i=1,o=-1;e>i;++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}function o(t,r){var e=n(t,r);if(!e)return t+"";var i=e[0],o=e[1],a=o-(g=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")+n(t,Math.max(0,r+a-1))[0]}function a(t,r){var e=n(t,r);if(!e)return t+"";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(t){return new s(t)}function s(t){if(!(n=p.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"):d[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 c(t){return t}function f(t){function n(t){function n(t){var n,a,u,c=x,d=y;if("c"===p)d=v(t)+d,t="";else{t=+t;var w=(0>t||0>1/t)&&(t*=-1,!0);if(t=v(t,m),w)for(n=-1,a=t.length,w=!1;++n<a;)if(u=t.charCodeAt(n),u>48&&58>u||"x"===p&&u>96&&103>u||"X"===p&&u>64&&71>u){w=!0;break}if(c=(w?"("===i?i:"-":"-"===i||"("===i?"":i)+c,d=d+("s"===p?M[8+g/3]:"")+(w&&"("===i?")":""),b)for(n=-1,a=t.length;++n<a;)if(u=t.charCodeAt(n),48>u||u>57){d=(46===u?s+t.slice(n+1):t.slice(n))+d,t=t.slice(0,n);break}}l&&!f&&(t=o(t,1/0));var j=c.length+t.length+d.length,P=h>j?new Array(h-j+1).join(r):"";switch(l&&f&&(t=o(P+t,P.length?h-d.length:1/0),P=""),e){case"<":return c+t+d+P;case"=":return c+P+t+d;case"^":return P.slice(0,j=P.length>>1)+c+t+d+P.slice(j)}return P+c+t+d}t=u(t);var r=t.fill,e=t.align,i=t.sign,c=t.symbol,f=t.zero,h=t.width,l=t.comma,m=t.precision,p=t.type,x="$"===c?a[0]:"#"===c&&/[boxX]/.test(p)?"0"+p.toLowerCase():"",y="$"===c?a[1]:/[%p]/.test(p)?"%":"",v=d[p],b=!p||/[defgprs%]/.test(p);return m=null==m?p?6:12:/[gprs]/.test(p)?Math.max(1,Math.min(21,m)):Math.max(0,Math.min(20,m)),n.toString=function(){return t+""},n}function i(t,e){var i=n((t=u(t),t.type="f",t)),o=3*Math.max(-8,Math.min(8,Math.floor(r(e)/3))),a=Math.pow(10,-o),s=M[8+o/3];return function(t){return i(a*t)+s}}var o=t.grouping&&t.thousands?e(t.grouping,t.thousands):c,a=t.currency,s=t.decimal;return{format:n,formatPrefix:i}}function h(t){return Math.max(0,-r(Math.abs(t)))}function l(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(r(n)/3)))-r(Math.abs(t)))}function m(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,r(n)-r(t))+1}var g,d={"":i,"%":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 a(100*t,n)},r:a,s:o,X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}},p=/^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;s.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 M=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],x=f({decimal:".",thousands:",",grouping:[3],currency:["$",""]}),y=x.format,v=x.formatPrefix;t.formatLocale=f,t.format=y,t.formatPrefix=v,t.formatSpecifier=u,t.precisionFixed=h,t.precisionPrefix=l,t.precisionRound=m,Object.defineProperty(t,"__esModule",{value:!0})}); |
28
index.js
@@ -1,26 +0,2 @@ | ||
import defaultLocale from "./src/locale/en-US"; | ||
export {default as formatLocale} from "./src/locale"; | ||
export {default as formatCaEs} from "./src/locale/ca-ES"; | ||
export {default as formatCsCz} from "./src/locale/cs-CZ"; | ||
export {default as formatDeCh} from "./src/locale/de-CH"; | ||
export {default as formatDeDe} from "./src/locale/de-DE"; | ||
export {default as formatEnCa} from "./src/locale/en-CA"; | ||
export {default as formatEnGb} from "./src/locale/en-GB"; | ||
export {default as formatEnUs} from "./src/locale/en-US"; | ||
export {default as formatEsEs} from "./src/locale/es-ES"; | ||
export {default as formatFiFi} from "./src/locale/fi-FI"; | ||
export {default as formatFrCa} from "./src/locale/fr-CA"; | ||
export {default as formatFrFr} from "./src/locale/fr-FR"; | ||
export {default as formatHeIl} from "./src/locale/he-IL"; | ||
export {default as formatHuHu} from "./src/locale/hu-HU"; | ||
export {default as formatItIt} from "./src/locale/it-IT"; | ||
export {default as formatJaJp} from "./src/locale/ja-JP"; | ||
export {default as formatKoKr} from "./src/locale/ko-KR"; | ||
export {default as formatMkMk} from "./src/locale/mk-MK"; | ||
export {default as formatNlNl} from "./src/locale/nl-NL"; | ||
export {default as formatPlPl} from "./src/locale/pl-PL"; | ||
export {default as formatPtBr} from "./src/locale/pt-BR"; | ||
export {default as formatRuRu} from "./src/locale/ru-RU"; | ||
export {default as formatSvSe} from "./src/locale/sv-SE"; | ||
export {default as formatZhCn} from "./src/locale/zh-CN"; | ||
export {default as formatLocale, format, formatPrefix} from "./src/locale"; | ||
export {default as formatSpecifier} from "./src/formatSpecifier"; | ||
@@ -30,3 +6,1 @@ export {default as precisionFixed} from "./src/precisionFixed"; | ||
export {default as precisionRound} from "./src/precisionRound"; | ||
export var format = defaultLocale.format; | ||
export var formatPrefix = defaultLocale.formatPrefix; |
{ | ||
"name": "d3-format", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"description": "Format numbers for human consumption.", | ||
@@ -10,3 +10,3 @@ "keywords": [ | ||
], | ||
"homepage": "https://github.com/d3/d3-format", | ||
"homepage": "https://d3js.org/d3-format/", | ||
"license": "BSD-3-Clause", | ||
@@ -24,10 +24,11 @@ "author": { | ||
"scripts": { | ||
"pretest": "mkdir -p build && node -e 'process.stdout.write(\"var version = \\\"\" + require(\"./package.json\").version + \"\\\"; export * from \\\"../index\\\"; export {version};\");' > build/bundle.js && rollup -f umd -n d3_format -o build/d3-format.js -- build/bundle.js", | ||
"test": "faucet `find test -name '*-test.js'` && eslint index.js src", | ||
"prepublish": "npm run test && uglifyjs build/d3-format.js -c -m -o build/d3-format.min.js && rm -f build/d3-format.zip && zip -j build/d3-format.zip -- LICENSE README.md build/d3-format.js build/d3-format.min.js", | ||
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git tag -am \"Release $VERSION.\" v${VERSION} && git push --tags && cp build/d3-format.js ../d3.github.com/d3-format.v0.5.js && cp build/d3-format.min.js ../d3.github.com/d3-format.v0.5.min.js && cd ../d3.github.com && git add d3-format.v0.5.js d3-format.v0.5.min.js && git commit -m \"d3-format ${VERSION}\" && git push" | ||
"pretest": "rm -rf build && mkdir build && rollup --banner \"$(preamble)\" -f umd -n d3 -o build/d3-format.js -- index.js", | ||
"test": "tape 'test/**/*-test.js' && eslint index.js src", | ||
"prepublish": "npm run test && uglifyjs --preamble \"$(preamble)\" build/d3-format.js -c -m -o build/d3-format.min.js", | ||
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git push --tags && cp build/d3-format.js ../d3.github.com/d3-format.v0.6.js && cp build/d3-format.min.js ../d3.github.com/d3-format.v0.6.min.js && cd ../d3.github.com && git add d3-format.v0.6.js d3-format.v0.6.min.js && git commit -m \"d3-format ${VERSION}\" && git push && cd - && zip -j build/d3-format.zip -- LICENSE README.md build/d3-format.js build/d3-format.min.js" | ||
}, | ||
"devDependencies": { | ||
"faucet": "0.0", | ||
"rollup": "0.25", | ||
"eslint": "2", | ||
"package-preamble": "0.0", | ||
"rollup": "0.27", | ||
"tape": "4", | ||
@@ -34,0 +35,0 @@ "uglify-js": "2" |
107
README.md
@@ -70,9 +70,14 @@ # d3-format | ||
If you use NPM, `npm install d3-format`. Otherwise, download the [latest release](https://github.com/d3/d3-format/releases/latest). The released bundle supports AMD, CommonJS, and vanilla environments. Create a custom build using [Rollup](https://github.com/rollup/rollup) or your preferred bundler. You can also load directly from [d3js.org](https://d3js.org): | ||
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.v0.6.min.js) or as part of [D3 4.0](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.v0.5.min.js"></script> | ||
<script src="https://d3js.org/d3-format.v0.6.min.js"></script> | ||
<script> | ||
var format = d3.format(".2s"); | ||
</script> | ||
``` | ||
In a vanilla environment, a `d3_format` global is exported. [Try d3-format in your browser.](https://tonicdev.com/npm/d3-format) | ||
[Try d3-format in your browser.](https://tonicdev.com/npm/d3-format) | ||
@@ -83,7 +88,7 @@ ## API Reference | ||
An alias for [*locale*.format](#locale_format) on the [U.S. English locale](#formatEnUs). See the other [locales](#locales), or use [formatLocale](#formatLocale) to define a new locale. | ||
An alias for [*locale*.format](#locale_format) on the U.S. English locale. See [formatLocale](#formatLocale) to define a new locale. | ||
<a name="formatPrefix" href="#formatPrefix">#</a> d3.<b>formatPrefix</b>(<i>specifier</i>, <i>value</i>) | ||
An alias for [*locale*.formatPrefix](#locale_formatPrefix) on the [U.S. English locale](#formatEnUs). See the other [locales](#locales), or use [formatLocale](#formatLocale) to define a new locale. | ||
An alias for [*locale*.formatPrefix](#locale_formatPrefix) on the U.S. English locale. See [formatLocale](#formatLocale) to define a new locale. | ||
@@ -293,93 +298,1 @@ <a name="locale_format" href="#locale_format">#</a> <i>locale</i>.<b>format</b>(<i>specifier</i>) | ||
Note that the *thousands* property is a misnomer, as the grouping definition allows groups other than thousands. | ||
<a name="formatCaEs" href="#formatCaEs">#</a> d3.<b>formatCaEs</b> | ||
[Catalan (Spain)](https://github.com/d3/d3-format/tree/master/src/locale/ca-ES.js) | ||
<a name="formatCsCz" href="#formatCsCz">#</a> d3.<b>formatCsCz</b> | ||
[Czech (Czech Republic)](https://github.com/d3/d3-format/tree/master/src/locale/cs-CZ.js) | ||
<a name="formatDeCh" href="#formatDeCh">#</a> d3.<b>formatDeCh</b> | ||
[German (Switzerland)](https://github.com/d3/d3-format/tree/master/src/locale/de-CH.js) | ||
<a name="formatDeDe" href="#formatDeDe">#</a> d3.<b>formatDeDe</b> | ||
[German (Germany)](https://github.com/d3/d3-format/tree/master/src/locale/de-DE.js) | ||
<a name="formatEnCa" href="#formatEnCa">#</a> d3.<b>formatEnCa</b> | ||
[English (Canada)](https://github.com/d3/d3-format/tree/master/src/locale/en-CA.js) | ||
<a name="formatEnGb" href="#formatEnGb">#</a> d3.<b>formatEnGb</b> | ||
[English (United Kingdom)](https://github.com/d3/d3-format/tree/master/src/locale/en-GB.js) | ||
<a name="formatEnUs" href="#formatEnUs">#</a> d3.<b>formatEnUs</b> | ||
[English (United States)](https://github.com/d3/d3-format/tree/master/src/locale/en-US.js) | ||
<a name="formatEsEs" href="#formatEsEs">#</a> d3.<b>formatEsEs</b> | ||
[Spanish (Spain)](https://github.com/d3/d3-format/tree/master/src/locale/es-ES.js) | ||
<a name="formatFiFi" href="#formatFiFi">#</a> d3.<b>formatFiFi</b> | ||
[Finnish (Finland)](https://github.com/d3/d3-format/tree/master/src/locale/fi-FI.js) | ||
<a name="formatFrCa" href="#formatFrCa">#</a> d3.<b>formatFrCa</b> | ||
[French (Canada)](https://github.com/d3/d3-format/tree/master/src/locale/fr-CA.js) | ||
<a name="formatFrFr" href="#formatFrFr">#</a> d3.<b>formatFrFr</b> | ||
[French (France)](https://github.com/d3/d3-format/tree/master/src/locale/fr-FR.js) | ||
<a name="formatHeIl" href="#formatHeIl">#</a> d3.<b>formatHeIl</b> | ||
[Hebrew (Israel)](https://github.com/d3/d3-format/tree/master/src/locale/he-IL.js) | ||
<a name="formatHuHu" href="#formatHuHu">#</a> d3.<b>formatHuHu</b> | ||
[Hungarian (Hungary)](https://github.com/d3/d3-format/tree/master/src/locale/hu-HU.js) | ||
<a name="formatItIt" href="#formatItIt">#</a> d3.<b>formatItIt</b> | ||
[Italian (Italy)](https://github.com/d3/d3-format/tree/master/src/locale/it-IT.js) | ||
<a name="formatJaJp" href="#formatJaJp">#</a> d3.<b>formatJaJp</b> | ||
[Japanese (Japan)](https://github.com/d3/d3-format/tree/master/src/locale/ja-JP.js) | ||
<a name="formatKoKr" href="#formatKoKr">#</a> d3.<b>formatKoKr</b> | ||
[Korean (South Korea)](https://github.com/d3/d3-format/tree/master/src/locale/ko-KR.js) | ||
<a name="formatMkMk" href="#formatMkMk">#</a> d3.<b>formatMkMk</b> | ||
[Macedonian (Macedonia)](https://github.com/d3/d3-format/tree/master/src/locale/mk-MK.js) | ||
<a name="formatNlNl" href="#formatNlNl">#</a> d3.<b>formatNlNl</b> | ||
[Dutch (Netherlands)](https://github.com/d3/d3-format/tree/master/src/locale/nl-NL.js) | ||
<a name="formatPlPl" href="#formatPlPl">#</a> d3.<b>formatPlPl</b> | ||
[Polish (Poland)](https://github.com/d3/d3-format/tree/master/src/locale/pl-PL.js) | ||
<a name="formatPtBr" href="#formatPtBr">#</a> d3.<b>formatPtBr</b> | ||
[Portuguese (Brazil)](https://github.com/d3/d3-format/tree/master/src/locale/pt-BR.js) | ||
<a name="formatRuRu" href="#formatRuRu">#</a> d3.<b>formatRuRu</b> | ||
[Russian (Russia)](https://github.com/d3/d3-format/tree/master/src/locale/ru-RU.js) | ||
<a name="formatSvSe" href="#formatSvSe">#</a> d3.<b>formatSvSe</b> | ||
[Swedish (Sweden)](https://github.com/d3/d3-format/tree/master/src/locale/sv-SE.js) | ||
<a name="formatZhCn" href="#formatZhCn">#</a> d3.<b>formatZhCn</b> | ||
[Chinese (China)](https://github.com/d3/d3-format/tree/master/src/locale/zh-CN.js) |
@@ -13,3 +13,13 @@ import exponent from "./exponent"; | ||
export default function(locale) { | ||
var defaultLocale = formatLocale({ | ||
decimal: ".", | ||
thousands: ",", | ||
grouping: [3], | ||
currency: ["$", ""] | ||
}); | ||
export var format = defaultLocale.format; | ||
export var formatPrefix = defaultLocale.formatPrefix; | ||
export default function formatLocale(locale) { | ||
var group = locale.grouping && locale.thousands ? formatGroup(locale.grouping, locale.thousands) : identity, | ||
@@ -16,0 +26,0 @@ currency = locale.currency, |
Sorry, the diff of this file is not supported yet
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
45934
5
693
296