format-money-js
Advanced tools
Comparing version 0.1.5 to 0.1.6
/*! | ||
* format-money-js v0.1.5 | ||
* format-money-js v0.1.6 | ||
* (c) 2020 Yurii Derevych | ||
@@ -4,0 +4,0 @@ * Released under the BSD-2-Clause License. |
/*! | ||
* format-money-js v0.1.5 | ||
* format-money-js v0.1.6 | ||
* (c) 2020 Yurii Derevych | ||
* Released under the BSD-2-Clause License. | ||
*/ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var FormatMoney = /** @class */ (function () { | ||
function FormatMoney(options) { | ||
var _this = this; | ||
export class FormatMoney { | ||
constructor(options) { | ||
this.options = options; | ||
this.version = '0.1.5'; | ||
this.version = '0.1.6'; | ||
this.defaults = { | ||
@@ -31,15 +19,15 @@ grouping: true, | ||
// default format and easing functions | ||
this.from = function (num) { | ||
var neg = (num < 0) ? '-' : ''; | ||
var result, x, x1, x2, x3; | ||
result = Math.abs(num).toFixed(_this.options.decimals); | ||
this.from = (num) => { | ||
const neg = (num < 0) ? '-' : ''; | ||
let result, x, x1, x2, x3; | ||
result = Math.abs(num).toFixed(this.options.decimals); | ||
result += ''; | ||
x = result.split('.'); | ||
x1 = x[0]; | ||
x2 = x.length > 1 ? _this.options.decimalPoint + x[1] : ''; | ||
if (_this.options.grouping) { | ||
x2 = x.length > 1 ? this.options.decimalPoint + x[1] : ''; | ||
if (this.options.grouping) { | ||
x3 = ''; | ||
for (var i = 0, len = x1.length; i < len; ++i) { | ||
for (let i = 0, len = x1.length; i < len; ++i) { | ||
if (i !== 0 && (i % 3) === 0) { | ||
x3 = _this.options.separator + x3; | ||
x3 = this.options.separator + x3; | ||
} | ||
@@ -50,9 +38,7 @@ x3 = x1[len - i - 1] + x3; | ||
} | ||
return neg + _this.options.prefix + x1 + x2 + _this.options.suffix; | ||
return neg + this.options.prefix + x1 + x2 + this.options.suffix; | ||
}; | ||
this.options = __assign(__assign({}, this.defaults), options); | ||
this.options = Object.assign(Object.assign({}, this.defaults), options); | ||
} | ||
return FormatMoney; | ||
}()); | ||
export { FormatMoney }; | ||
} | ||
//# sourceMappingURL=format-money.js.map |
@@ -1,1 +0,1 @@ | ||
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var i,s=1,o=arguments.length;s<o;s++)for(var n in i=arguments[s])Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n]);return t}).apply(this,arguments)},FormatMoney=function(){return function(t){var i=this;this.options=t,this.version="0.1.5",this.defaults={grouping:!0,separator:",",decimalPoint:".",decimals:0,prefix:"",suffix:""},this.from=function(t){var s,o,n,r,a,e=t<0?"-":"";if(s=Math.abs(t).toFixed(i.options.decimals),n=(o=(s+="").split("."))[0],r=o.length>1?i.options.decimalPoint+o[1]:"",i.options.grouping){a="";for(var p=0,f=n.length;p<f;++p)0!==p&&p%3==0&&(a=i.options.separator+a),a=n[f-p-1]+a;n=a}return e+i.options.prefix+n+r+i.options.suffix},this.options=__assign(__assign({},this.defaults),t)}}();export{FormatMoney}; | ||
export class FormatMoney{constructor(t){this.options=t,this.version="0.1.6",this.defaults={grouping:!0,separator:",",decimalPoint:".",decimals:0,prefix:"",suffix:""},this.from=(t=>{const s=t<0?"-":"";let i,o,e,n,r;if(i=Math.abs(t).toFixed(this.options.decimals),e=(o=(i+="").split("."))[0],n=o.length>1?this.options.decimalPoint+o[1]:"",this.options.grouping){r="";for(let t=0,s=e.length;t<s;++t)0!==t&&t%3==0&&(r=this.options.separator+r),r=e[s-t-1]+r;e=r}return s+this.options.prefix+e+n+this.options.suffix}),this.options=Object.assign(Object.assign({},this.defaults),t)}}; |
{ | ||
"name": "format-money-js", | ||
"description": "Tiny JavaScript library by CurrencyRate.today, providing simple and advanced number, money and currency formatting.", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"license": "BSD-2-Clause", | ||
@@ -6,0 +6,0 @@ "main": "./dist/format-money.min.js", |
@@ -1,2 +0,2 @@ | ||
# FormatMoney.js | ||
# format-money-js | ||
Tiny JavaScript library (576 bytes) by CurrencyRate.today, providing simple and advanced number, money and currency formatting. |
/*! | ||
* format-money-js v0.1.5 | ||
* format-money-js v0.1.6 | ||
* (c) 2020 Yurii Derevych | ||
@@ -18,3 +18,3 @@ * Released under the BSD-2-Clause License. | ||
version = '0.1.5'; | ||
version = '0.1.6'; | ||
private defaults: FormatMoneyOptions = { | ||
@@ -21,0 +21,0 @@ grouping: true, |
{ | ||
"compilerOptions": { | ||
"lib": ["ES5","ESNext"], | ||
"module": "ESNext", | ||
"lib": ["ES6"], | ||
"module": "ES6", | ||
"declaration": true, | ||
"outDir": "dist", | ||
"target": "ES5", | ||
"target": "ES6", | ||
"pretty": true, | ||
@@ -9,0 +9,0 @@ "allowJs": true, |
Sorry, the diff of this file is not supported yet
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
12197
296