Comparing version 0.5.8 to 0.5.9
{ | ||
"name": "ssf", | ||
"version": "0.5.8", | ||
"version": "0.5.9", | ||
"author": "SheetJS", | ||
@@ -5,0 +5,0 @@ "description": "pure-JS library to format data using ECMA-376 spreadsheet Format Codes", |
@@ -56,3 +56,5 @@ # SSF | ||
[![Coverage Status](https://coveralls.io/repos/SheetJS/ssf/badge.png?branch=master)](https://coveralls.io/r/SheetJS/ssf?branch=master) | ||
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/c1dac903f4b43f82a529bc8df145d085 "githalytics.com")](http://githalytics.com/SheetJS/ssf) | ||
@@ -8,3 +8,3 @@ /* ssf.js (C) 2013-2014 SheetJS -- http://sheetjs.com */ | ||
function rpad(v,d,c){var t=String(v);return t.length>=d?t:(t+fill(c||0,d-t.length));} | ||
SSF.version = '0.5.8'; | ||
SSF.version = '0.5.9'; | ||
/* Options */ | ||
@@ -246,5 +246,6 @@ var opts_fmt = {}; | ||
} | ||
fmt = fmt.replace(/^#+0/, "0"); | ||
if((r = fmt.match(/^(0*)\.(#*)$/))) { | ||
o = Math.round(val*Math.pow(10,r[2].length)); | ||
return String(o * Math.pow(10,-r[2].length)).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^([-]?\d*)$/,"$1.").replace(/^0\./,r[1].length?"0.":"."); | ||
o = Math.round(aval*Math.pow(10,r[2].length)); | ||
return sign + String(o / Math.pow(10,r[2].length)).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^([-]?\d*)$/,"$1.").replace(/^0\./,r[1].length?"0.":"."); | ||
} | ||
@@ -251,0 +252,0 @@ if((r = fmt.match(/^#,##0([.]?)$/))) return sign + commaify(String(Math.round(aval))); |
12
ssf.md
@@ -434,5 +434,11 @@ # SSF | ||
} | ||
``` | ||
The next few simplifications ignore leading optional sigils (`#`): | ||
``` | ||
fmt = fmt.replace(/^#+0/, "0"); | ||
if((r = fmt.match(/^(0*)\.(#*)$/))) { | ||
o = Math.round(val*Math.pow(10,r[2].length)); | ||
return String(o * Math.pow(10,-r[2].length)).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^([-]?\d*)$/,"$1.").replace(/^0\./,r[1].length?"0.":"."); | ||
o = Math.round(aval*Math.pow(10,r[2].length)); | ||
return sign + String(o / Math.pow(10,r[2].length)).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^([-]?\d*)$/,"$1.").replace(/^0\./,r[1].length?"0.":"."); | ||
} | ||
@@ -1000,3 +1006,3 @@ if((r = fmt.match(/^#,##0([.]?)$/))) return sign + commaify(String(Math.round(aval))); | ||
"name": "ssf", | ||
"version": "0.5.8", | ||
"version": "0.5.9", | ||
"author": "SheetJS", | ||
@@ -1003,0 +1009,0 @@ "description": "pure-JS library to format data using ECMA-376 spreadsheet Format Codes", |
@@ -22,2 +22,3 @@ [ | ||
["_($* #,##0_);_($* (#,##0);_($* \"-\"_);_(@_)", [1, " $1 "], [-1, " $(1)"], [0," $- "], ["TODO", " TODO "], ["",""]], | ||
["#0.#", [0,"0."], [1,"1."], [12,"12."], [12.34, "12.3"], [-1.23, "-1.2"]], | ||
["#,##0.0", [1,"1.0"], [-1,"-1.0"], [0,"0.0"], ["TODO","TODO"]], | ||
@@ -24,0 +25,0 @@ ["#,##0.00", [1,"1.00"], [-1,"-1.00"], [0,"0.00"], ["TODO","TODO"]], |
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
104303
1916
60