Comparing version 1.5.4 to 1.5.5
{ | ||
"name": "numeral", | ||
"repo": "adamwdraper/Numeral-js", | ||
"version": "1.5.4", | ||
"version": "1.5.5", | ||
"description": "Format and manipulate numbers.", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
{ | ||
"name": "numeral", | ||
"repo": "adamwdraper/Numeral-js", | ||
"version": "1.5.4", | ||
"version": "1.5.5", | ||
"description": "Format and manipulate numbers.", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
/*! @preserve | ||
* numeral.js | ||
* version : 1.5.4 | ||
* version : 1.5.5 | ||
* author : Adam Draper | ||
@@ -8,2 +8,2 @@ * license : MIT | ||
*/ | ||
(function(){function a(a){this._value=a}function b(a,b,c,d){var e,f,g,h,i=a.toString().split("."),j=b-(d||0);return e=2===i.length?Math.min(Math.max(i[1].length,j),b):j,g=Math.pow(10,e),h=(c(a*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var d;return d=b.indexOf("$")>-1?e(a,b,c):b.indexOf("%")>-1?f(a,b,c):b.indexOf(":")>-1?g(a,b):i(a._value,b,c)}function d(a,b){var c,d,e,f,g,i=b,j=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],k=["KB","MB","GB","TB","PB","EB","ZB","YB"],l=!1;if(b.indexOf(":")>-1)a._value=h(b);else if(b===q.zeroFormat||b===q.nullFormat)a._value=0;else{for("."!==o[q.currentLanguage].delimiters.decimal&&(b=b.replace(/\./g,"").replace(o[q.currentLanguage].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.thousand+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.million+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.billion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.trillion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),g=0;g<=j.length&&!l;g++)l=b.indexOf(j[g])>-1?Math.pow(1024,g+1):b.indexOf(k[g])>-1?Math.pow(1e3,g+1):!1;a._value=(l?l:1)*(i.match(c)?Math.pow(10,3):1)*(i.match(d)?Math.pow(10,6):1)*(i.match(e)?Math.pow(10,9):1)*(i.match(f)?Math.pow(10,12):1)*(b.indexOf("%")>-1?.01:1)*((b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1)*Number(b.replace(/[^0-9\.]+/g,"")),a._value=l?Math.ceil(a._value):a._value}return a._value}function e(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),j="";return b.indexOf(" $")>-1?(j=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(j=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=i(a._value,b,c),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,o[q.currentLanguage].currency.symbol+j),e=e.join("")):e=o[q.currentLanguage].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+o[q.currentLanguage].currency.symbol),e=e.join("")):e=e+j+o[q.currentLanguage].currency.symbol,e}function f(a,b,c){var d,e="",f=100*a._value;return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=i(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function g(a){var b=Math.floor(a._value/60/60),c=Math.floor((a._value-60*b*60)/60),d=Math.round(a._value-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function h(a){var b=a.split(":"),c=0;return 3===b.length?(c+=60*Number(b[0])*60,c+=60*Number(b[1]),c+=Number(b[2])):2===b.length&&(c+=60*Number(b[0]),c+=Number(b[1])),Number(c)}function i(a,c,d){var e,f,g,h,i,j,k=!1,l=!1,m=!1,n="",p=!1,r=!1,s=!1,t=!1,u=!1,v="",w="",x=Math.abs(a),y=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],z=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],A="",B=!1;if(0===a&&null!==q.zeroFormat)return q.zeroFormat;if(null===a&&null!==q.nullFormat)return q.nullFormat;if(c.indexOf("(")>-1?(k=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(l=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(p=c.indexOf("aK")>=0,r=c.indexOf("aM")>=0,s=c.indexOf("aB")>=0,t=c.indexOf("aT")>=0,u=p||r||s||t,c.indexOf(" a")>-1&&(n=" "),c=c.replace(new RegExp(n+"a[KMBT]?"),""),x>=Math.pow(10,12)&&!u||t?(n+=o[q.currentLanguage].abbreviations.trillion,a/=Math.pow(10,12)):x<Math.pow(10,12)&&x>=Math.pow(10,9)&&!u||s?(n+=o[q.currentLanguage].abbreviations.billion,a/=Math.pow(10,9)):x<Math.pow(10,9)&&x>=Math.pow(10,6)&&!u||r?(n+=o[q.currentLanguage].abbreviations.million,a/=Math.pow(10,6)):(x<Math.pow(10,6)&&x>=Math.pow(10,3)&&!u||p)&&(n+=o[q.currentLanguage].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("b")>-1)for(c.indexOf(" b")>-1?(v=" ",c=c.replace(" b","")):c=c.replace("b",""),g=0;g<=y.length;g++)if(e=Math.pow(1024,g),f=Math.pow(1024,g+1),a>=e&&f>a){v+=y[g],e>0&&(a/=e);break}if(c.indexOf("d")>-1)for(c.indexOf(" d")>-1?(v=" ",c=c.replace(" d","")):c=c.replace("d",""),g=0;g<=z.length;g++)if(e=Math.pow(1e3,g),f=Math.pow(1e3,g+1),a>=e&&f>a){v+=z[g],e>0&&(a/=e);break}return c.indexOf("o")>-1&&(c.indexOf(" o")>-1?(w=" ",c=c.replace(" o","")):c=c.replace("o",""),w+=o[q.currentLanguage].ordinal(a)),c.indexOf("[.]")>-1&&(m=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(i.indexOf("[")>-1?(i=i.replace("]",""),i=i.split("["),A=b(a,i[0].length+i[1].length,d,i[1].length)):A=b(a,i.length,d),h=A.split(".")[0],A=A.indexOf(".")>-1?o[q.currentLanguage].delimiters.decimal+A.split(".")[1]:"",m&&0===Number(A.slice(1))&&(A="")):h=b(a,null,d),h.indexOf("-")>-1&&(h=h.slice(1),B=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+o[q.currentLanguage].delimiters.thousands)),0===c.indexOf(".")&&(h=""),(k&&B?"(":"")+(!k&&B?"-":"")+(!B&&l?"+":"")+h+A+(w?w:"")+(n?n:"")+(v?v:"")+(k&&B?")":"")}function j(a,b){o[a]=b}function k(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function l(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=k(a),d=k(b);return c>d?c:d},-(1/0))}var m,n="1.5.4",o={},p={currentLanguage:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},q={currentLanguage:p.currentLanguage,zeroFormat:p.zeroFormat,nullFormat:p.nullFormat,defaultFormat:p.defaultFormat};m=function(b){return m.isNumeral(b)?b=b.value():0===b||"undefined"==typeof b?b=0:null===b?b=null:Number(b)||(b=m.fn.unformat(b)),new a(b)},m.version=n,m.isNumeral=function(b){return b instanceof a},m.language=function(a,b){if(!a)return q.currentLanguage;if(a=a.toLowerCase(),a&&!b){if(!o[a])throw new Error("Unknown language : "+a);q.currentLanguage=a}return(b||!o[a])&&j(a,b),m},m.reset=function(){for(var a in p)q[a]=p[a]},m.languageData=function(a){if(!a)return o[q.currentLanguage];if(!o[a])throw new Error("Unknown language : "+a);return o[a]},m.language("en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}}),m.zeroFormat=function(a){q.zeroFormat="string"==typeof a?a:null},m.nullFormat=function(a){q.nullFormat="string"==typeof a?a:null},m.defaultFormat=function(a){q.defaultFormat="string"==typeof a?a:"0.0"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;if("string"!=typeof a&&(a+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",a)),a=a.trim(),a.match(/^\d+$/))return!0;if(""===a)return!1;try{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof a)throw new TypeError(a+" is not a function");var b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),m.fn=a.prototype={clone:function(){return m(this)},format:function(a,b){return c(this,a?a:q.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:d(this,a?a:q.defaultFormat)},value:function(){return this._value},valueOf:function(){return this._value},set:function(a){return this._value=Number(a),this},add:function(a){function b(a,b,d,e){return a+c*b}var c=l.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=l.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b,c,d){var e=l(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=l(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(m(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=m),"undefined"==typeof ender&&(this.numeral=m),"function"==typeof define&&define.amd&&define([],function(){return m})}).call(this); | ||
(function(){function a(a){this._value=a}function b(a,b,c,d){var e,f,g,h,i=a.toString().split("."),j=b-(d||0);return e=2===i.length?Math.min(Math.max(i[1].length,j),b):j,g=Math.pow(10,e),h=(c(a*g)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}function c(a,b,c){var d;return d=b.indexOf("$")>-1?e(a,b,c):b.indexOf("%")>-1?f(a,b,c):b.indexOf(":")>-1?g(a,b):i(a._value,b,c)}function d(a,b){var c,d,e,f,g,i=b,j=["KB","MB","GB","TB","PB","EB","ZB","YB"],k=["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],l=!1;if(b.indexOf(":")>-1)a._value=h(b);else if(b===q.zeroFormat||b===q.nullFormat)a._value=0;else{for("."!==o[q.currentLanguage].delimiters.decimal&&(b=b.replace(/\./g,"").replace(o[q.currentLanguage].delimiters.decimal,".")),c=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.thousand+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),d=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.million+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),e=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.billion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),f=new RegExp("[^a-zA-Z]"+o[q.currentLanguage].abbreviations.trillion+"(?:\\)|(\\"+o[q.currentLanguage].currency.symbol+")?(?:\\))?)?$"),g=0;g<=j.length&&!(l=b.indexOf(j[g])>-1||b.indexOf(k[g])>-1?Math.pow(1024,g+1):!1);g++);a._value=(l?l:1)*(i.match(c)?Math.pow(10,3):1)*(i.match(d)?Math.pow(10,6):1)*(i.match(e)?Math.pow(10,9):1)*(i.match(f)?Math.pow(10,12):1)*(b.indexOf("%")>-1?.01:1)*((b.split("-").length+Math.min(b.split("(").length-1,b.split(")").length-1))%2?1:-1)*Number(b.replace(/[^0-9\.]+/g,"")),a._value=l?Math.ceil(a._value):a._value}return a._value}function e(a,b,c){var d,e,f=b.indexOf("$"),g=b.indexOf("("),h=b.indexOf("-"),j="";return b.indexOf(" $")>-1?(j=" ",b=b.replace(" $","")):b.indexOf("$ ")>-1?(j=" ",b=b.replace("$ ","")):b=b.replace("$",""),e=i(a._value,b,c),1>=f?e.indexOf("(")>-1||e.indexOf("-")>-1?(e=e.split(""),d=1,(g>f||h>f)&&(d=0),e.splice(d,0,o[q.currentLanguage].currency.symbol+j),e=e.join("")):e=o[q.currentLanguage].currency.symbol+j+e:e.indexOf(")")>-1?(e=e.split(""),e.splice(-1,0,j+o[q.currentLanguage].currency.symbol),e=e.join("")):e=e+j+o[q.currentLanguage].currency.symbol,e}function f(a,b,c){var d,e="",f=100*a._value;return b.indexOf(" %")>-1?(e=" ",b=b.replace(" %","")):b=b.replace("%",""),d=i(f,b,c),d.indexOf(")")>-1?(d=d.split(""),d.splice(-1,0,e+"%"),d=d.join("")):d=d+e+"%",d}function g(a){var b=Math.floor(a._value/60/60),c=Math.floor((a._value-60*b*60)/60),d=Math.round(a._value-60*b*60-60*c);return b+":"+(10>c?"0"+c:c)+":"+(10>d?"0"+d:d)}function h(a){var b=a.split(":"),c=0;return 3===b.length?(c+=60*Number(b[0])*60,c+=60*Number(b[1]),c+=Number(b[2])):2===b.length&&(c+=60*Number(b[0]),c+=Number(b[1])),Number(c)}function i(a,c,d){var e,f,g,h,i,j,k=!1,l=!1,m=!1,n="",p=!1,r=!1,s=!1,t=!1,u=!1,v="",w="",x=Math.abs(a),y=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],z=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],A="",B=!1,C=!1;if(0===a&&null!==q.zeroFormat)return q.zeroFormat;if(null===a&&null!==q.nullFormat)return q.nullFormat;if(c.indexOf("(")>-1?(k=!0,c=c.slice(1,-1)):c.indexOf("+")>-1&&(l=!0,c=c.replace(/\+/g,"")),c.indexOf("a")>-1&&(p=c.indexOf("aK")>=0,r=c.indexOf("aM")>=0,s=c.indexOf("aB")>=0,t=c.indexOf("aT")>=0,u=p||r||s||t,c.indexOf(" a")>-1&&(n=" "),c=c.replace(new RegExp(n+"a[KMBT]?"),""),x>=Math.pow(10,12)&&!u||t?(n+=o[q.currentLanguage].abbreviations.trillion,a/=Math.pow(10,12)):x<Math.pow(10,12)&&x>=Math.pow(10,9)&&!u||s?(n+=o[q.currentLanguage].abbreviations.billion,a/=Math.pow(10,9)):x<Math.pow(10,9)&&x>=Math.pow(10,6)&&!u||r?(n+=o[q.currentLanguage].abbreviations.million,a/=Math.pow(10,6)):(x<Math.pow(10,6)&&x>=Math.pow(10,3)&&!u||p)&&(n+=o[q.currentLanguage].abbreviations.thousand,a/=Math.pow(10,3))),c.indexOf("b")>-1)for(c.indexOf("ib")>-1&&(C=!0),c.indexOf(" b")>-1||c.indexOf(" ib")>-1?(v=" ",c=c.replace(" ib","").replace(" b","")):c=c.replace("ib","").replace("b",""),g=0;g<=z.length;g++)if(e=Math.pow(1024,g),f=Math.pow(1024,g+1),a>=e&&f>a){v+=C?y[g]:z[g],e>0&&(a/=e);break}return c.indexOf("o")>-1&&(c.indexOf(" o")>-1?(w=" ",c=c.replace(" o","")):c=c.replace("o",""),w+=o[q.currentLanguage].ordinal(a)),c.indexOf("[.]")>-1&&(m=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],j=c.indexOf(","),i?(i.indexOf("[")>-1?(i=i.replace("]",""),i=i.split("["),A=b(a,i[0].length+i[1].length,d,i[1].length)):A=b(a,i.length,d),h=A.split(".")[0],A=A.indexOf(".")>-1?o[q.currentLanguage].delimiters.decimal+A.split(".")[1]:"",m&&0===Number(A.slice(1))&&(A="")):h=b(a,null,d),h.indexOf("-")>-1&&(h=h.slice(1),B=!0),j>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+o[q.currentLanguage].delimiters.thousands)),0===c.indexOf(".")&&(h=""),(k&&B?"(":"")+(!k&&B?"-":"")+(!B&&l?"+":"")+h+A+(w?w:"")+(n?n:"")+(v?v:"")+(k&&B?")":"")}function j(a,b){o[a]=b}function k(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)}function l(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var c=k(a),d=k(b);return c>d?c:d},-(1/0))}var m,n="1.5.5",o={},p={currentLanguage:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0"},q={currentLanguage:p.currentLanguage,zeroFormat:p.zeroFormat,nullFormat:p.nullFormat,defaultFormat:p.defaultFormat};m=function(b){return m.isNumeral(b)?b=b.value():0===b||"undefined"==typeof b?b=0:null===b?b=null:Number(b)||(b=m.fn.unformat(b)),new a(b)},m.version=n,m.isNumeral=function(b){return b instanceof a},m.language=function(a,b){if(!a)return q.currentLanguage;if(a=a.toLowerCase(),a&&!b){if(!o[a])throw new Error("Unknown language : "+a);q.currentLanguage=a}return(b||!o[a])&&j(a,b),m},m.reset=function(){for(var a in p)q[a]=p[a]},m.languageData=function(a){if(!a)return o[q.currentLanguage];if(!o[a])throw new Error("Unknown language : "+a);return o[a]},m.language("en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}}),m.zeroFormat=function(a){q.zeroFormat="string"==typeof a?a:null},m.nullFormat=function(a){q.nullFormat="string"==typeof a?a:null},m.defaultFormat=function(a){q.defaultFormat="string"==typeof a?a:"0.0"},m.validate=function(a,b){var c,d,e,f,g,h,i,j;if("string"!=typeof a&&(a+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",a)),a=a.trim(),a.match(/^\d+$/))return!0;if(""===a)return!1;try{i=m.languageData(b)}catch(k){i=m.languageData(m.language())}return e=i.currency.symbol,g=i.abbreviations,c=i.delimiters.decimal,d="."===i.delimiters.thousands?"\\.":i.delimiters.thousands,j=a.match(/^[^\d]+/),null!==j&&(a=a.substr(1),j[0]!==e)?!1:(j=a.match(/[^\d]+$/),null!==j&&(a=a.slice(0,-1),j[0]!==g.thousand&&j[0]!==g.million&&j[0]!==g.billion&&j[0]!==g.trillion)?!1:(h=new RegExp(d+"{2}"),a.match(/[^\d.,]/g)?!1:(f=a.split(c),f.length>2?!1:f.length<2?!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h):1===f[0].length?!!f[0].match(/^\d+$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/):!!f[0].match(/^\d+.*\d$/)&&!f[0].match(h)&&!!f[1].match(/^\d+$/))))},Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof a)throw new TypeError(a+" is not a function");var b,c=Object(this),d=c.length>>>0,e=0;if(2===arguments.length)b=arguments[1];else{for(;d>e&&!(e in c);)e++;if(e>=d)throw new TypeError("Reduce of empty array with no initial value");b=c[e++]}for(;d>e;e++)e in c&&(b=a(b,c[e],e,c));return b}),m.fn=a.prototype={clone:function(){return m(this)},format:function(a,b){return c(this,a?a:q.defaultFormat,void 0!==b?b:Math.round)},unformat:function(a){return"[object Number]"===Object.prototype.toString.call(a)?a:d(this,a?a:q.defaultFormat)},value:function(){return this._value},valueOf:function(){return this._value},set:function(a){return this._value=Number(a),this},add:function(a){function b(a,b,d,e){return a+c*b}var c=l.call(null,this._value,a);return this._value=[this._value,a].reduce(b,0)/c,this},subtract:function(a){function b(a,b,d,e){return a-c*b}var c=l.call(null,this._value,a);return this._value=[a].reduce(b,this._value*c)/c,this},multiply:function(a){function b(a,b,c,d){var e=l(a,b);return a*e*(b*e)/(e*e)}return this._value=[this._value,a].reduce(b,1),this},divide:function(a){function b(a,b,c,d){var e=l(a,b);return a*e/(b*e)}return this._value=[this._value,a].reduce(b),this},difference:function(a){return Math.abs(m(this._value).subtract(a).value())}},"undefined"!=typeof module&&module.exports&&(module.exports=m),"undefined"==typeof ender&&(this.numeral=m),"function"==typeof define&&define.amd&&define([],function(){return m})}).call(this); |
/*! @preserve | ||
* numeral.js | ||
* version : 1.5.4 | ||
* version : 1.5.5 | ||
* author : Adam Draper | ||
@@ -16,3 +16,3 @@ * license : MIT | ||
var numeral, | ||
VERSION = '1.5.4', | ||
VERSION = '1.5.5', | ||
// internal storage for language config files | ||
@@ -109,4 +109,4 @@ languages = {}, | ||
trillionRegExp, | ||
binarySuffixes = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], | ||
decimalSuffixes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], | ||
suffixes = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], | ||
iecSuffixes = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], | ||
bytesMultiplier = false, | ||
@@ -132,6 +132,8 @@ power; | ||
// see if bytes are there so that we can multiply to the correct number | ||
for (power = 0; power <= binarySuffixes.length && !bytesMultiplier; power++) { | ||
if (string.indexOf(binarySuffixes[power]) > -1) { bytesMultiplier = Math.pow(1024, power + 1); } | ||
else if (string.indexOf(decimalSuffixes[power]) > -1) { bytesMultiplier = Math.pow(1000, power + 1); } | ||
else { bytesMultiplier = false; } | ||
for (power = 0; power <= suffixes.length; power++) { | ||
bytesMultiplier = ((string.indexOf(suffixes[power]) > -1) || (string.indexOf(iecSuffixes[power]) > -1))? Math.pow(1024, power + 1) : false; | ||
if (bytesMultiplier) { | ||
break; | ||
} | ||
} | ||
@@ -251,2 +253,8 @@ | ||
/* format keys: | ||
* a - abbreviation | ||
* ib - binary bytes | ||
* b - decimal bytes | ||
* o - ordinal | ||
*/ | ||
function formatNumber(value, format, roundingFunction) { | ||
@@ -265,4 +273,4 @@ var negP = false, | ||
abs = Math.abs(value), | ||
binarySuffixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], | ||
decimalSuffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], | ||
iecSuffixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'], | ||
suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], | ||
min, | ||
@@ -275,3 +283,4 @@ max, | ||
d = '', | ||
neg = false; | ||
neg = false, | ||
iecBinary = false; | ||
@@ -329,42 +338,24 @@ // check if number is zero and a custom zero format has been set | ||
// see if we are formatting binary bytes | ||
// see if we are formatting bytes | ||
if (format.indexOf('b') > -1) { | ||
// check for space before | ||
if (format.indexOf(' b') > -1) { | ||
bytes = ' '; | ||
format = format.replace(' b', ''); | ||
} else { | ||
format = format.replace('b', ''); | ||
} | ||
for (power = 0; power <= binarySuffixes.length; power++) { | ||
min = Math.pow(1024, power); | ||
max = Math.pow(1024, power + 1); | ||
if (value >= min && value < max) { | ||
bytes = bytes + binarySuffixes[power]; | ||
if (min > 0) { | ||
value = value / min; | ||
} | ||
break; | ||
} | ||
// check for IEC Binary byte notation | ||
if (format.indexOf('ib') > -1) { | ||
iecBinary = true; | ||
} | ||
} | ||
// see if we are formatting decimal bytes | ||
if (format.indexOf('d') > -1) { | ||
// check for space before | ||
if (format.indexOf(' d') > -1) { | ||
if (format.indexOf(' b') > -1 || format.indexOf(' ib') > -1) { | ||
bytes = ' '; | ||
format = format.replace(' d', ''); | ||
format = format.replace(' ib', '').replace(' b', ''); | ||
} else { | ||
format = format.replace('d', ''); | ||
format = format.replace('ib', '').replace('b', ''); | ||
} | ||
for (power = 0; power <= decimalSuffixes.length; power++) { | ||
min = Math.pow(1000, power); | ||
max = Math.pow(1000, power+1); | ||
for (power = 0; power <= suffixes.length; power++) { | ||
min = Math.pow(1024, power); | ||
max = Math.pow(1024, power+1); | ||
if (value >= min && value < max) { | ||
bytes = bytes + decimalSuffixes[power]; | ||
bytes = bytes + (iecBinary ? iecSuffixes[power] : suffixes[power]); | ||
if (min > 0) { | ||
@@ -371,0 +362,0 @@ value = value / min; |
{ | ||
"name": "numeral", | ||
"version": "1.5.4", | ||
"version": "1.5.5", | ||
"description": "Format and manipulate numbers.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://numeraljs.com", |
@@ -50,2 +50,6 @@ # [Numeral.js](http://numeraljs.com/) | ||
### 1.5.5 | ||
Bug fix: Switch bytes back to `b` and change iecBinary to `ib`, and calculate both using 1024 for backwards compatibility | ||
### 1.5.4 | ||
@@ -55,3 +59,3 @@ | ||
Tests: Added browser tests for Chrome, Firefox, and IE using saucelabs | ||
Tests: Added browser tests for Chrome, Firefox, and IE using saucelabs | ||
@@ -58,0 +62,0 @@ Added reset function to reset numeral to default options |
@@ -136,12 +136,12 @@ | ||
[100,'0b','100B'], | ||
[1024*2,'0 b','2 KiB'], | ||
[1024*1024*5,'0b','5MiB'], | ||
[1024*1024*1024*7.343,'0.[0] b','7.3 GiB'], | ||
[1024*1024*1024*1024*3.1536544,'0.000b','3.154TiB'], | ||
[1024*1024*1024*1024*1024*2.953454534534,'0b','3PiB'], | ||
[1000*2,'0 d','2 KB'], | ||
[1000*1000*5,'0d','5MB'], | ||
[1000*1000*1000*7.343,'0.[0] d','7.3 GB'], | ||
[1000*1000*1000*1000*3.1536544,'0.000d','3.154TB'], | ||
[1000*1000*1000*1000*1000*2.953454534534,'0d','3PB'] | ||
[1024*2,'0 ib','2 KiB'], | ||
[1024*1024*5,'0ib','5MiB'], | ||
[1024*1024*1024*7.343,'0.[0] ib','7.3 GiB'], | ||
[1024*1024*1024*1024*3.1536544,'0.000ib','3.154TiB'], | ||
[1024*1024*1024*1024*1024*2.953454534534,'0ib','3PiB'], | ||
[1024*2,'0 b','2 KB'], | ||
[1024*1024*5,'0b','5MB'], | ||
[1024*1024*1024*7.343,'0.[0] b','7.3 GB'], | ||
[1024*1024*1024*1024*3.1536544,'0.000b','3.154TB'], | ||
[1024*1024*1024*1024*1024*2.953454534534,'0b','3PB'] | ||
], | ||
@@ -148,0 +148,0 @@ i; |
@@ -63,3 +63,3 @@ // Node | ||
['3.154 TiB', 3467859674006], | ||
['3.154 TB', 3154000000000] | ||
['3.154 TB', 3467859674006] | ||
]; | ||
@@ -66,0 +66,0 @@ |
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
239
250348
6443