multi-number-parse
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -46,3 +46,3 @@ 'use strict'; | ||
// analyze separators | ||
var separators = stripped.match(/[^\d]/g).reduce(function (acc, sep, idx) { | ||
var separators = (stripped.match(/[^\d]/g) || []).reduce(function (acc, sep, idx) { | ||
var sepChr = 'str_' + sep.codePointAt(0); | ||
@@ -61,2 +61,7 @@ var cnt = ((acc[sepChr] || {}).cnt || 0) + 1; | ||
if (!sepKeys.length) { | ||
// no separator, that's easy-peasy | ||
return parseInt(stripped, 10) * (negative ? -1 : 1); | ||
} | ||
if (sepKeys.length > 2) { | ||
@@ -63,0 +68,0 @@ // there's more than 2 separators, that's wrong |
{ | ||
"name": "multi-number-parse", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Library for parsing numbers in any valid format.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -17,2 +17,5 @@ import { assert } from 'chai'; | ||
{ actual: '4.78€', expected: 4.78 }, | ||
{ actual: '28', expected: 28 }, | ||
{ actual: '-48', expected: -48 }, | ||
{ actual: '39USD', expected: 39 }, | ||
// some negative numbers | ||
@@ -19,0 +22,0 @@ { actual: '-2,543.56', expected: -2543.56 }, |
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
10464
148