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 4.13.0 to 4.13.1

22

CHANGELOG.md

@@ -6,9 +6,19 @@

* `skip_lines_with_empty_values`: rename to skip_records_with_empty_values
* `skip_lines_with_error`: rename to skip_records_with_error
* `relax`: rename to relax_quotes_when_unquoted
* `max_comment_size`: new option
* promise: new API module
* errors: finish normalisation of all errors
Please join and contribute:
* `skip_lines_with_empty_values`: rename to skip_records_with_empty_values (easy)
* `skip_lines_with_error`: rename to skip_records_with_error (easy)
* `relax`: rename to relax_quotes_when_unquoted (easy)
* `max_comment_size`: new option (medium)
* promise: new API module (medium)
* errors: finish normalisation of all errors (easy)
* encoding: new encoding_input and encoding_output options (medium)
## Version 4.13.1
* encoding: buffer, detection and options samples
* encoding: return buffer when null or false
* encoding: support boolean values
* api: remove commented code
## Version 4.13.0

@@ -15,0 +25,0 @@

@@ -72,4 +72,3 @@ "use strict";

var cr = 13;
var space = 32; // const bom_utf8 = Buffer.from([239, 187, 191])
var space = 32;
var boms = {

@@ -99,4 +98,2 @@ // Note, the following are equals:

// const encoding = opts.encoding
// delete opts.encoding
_this = _super.call(this, _objectSpread(_objectSpread(_objectSpread({}, {

@@ -117,4 +114,3 @@ readableObjectMode: true

value: function __normalizeOptions(opts) {
var options = {}; // const options = {encoding: encoding}
// Merge with user options
var options = {}; // Merge with user options

@@ -128,4 +124,6 @@ for (var opt in opts) {

if (options.encoding === undefined) {
if (options.encoding === undefined || options.encoding === true) {
options.encoding = 'utf8';
} else if (options.encoding === null || options.encoding === false) {
options.encoding = null;
} else if (typeof options.encoding !== 'string' && options.encoding !== null) {

@@ -237,6 +235,3 @@ throw new CsvError('CSV_INVALID_OPTION_ENCODING', ['Invalid option encoding:', 'encoding must be a string or null to return a buffer,', "got ".concat(JSON.stringify(options.encoding))], options);

if (!Buffer.isBuffer(options.escape)) {
throw new Error("Invalid Option: escape must be a buffer, a string or a boolean, got ".concat(JSON.stringify(options.escape))); // }else if(options.escape.length !== 1){
// throw new Error(`Invalid Option Length: escape must be one character, got ${options.escape.length}`)
// }else{
// options.escape = options.escape[0]
throw new Error("Invalid Option: escape must be a buffer, a string or a boolean, got ".concat(JSON.stringify(options.escape)));
}

@@ -335,6 +330,3 @@ } // Normalize option `from`

if (!Buffer.isBuffer(options.quote)) {
throw new Error("Invalid Option: quote must be a buffer or a string, got ".concat(JSON.stringify(options.quote))); // }else if(options.quote.length !== 1){
// throw new Error(`Invalid Option Length: quote must be one character, got ${options.quote.length}`)
// }else{
// options.quote = options.quote[0]
throw new Error("Invalid Option: quote must be a buffer or a string, got ".concat(JSON.stringify(options.quote)));
}

@@ -691,3 +683,2 @@ } // Normalize option `raw`

// TODO: need to compare bytes instead of single char
// if(this.state.commenting === false && chr === quote){

@@ -699,5 +690,4 @@

var isNextChrTrimable = rtrim && this.__isCharTrimable(nextChr); // const isNextChrComment = nextChr === comment
var isNextChrTrimable = rtrim && this.__isCharTrimable(nextChr);
var isNextChrComment = comment !== null && this.__compareBytes(comment, buf, pos + quote.length, nextChr);

@@ -709,4 +699,2 @@

// Treat next char as a regular character
// TODO: need to compare bytes instead of single char
// if(escape !== null && chr === escape && nextChr === quote){

@@ -928,4 +916,3 @@ if (escape !== null && this.__isEscape(buf, pos, chr) && this.__isQuote(buf, pos + escape.length)) {

} else {
var _err5 = this.__error( // CSV_INVALID_RECORD_LENGTH_DONT_MATCH_COLUMNS
new CsvError('CSV_RECORD_DONT_MATCH_COLUMNS_LENGTH', ['Invalid Record Length:', "columns length is ".concat(columns.length, ","), // rename columns
var _err5 = this.__error(new CsvError('CSV_RECORD_DONT_MATCH_COLUMNS_LENGTH', ['Invalid Record Length:', "columns length is ".concat(columns.length, ","), // rename columns
"got ".concat(recordLength, " on line ").concat(this.info.lines)], this.options, this.__context(), {

@@ -962,4 +949,3 @@ record: record

for (var i = 0, l = record.length; i < l; i++) {
if (columns[i] === undefined || columns[i].disabled) continue; // obj[columns[i].name] = record[i]
// Turn duplicate columns into an array
if (columns[i] === undefined || columns[i].disabled) continue; // Turn duplicate columns into an array

@@ -966,0 +952,0 @@ if (columns_duplicates_to_array === true && obj[columns[i].name]) {

@@ -81,5 +81,7 @@ "use strict";

value: function toString(encoding) {
// console.log('!!', encoding)
// return this.buf.slice(0, this.length)
return this.buf.slice(0, this.length).toString(encoding);
if (encoding) {
return this.buf.slice(0, this.length).toString(encoding);
} else {
return Uint8Array.prototype.slice.call(this.buf.slice(0, this.length));
}
}

@@ -86,0 +88,0 @@ }, {

@@ -17,3 +17,2 @@

const space = 32
// const bom_utf8 = Buffer.from([239, 187, 191])
const boms = {

@@ -33,4 +32,2 @@ // Note, the following are equals:

constructor(opts = {}){
// const encoding = opts.encoding
// delete opts.encoding
super({...{readableObjectMode: true}, ...opts, encoding: null})

@@ -42,3 +39,2 @@ this.__originalOptions = opts

const options = {}
// const options = {encoding: encoding}
// Merge with user options

@@ -51,4 +47,6 @@ for(let opt in opts){

// to convert chars/strings into buffers.
if(options.encoding === undefined){
if(options.encoding === undefined || options.encoding === true){
options.encoding = 'utf8'
}else if(options.encoding === null || options.encoding === false){
options.encoding = null
}else if(typeof options.encoding !== 'string' && options.encoding !== null){

@@ -178,6 +176,2 @@ throw new CsvError('CSV_INVALID_OPTION_ENCODING', [

throw new Error(`Invalid Option: escape must be a buffer, a string or a boolean, got ${JSON.stringify(options.escape)}`)
// }else if(options.escape.length !== 1){
// throw new Error(`Invalid Option Length: escape must be one character, got ${options.escape.length}`)
// }else{
// options.escape = options.escape[0]
}

@@ -272,6 +266,2 @@ }

throw new Error(`Invalid Option: quote must be a buffer or a string, got ${JSON.stringify(options.quote)}`)
// }else if(options.quote.length !== 1){
// throw new Error(`Invalid Option Length: quote must be one character, got ${options.quote.length}`)
// }else{
// options.quote = options.quote[0]
}

@@ -570,3 +560,2 @@ }

// TODO: need to compare bytes instead of single char
// if(this.state.commenting === false && chr === quote){
if(this.state.commenting === false && this.__isQuote(buf, pos)){

@@ -576,3 +565,2 @@ if(this.state.quoting === true){

const isNextChrTrimable = rtrim && this.__isCharTrimable(nextChr)
// const isNextChrComment = nextChr === comment
const isNextChrComment = comment !== null && this.__compareBytes(comment, buf, pos+quote.length, nextChr)

@@ -583,4 +571,2 @@ const isNextChrDelimiter = this.__isDelimiter(buf, pos+quote.length, nextChr)

// Treat next char as a regular character
// TODO: need to compare bytes instead of single char
// if(escape !== null && chr === escape && nextChr === quote){
if(escape !== null && this.__isEscape(buf, pos, chr) && this.__isQuote(buf, pos + escape.length)){

@@ -788,3 +774,2 @@ pos += escape.length - 1

const err = this.__error(
// CSV_INVALID_RECORD_LENGTH_DONT_MATCH_COLUMNS
new CsvError('CSV_RECORD_DONT_MATCH_COLUMNS_LENGTH', [

@@ -820,3 +805,2 @@ 'Invalid Record Length:',

if(columns[i] === undefined || columns[i].disabled) continue
// obj[columns[i].name] = record[i]
// Turn duplicate columns into an array

@@ -823,0 +807,0 @@ if (columns_duplicates_to_array === true && obj[columns[i].name]) {

@@ -51,5 +51,7 @@

toString(encoding){
// console.log('!!', encoding)
// return this.buf.slice(0, this.length)
return this.buf.slice(0, this.length).toString(encoding)
if(encoding){
return this.buf.slice(0, this.length).toString(encoding)
}else{
return Uint8Array.prototype.slice.call(this.buf.slice(0, this.length))
}
}

@@ -56,0 +58,0 @@ toJSON(){

{
"version": "4.13.0",
"version": "4.13.1",
"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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc