Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

csvnorm

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csvnorm - npm Package Compare versions

Comparing version 0.8.0 to 0.9.0

binary/tests/leading-zero.d.ts

2

binary/source/formatNumber.d.ts

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc