From e699be8919574f0f0b666b0fa1d2bdc9e13fcf7a Mon Sep 17 00:00:00 2001 From: Denis Forveille Date: Sat, 21 Sep 2019 19:56:22 -0400 Subject: [PATCH] fix formatage --- dist/utils.js | 4 ++-- package-lock.json | 2 +- package.json | 2 +- src/utils.ts | 8 +++++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dist/utils.js b/dist/utils.js index ceb9ec5..f313cfd 100644 --- a/dist/utils.js +++ b/dist/utils.js @@ -3,9 +3,9 @@ exports.__esModule = true; var options_1 = require("./options"); function format(input, opt) { if (opt === void 0) { opt = options_1["default"]; } - var value = (!isNaN(input)) + var value = (typeof input === 'number') ? Number(input).toFixed(fixed(opt.precision)) - : '0'; + : input; var negative = value.indexOf('-') >= 0 ? '-' : ''; var numbers = onlyNumbers(value); var currency = numbersToCurrency(numbers, opt.precision); diff --git a/package-lock.json b/package-lock.json index 8c92613..9971219 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@titou10/v-money", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 729981b..0f57a85 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@titou10/v-money", "description": "v-money directive for vue.js that exposes the unmasked value", - "version": "1.0.0", + "version": "1.0.1", "author": "Denis Forveille ", "license": "MIT", "keywords": [ diff --git a/src/utils.ts b/src/utils.ts index 16b044a..5a7d014 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,9 +1,11 @@ import defaults from './options'; function format(input, opt = defaults) { - const value = (!isNaN(input)) - ? Number(input).toFixed(fixed(opt.precision)) - : '0'; + + const value = (typeof input === 'number') + ? Number(input).toFixed(fixed(opt.precision)) + : input; + const negative = value.indexOf('-') >= 0 ? '-' : ''; const numbers = onlyNumbers(value);