csv-parse
Advanced tools
Comparing version 4.10.1 to 4.11.1
@@ -13,2 +13,15 @@ | ||
## Version 4.11.1 | ||
New feature: | ||
* escape: disabled when null or false | ||
Project management: | ||
* travis: test node version 14 | ||
## Version 4.11 | ||
Project management: | ||
* mistake in the release | ||
## Version 4.10.1 | ||
@@ -15,0 +28,0 @@ |
@@ -5,6 +5,4 @@ "use strict"; | ||
function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } | ||
@@ -14,18 +12,22 @@ | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
@@ -43,2 +45,8 @@ | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
@@ -48,8 +56,6 @@ | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
/* | ||
@@ -76,2 +82,4 @@ CSV Parse | ||
var _super = _createSuper(Parser); | ||
function Parser() { | ||
@@ -84,5 +92,5 @@ var _this; | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(Parser).call(this, _objectSpread({}, { | ||
_this = _super.call(this, _objectSpread(_objectSpread({}, { | ||
readableObjectMode: true | ||
}, {}, opts))); | ||
}), opts)); | ||
var options = {}; // Merge with user options | ||
@@ -186,14 +194,18 @@ | ||
if (options.escape === undefined || options.escape === null) { | ||
if (options.escape === undefined || options.escape === true) { | ||
options.escape = Buffer.from('"'); | ||
} else if (typeof options.escape === 'string') { | ||
options.escape = Buffer.from(options.escape); | ||
} else if (options.escape === null || options.escape === false) { | ||
options.escape = null; | ||
} | ||
if (!Buffer.isBuffer(options.escape)) { | ||
throw new Error("Invalid Option: escape must be a buffer or a string, got ".concat(JSON.stringify(options.escape))); | ||
} else if (options.escape.length !== 1) { | ||
throw new Error("Invalid Option Length: escape must be one character, got ".concat(options.escape.length)); | ||
} else { | ||
options.escape = options.escape[0]; | ||
if (options.escape !== null) { | ||
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 ".concat(options.escape.length)); | ||
} else { | ||
options.escape = options.escape[0]; | ||
} | ||
} // Normalize option `from` | ||
@@ -618,3 +630,3 @@ | ||
// We are quoting, the char is an escape chr and there is a chr to escape | ||
if (this.state.quoting === true && chr === escape && pos + 1 < bufLen) { | ||
if (escape !== null && this.state.quoting === true && chr === escape && pos + 1 < bufLen) { | ||
if (escapeIsQuote) { | ||
@@ -648,3 +660,3 @@ if (buf[pos + 1] === quote) { | ||
if (chr === escape && nextChr === quote) { | ||
if (escape !== null && chr === escape && nextChr === quote) { | ||
pos++; | ||
@@ -1321,2 +1333,4 @@ } else if (!nextChr || isNextChrDelimiter || isNextChrRowDelimiter || isNextChrComment || isNextChrTrimable) { | ||
var _super2 = _createSuper(CsvError); | ||
function CsvError(code, message) { | ||
@@ -1328,3 +1342,3 @@ var _this2; | ||
if (Array.isArray(message)) message = message.join(' '); | ||
_this2 = _possibleConstructorReturn(this, _getPrototypeOf(CsvError).call(this, message)); | ||
_this2 = _super2.call(this, message); | ||
@@ -1331,0 +1345,0 @@ if (Error.captureStackTrace !== undefined) { |
@@ -134,13 +134,17 @@ | ||
// Normalize option `escape` | ||
if(options.escape === undefined || options.escape === null){ | ||
if(options.escape === undefined || options.escape === true){ | ||
options.escape = Buffer.from('"') | ||
}else if(typeof options.escape === 'string'){ | ||
options.escape = Buffer.from(options.escape) | ||
}else if (options.escape === null || options.escape === false){ | ||
options.escape = null | ||
} | ||
if(!Buffer.isBuffer(options.escape)){ | ||
throw new Error(`Invalid Option: escape must be a buffer or a string, 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] | ||
if(options.escape !== null){ | ||
if(!Buffer.isBuffer(options.escape)){ | ||
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] | ||
} | ||
} | ||
@@ -498,3 +502,3 @@ // Normalize option `from` | ||
// We are quoting, the char is an escape chr and there is a chr to escape | ||
if(this.state.quoting === true && chr === escape && pos + 1 < bufLen){ | ||
if(escape !== null && this.state.quoting === true && chr === escape && pos + 1 < bufLen){ | ||
if(escapeIsQuote){ | ||
@@ -523,3 +527,3 @@ if(buf[pos+1] === quote){ | ||
// TODO: need to compare bytes instead of single char | ||
if(chr === escape && nextChr === quote){ | ||
if(escape !== null && chr === escape && nextChr === quote){ | ||
pos++ | ||
@@ -526,0 +530,0 @@ }else if(!nextChr || isNextChrDelimiter || isNextChrRowDelimiter || isNextChrComment || isNextChrTrimable){ |
{ | ||
"version": "4.10.1", | ||
"version": "4.11.1", | ||
"name": "csv-parse", | ||
@@ -4,0 +4,0 @@ "description": "CSV parsing implementing the Node.js `stream.Transform` API", |
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
151782
2824