mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-10 05:36:04 +00:00
Update strings.js
This commit is contained in:
parent
3b0731d010
commit
d29a9f239e
|
@ -2,7 +2,7 @@
|
||||||
* strings.js
|
* strings.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.number_format = function(number, decimals, decPoint, thousandsSep) { // eslint-disable-line camelcase
|
var number_format = function(number, decimals, decPoint, thousandsSep) { // eslint-disable-line camelcase
|
||||||
// discuss at: https://locutus.io/php/number_format/
|
// discuss at: https://locutus.io/php/number_format/
|
||||||
// original by: Jonas Raoni Soares Silva (https://www.jsfromhell.com)
|
// original by: Jonas Raoni Soares Silva (https://www.jsfromhell.com)
|
||||||
// improved by: Kevin van Zonneveld (https://kvz.io)
|
// improved by: Kevin van Zonneveld (https://kvz.io)
|
||||||
|
@ -58,7 +58,7 @@ module.number_format = function(number, decimals, decPoint, thousandsSep) { // e
|
||||||
const sep = (typeof thousandsSep === 'undefined') ? ',' : thousandsSep
|
const sep = (typeof thousandsSep === 'undefined') ? ',' : thousandsSep
|
||||||
const dec = (typeof decPoint === 'undefined') ? '.' : decPoint
|
const dec = (typeof decPoint === 'undefined') ? '.' : decPoint
|
||||||
let s = ''
|
let s = ''
|
||||||
const toFixedFix = function (n, prec) {
|
const toFixedFix = function(n, prec) {
|
||||||
if (('' + n).indexOf('e') === -1) {
|
if (('' + n).indexOf('e') === -1) {
|
||||||
return +(Math.round(n + 'e+' + prec) + 'e-' + prec)
|
return +(Math.round(n + 'e+' + prec) + 'e-' + prec)
|
||||||
} else {
|
} else {
|
||||||
|
@ -81,3 +81,5 @@ module.number_format = function(number, decimals, decPoint, thousandsSep) { // e
|
||||||
}
|
}
|
||||||
return s.join(dec)
|
return s.join(dec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.number_format = number_format;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user