X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=node_modules%2Funderscore.string%2FnumberFormat.js;fp=node_modules%2Funderscore.string%2FnumberFormat.js;h=6a681fee684d68c15adf1ed4d5e152a85d28dbcc;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/node_modules/underscore.string/numberFormat.js b/node_modules/underscore.string/numberFormat.js new file mode 100644 index 000000000..6a681fee6 --- /dev/null +++ b/node_modules/underscore.string/numberFormat.js @@ -0,0 +1,12 @@ +module.exports = function numberFormat(number, dec, dsep, tsep) { + if (isNaN(number) || number == null) return ''; + + number = number.toFixed(~~dec); + tsep = typeof tsep == 'string' ? tsep : ','; + + var parts = number.split('.'), + fnums = parts[0], + decimals = parts[1] ? (dsep || '.') + parts[1] : ''; + + return fnums.replace(/(\d)(?=(?:\d{3})+$)/g, '$1' + tsep) + decimals; +};