UNPKG

cobuild-angular-stack

Version:

Base stack angular sass jade gulp

24 lines (22 loc) 753 B
/** * Created by garusis on 27/07/16. */ Number.prototype.formatMoney = function (c, d, t) { d = d || "."; t = t || ","; try { c = isNaN(c = Math.abs(c)) ? 2 : c; var n = this, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); } catch (err) { return '0' + d + '00'; } }; (function(arr,i,name) { while(name = arr[i++]) { Math["$"+name] = Function("a","b","return Math."+name+"(a*(b=Math.pow(10,b||0)))/b"); } })(["floor","ceil","round"],0);