Comparing version 0.8.0 to 0.9.0
@@ -1,1 +0,1 @@ | ||
export default function (value: string): number | undefined; | ||
export default function (value: string): string | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function default_1(value) { | ||
if (typeof value !== 'string') { | ||
const isDigitsAndSeparators = /^[0-9+-.,]+$/.test(value); | ||
if (!isDigitsAndSeparators) { | ||
return undefined; | ||
} | ||
const containsANumber = /^[0-9+-.,]+$/.test(value); | ||
if (!containsANumber) { | ||
let optionalSign = ''; | ||
if (value.startsWith('+')) { | ||
value = value.slice(1); | ||
optionalSign = '+'; | ||
} | ||
else if (value.startsWith('-')) { | ||
value = value.slice(1); | ||
optionalSign = '-'; | ||
} | ||
const hasLeadingZeros = /^0+/.test(value); | ||
if (!isDigitsAndSeparators || hasLeadingZeros) { | ||
return undefined; | ||
@@ -13,7 +23,7 @@ } | ||
if (!containsASeparator) { | ||
return Number(value); | ||
return optionalSign + String(Number(value)); | ||
} | ||
const containsOnlyThousands = /^[0-9]{1,3}(,[0-9]{3})$/.test(value); | ||
if (containsOnlyThousands) { | ||
return Number(value.replace(/,/g, '')); | ||
return optionalSign + String(Number(value.replace(/,/g, ''))); | ||
} | ||
@@ -26,9 +36,9 @@ const separatorChars = value | ||
separatorChars.pop() === ',') { | ||
return Number(value | ||
return optionalSign + String(Number(value | ||
.replace('.', '') | ||
.replace(',', '.')); | ||
.replace(',', '.'))); | ||
} | ||
const commaAsDecimalMark = /^[0-9+-]+,[0-9]{1,2}$/.test(value); | ||
if (commaAsDecimalMark) { | ||
return Number(value.replace(/,(.+?)/, '.$1')); | ||
return optionalSign + String(Number(value.replace(/,(.+?)/, '.$1'))); | ||
} | ||
@@ -35,0 +45,0 @@ return undefined; |
@@ -30,2 +30,3 @@ "use strict"; | ||
assert_1.default.equal(buffer.toString(), expected.toString()); | ||
console.info(' ✔︎'); | ||
}); | ||
@@ -32,0 +33,0 @@ process.stdout.write('Format all datetimes in ISO8601 format'); |
@@ -27,2 +27,3 @@ "use strict"; | ||
assert_1.default.equal(buffer.toString(), expected.toString()); | ||
console.info(' ✔︎'); | ||
}); | ||
@@ -29,0 +30,0 @@ process.stdout.write('Force data format for parsing CSV'); |
@@ -28,2 +28,3 @@ "use strict"; | ||
assert_1.default.equal(buffer.toString(), expected.toString()); | ||
console.info(' ✔︎'); | ||
}); | ||
@@ -30,0 +31,0 @@ process.stdout.write('Parse CSV file with preceding lines'); |
{ | ||
"name": "csvnorm", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "Command line tool to normalize CSV and *SV files.", | ||
@@ -5,0 +5,0 @@ "main": "binary/source/index.js", |
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
33784
43
754
10