Socket
Socket
Sign inDemoInstall

csv-parse

Package Overview
Dependencies
0
Maintainers
1
Versions
141
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.4 to 1.0.0

63

lib/index.js

@@ -131,4 +131,6 @@ // Generated by CoffeeScript 1.9.3

this.count = 0;
this.regexp_int = /^(\-|\+)?([1-9]+[0-9]*)$/;
this.regexp_float = /^(\-|\+)?([0-9]+(\.[0-9]+)?([eE][0-9]+)?|Infinity)$/;
this.is_int = /^(\-|\+)?([1-9]+[0-9]*)$/;
this.is_float = function(value) {
return (value - parseFloat(value) + 1) >= 0;
};
this.decoder = new StringDecoder();

@@ -209,3 +211,37 @@ this.buf = '';

Parser.prototype.__write = function(chars, end, callback) {
var acceptedLength, areNextCharsDelimiter, areNextCharsRowDelimiters, char, escapeIsQuote, i, isDelimiter, isEscape, isNextCharAComment, isQuote, isRowDelimiter, l, ltrim, m, nextCharPos, ref, results, rowDelimiter, rowDelimiterLength, rtrim, wasCommenting;
var acceptedLength, areNextCharsDelimiter, areNextCharsRowDelimiters, auto_parse, char, escapeIsQuote, i, isDelimiter, isEscape, isNextCharAComment, isQuote, isRowDelimiter, is_float, is_int, l, ltrim, nextCharPos, ref, results, rowDelimiter, rowDelimiterLength, rtrim, wasCommenting;
is_int = (function(_this) {
return function(value) {
if (typeof _this.is_int === 'function') {
return _this.is_int(value);
} else {
return _this.is_int.test(value);
}
};
})(this);
is_float = (function(_this) {
return function(value) {
if (typeof _this.is_float === 'function') {
return _this.is_float(value);
} else {
return _this.is_float.test(value);
}
};
})(this);
auto_parse = (function(_this) {
return function(value) {
var m;
if (_this.options.auto_parse && is_int(_this.field)) {
_this.field = parseInt(_this.field);
} else if (_this.options.auto_parse && is_float(_this.field)) {
_this.field = parseFloat(_this.field);
} else if (_this.options.auto_parse && _this.options.auto_parse_date) {
m = Date.parse(_this.field);
if (!isNaN(m)) {
_this.field = new Date(m);
}
}
return _this.field;
};
})(this);
ltrim = this.options.trim || this.options.ltrim;

@@ -276,3 +312,3 @@ rtrim = this.options.trim || this.options.rtrim;

if (end && i === l) {
this.line.push(this.field);
this.line.push(auto_parse(this.field));
}

@@ -314,16 +350,3 @@ continue;

}
if (this.options.auto_parse && this.regexp_int.test(this.field)) {
this.line.push(parseInt(this.field));
} else if (this.options.auto_parse && this.regexp_float.test(this.field)) {
this.line.push(parseFloat(this.field));
} else if (this.options.auto_parse && this.options.auto_parse_date) {
m = Date.parse(this.field);
if (isNaN(m)) {
this.line.push(this.field);
} else {
this.line.push(new Date(m));
}
} else {
this.line.push(this.field);
}
this.line.push(auto_parse(this.field));
this.closingQuote = 0;

@@ -354,3 +377,3 @@ this.field = '';

}
this.line.push(this.field);
this.line.push(auto_parse(this.field));
}

@@ -362,3 +385,3 @@ i++;

if (end && i === l) {
this.line.push(this.field);
this.line.push(auto_parse(this.field));
}

@@ -365,0 +388,0 @@ } else {

{
"version": "0.1.4",
"version": "1.0.0",
"name": "csv-parse",

@@ -4,0 +4,0 @@ "description": "CSV parsing implementing the Node.js `stream.Transform` API",

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc