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

csv-parse

Package Overview
Dependencies
Maintainers
1
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csv-parse - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

CHANGELOG.md

148

lib/index.js

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.10.0
// Generated by CoffeeScript 1.12.7
var Parser, StringDecoder, stream, util;

@@ -99,2 +99,5 @@

}
if (this.options.quote !== void 0 && !this.options.quote) {
this.options.quote = '';
}
if ((base2 = this.options).quote == null) {

@@ -153,18 +156,17 @@ base2.quote = '"';

};
this._ = {};
this._.decoder = new StringDecoder();
this._.quoting = false;
this._.commenting = false;
this._.field = null;
this._.nextChar = null;
this._.closingQuote = 0;
this._.line = [];
this._.chunks = [];
this._.rawBuf = '';
this._.buf = '';
if (this.options.rowDelimiter) {
this._.rowDelimiterLength = Math.max.apply(Math, this.options.rowDelimiter.map(function(v) {
this._ = {
decoder: new StringDecoder(),
quoting: false,
commenting: false,
field: null,
nextChar: null,
closingQuote: 0,
line: [],
chunks: [],
rawBuf: '',
buf: '',
rowDelimiterLength: this.options.rowDelimiter ? Math.max.apply(Math, this.options.rowDelimiter.map(function(v) {
return v.length;
}));
}
})) : void 0
};
return this;

@@ -178,35 +180,34 @@ };

Parser.prototype._transform = function(chunk, encoding, callback) {
var err, error;
var err;
if (chunk instanceof Buffer) {
chunk = this._.decoder.write(chunk);
}
try {
this.__write(chunk, false);
return callback();
} catch (error) {
err = error;
err = this.__write(chunk, false);
if (err) {
return this.emit('error', err);
}
return callback();
};
Parser.prototype._flush = function(callback) {
var err, error;
try {
this.__write(this._.decoder.end(), true);
if (this._.quoting) {
this.emit('error', new Error("Quoted field not terminated at line " + (this.lines + 1)));
return;
}
if (this._.line.length > 0) {
this.__push(this._.line);
}
return callback();
} catch (error) {
err = error;
var err;
err = this.__write(this._.decoder.end(), true);
if (err) {
return this.emit('error', err);
}
if (this._.quoting) {
this.emit('error', new Error("Quoted field not terminated at line " + (this.lines + 1)));
return;
}
if (this._.line.length > 0) {
err = this.__push(this._.line);
if (err) {
return callback(err);
}
}
return callback();
};
Parser.prototype.__push = function(line) {
var field, i, j, len, lineAsColumns, rawBuf, row;
var call_column_udf, columns, err, field, i, j, len, lineAsColumns, rawBuf, ref, row;
if (this.options.skip_lines_with_empty_values && line.join('').trim() === '') {

@@ -221,3 +222,17 @@ return;

} else if (typeof this.options.columns === 'function') {
this.options.columns = this.options.columns(line);
call_column_udf = function(fn, line) {
var columns, err;
try {
columns = fn.call(null, line);
return [null, columns];
} catch (error) {
err = error;
return [err];
}
};
ref = call_column_udf(this.options.columns, line), err = ref[0], columns = ref[1];
if (err) {
return err;
}
this.options.columns = columns;
rawBuf = '';

@@ -235,5 +250,5 @@ return;

} else if (this.options.columns != null) {
throw Error("Number of columns on line " + this.lines + " does not match header");
return Error("Number of columns on line " + this.lines + " does not match header");
} else {
throw Error("Number of columns is inconsistent on line " + this.lines);
return Error("Number of columns is inconsistent on line " + this.lines);
}

@@ -271,10 +286,11 @@ } else {

});
return this._.rawBuf = '';
this._.rawBuf = '';
} else {
return this.push(row);
this.push(row);
}
return null;
};
Parser.prototype.__write = function(chars, end) {
var areNextCharsDelimiter, areNextCharsRowDelimiters, auto_parse, char, escapeIsQuote, i, isDelimiter, isEscape, isNextCharAComment, isQuote, isRowDelimiter, isRowDelimiterLength, is_float, is_int, l, ltrim, nextCharPos, ref, ref1, ref2, ref3, ref4, remainingBuffer, results, rowDelimiter, rtrim, wasCommenting;
var areNextCharsDelimiter, areNextCharsRowDelimiters, auto_parse, char, err, escapeIsQuote, i, isDelimiter, isEscape, isNextCharAComment, isQuote, isRowDelimiter, isRowDelimiterLength, is_float, is_int, l, ltrim, nextCharPos, ref, ref1, ref2, ref3, ref4, ref5, remainingBuffer, rowDelimiter, rtrim, wasCommenting;
is_int = (function(_this) {

@@ -349,3 +365,3 @@ return function(value) {

nextCharPos += 1;
} else if (!(!this._.quoting && char === this.options.quote) && (this._.nextChar === '\n' || this._.nextChar === '\r')) {
} else if (this._.quoting && char === this.options.quote && ((ref = this._.nextChar) === '\n' || ref === '\r')) {
rowDelimiter = this._.nextChar;

@@ -396,3 +412,3 @@ nextCharPos += 2;

} else {
throw Error("Invalid closing quote at line " + (this.lines + 1) + "; found " + (JSON.stringify(this._.nextChar)) + " instead of delimiter " + (JSON.stringify(this.options.delimiter)));
return Error("Invalid closing quote at line " + (this.lines + 1) + "; found " + (JSON.stringify(this._.nextChar)) + " instead of delimiter " + (JSON.stringify(this.options.delimiter)));
}

@@ -414,3 +430,3 @@ } else {

} else if ((this._.field != null) && !this.options.relax) {
throw Error("Invalid opening quote at line " + (this.lines + 1));
return Error("Invalid opening quote at line " + (this.lines + 1));
}

@@ -421,7 +437,2 @@ }

});
if (isRowDelimiter) {
isRowDelimiterLength = this.options.rowDelimiter.filter(function(rd) {
return chars.substr(i, rd.length) === rd;
})[0].length;
}
if (isRowDelimiter || (end && i === l - 1)) {

@@ -439,2 +450,7 @@ this.lines++;

if (!this._.commenting && !this._.quoting && (isDelimiter || isRowDelimiter)) {
if (isRowDelimiter) {
isRowDelimiterLength = this.options.rowDelimiter.filter(function(rd) {
return chars.substr(i, rd.length) === rd;
})[0].length;
}
if (isRowDelimiter && this._.line.length === 0 && (this._.field == null)) {

@@ -449,3 +465,3 @@ if (wasCommenting || this.options.skip_empty_lines) {

if (!this._.closingQuote) {
this._.field = (ref = this._.field) != null ? ref.trimRight() : void 0;
this._.field = (ref1 = this._.field) != null ? ref1.trimRight() : void 0;
}

@@ -465,3 +481,6 @@ }

if (isRowDelimiter) {
this.__push(this._.line);
err = this.__push(this._.line);
if (err) {
return err;
}
this._.line = [];

@@ -489,7 +508,7 @@ i += isRowDelimiterLength;

}
if (!this._.commenting && ((ref1 = this._.field) != null ? ref1.length : void 0) > this.options.max_limit_on_data_read) {
throw Error("Delimiter not found in the file " + (JSON.stringify(this.options.delimiter)));
if (!this._.commenting && ((ref2 = this._.field) != null ? ref2.length : void 0) > this.options.max_limit_on_data_read) {
return Error("Delimiter not found in the file " + (JSON.stringify(this.options.delimiter)));
}
if (!this._.commenting && ((ref2 = this._.line) != null ? ref2.length : void 0) > this.options.max_limit_on_data_read) {
throw Error("Row delimiter not found in the file " + (JSON.stringify(this.options.rowDelimiter)));
if (!this._.commenting && ((ref3 = this._.line) != null ? ref3.length : void 0) > this.options.max_limit_on_data_read) {
return Error("Row delimiter not found in the file " + (JSON.stringify(this.options.rowDelimiter)));
}

@@ -501,3 +520,3 @@ }

if (!this._.closingQuote) {
this._.field = (ref3 = this._.field) != null ? ref3.trimRight() : void 0;
this._.field = (ref4 = this._.field) != null ? ref4.trimRight() : void 0;
}

@@ -508,4 +527,4 @@ }

}
if (((ref4 = this._.field) != null ? ref4.length : void 0) > this.options.max_limit_on_data_read) {
throw Error("Delimiter not found in the file " + (JSON.stringify(this.options.delimiter)));
if (((ref5 = this._.field) != null ? ref5.length : void 0) > this.options.max_limit_on_data_read) {
return Error("Delimiter not found in the file " + (JSON.stringify(this.options.delimiter)));
}

@@ -516,12 +535,7 @@ if (l === 0) {

if (this._.line.length > this.options.max_limit_on_data_read) {
throw Error("Row delimiter not found in the file " + (JSON.stringify(this.options.rowDelimiter)));
return Error("Row delimiter not found in the file " + (JSON.stringify(this.options.rowDelimiter)));
}
}
this._.buf = '';
results = [];
while (i < l) {
this._.buf += chars.charAt(i);
results.push(i++);
}
return results;
this._.buf = chars.substr(i);
return null;
};

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.10.0
// Generated by CoffeeScript 1.12.7
var StringDecoder, parse;

@@ -3,0 +3,0 @@

{
"version": "1.2.0",
"version": "1.2.1",
"name": "csv-parse",

@@ -31,14 +31,13 @@ "description": "CSV parsing implementing the Node.js `stream.Transform` API",

"type": "git",
"url": "http://www.github.com/wdavidw/node-csv-parse"
"url": "http://www.github.com/adaltas/node-csv-parse"
},
"homepage": "http://csv.adaltas.com/parse/",
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"each": "0.6.1",
"coffee-script": "1.10.0",
"coffee-script": "1.12.7",
"csv-generate": "1.0.0",
"csv-spectrum": "1.0.0",
"mocha": "2.5.3",
"should": "9.0.2"
"mocha": "3.4.2",
"should": "11.2.1"
},

@@ -45,0 +44,0 @@ "optionalDependencies": {},

@@ -1,2 +0,2 @@

[![Build Status](https://secure.travis-ci.org/wdavidw/node-csv-parse.png)][travis]
[![Build Status](https://secure.travis-ci.org/wdavidw/node-csv-parse.svg)][travis]

@@ -3,0 +3,0 @@ Part of the [CSV module][csv_home], this project is a parser converting CSV text

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