2
2
3
3
function _wrapNativeSuper ( Class ) { var _cache = typeof Map === "function" ? new Map ( ) : undefined ; _wrapNativeSuper = function _wrapNativeSuper ( Class ) { if ( Class === null || ! _isNativeFunction ( Class ) ) return Class ; if ( typeof Class !== "function" ) { throw new TypeError ( "Super expression must either be null or a function" ) ; } if ( typeof _cache !== "undefined" ) { if ( _cache . has ( Class ) ) return _cache . get ( Class ) ; _cache . set ( Class , Wrapper ) ; } function Wrapper ( ) { return _construct ( Class , arguments , _getPrototypeOf ( this ) . constructor ) ; } Wrapper . prototype = Object . create ( Class . prototype , { constructor : { value : Wrapper , enumerable : false , writable : true , configurable : true } } ) ; return _setPrototypeOf ( Wrapper , Class ) ; } ; return _wrapNativeSuper ( Class ) ; }
4
4
5
- 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 ; } }
6
-
7
- 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 ) ; }
5
+ 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 ) ; }
8
6
9
7
function _isNativeFunction ( fn ) { return Function . toString . call ( fn ) . indexOf ( "[native code]" ) !== - 1 ; }
10
8
11
9
function _typeof ( obj ) { "@babel/helpers - typeof" ; if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) { _typeof = function _typeof ( obj ) { return typeof obj ; } ; } else { _typeof = function _typeof ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ; } return _typeof ( obj ) ; }
12
10
13
- function _slicedToArray ( arr , i ) { return _arrayWithHoles ( arr ) || _iterableToArrayLimit ( arr , i ) || _nonIterableRest ( ) ; }
11
+ function _slicedToArray ( arr , i ) { return _arrayWithHoles ( arr ) || _iterableToArrayLimit ( arr , i ) || _unsupportedIterableToArray ( arr , i ) || _nonIterableRest ( ) ; }
14
12
15
- function _nonIterableRest ( ) { throw new TypeError ( "Invalid attempt to destructure non-iterable instance" ) ; }
13
+ 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. " ) ; }
16
14
17
- 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 ; }
15
+ 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 ; }
18
16
19
17
function _arrayWithHoles ( arr ) { if ( Array . isArray ( arr ) ) return arr ; }
20
18
21
- function _toConsumableArray ( arr ) { return _arrayWithoutHoles ( arr ) || _iterableToArray ( arr ) || _nonIterableSpread ( ) ; }
19
+ function _toConsumableArray ( arr ) { return _arrayWithoutHoles ( arr ) || _iterableToArray ( arr ) || _unsupportedIterableToArray ( arr ) || _nonIterableSpread ( ) ; }
20
+
21
+ 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." ) ; }
22
+
23
+ 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" || / ^ (?: U i | I ) n t (?: 8 | 1 6 | 3 2 ) (?: C l a m p e d ) ? A r r a y $ / . test ( n ) ) return _arrayLikeToArray ( o , minLen ) ; }
22
24
23
- function _nonIterableSpread ( ) { throw new TypeError ( "Invalid attempt to spread non-iterable instance" ) ; }
25
+ function _iterableToArray ( iter ) { if ( typeof Symbol !== "undefined" && Symbol . iterator in Object ( iter ) ) return Array . from ( iter ) ; }
24
26
25
- function _iterableToArray ( iter ) { if ( Symbol . iterator in Object ( iter ) || Object . prototype . toString . call ( iter ) === "[object Arguments]" ) return Array . from ( iter ) ; }
27
+ function _arrayWithoutHoles ( arr ) { if ( Array . isArray ( arr ) ) return _arrayLikeToArray ( arr ) ; }
26
28
27
- 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 ; } }
29
+ 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 ; }
28
30
29
31
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 ; }
30
32
@@ -38,15 +40,19 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
38
40
39
41
function _createClass ( Constructor , protoProps , staticProps ) { if ( protoProps ) _defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) _defineProperties ( Constructor , staticProps ) ; return Constructor ; }
40
42
43
+ 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 ) ; }
44
+
45
+ function _setPrototypeOf ( o , p ) { _setPrototypeOf = Object . setPrototypeOf || function _setPrototypeOf ( o , p ) { o . __proto__ = p ; return o ; } ; return _setPrototypeOf ( o , p ) ; }
46
+
47
+ 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 ) ; } ; }
48
+
41
49
function _possibleConstructorReturn ( self , call ) { if ( call && ( _typeof ( call ) === "object" || typeof call === "function" ) ) { return call ; } return _assertThisInitialized ( self ) ; }
42
50
43
51
function _assertThisInitialized ( self ) { if ( self === void 0 ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return self ; }
44
52
45
- function _getPrototypeOf ( o ) { _getPrototypeOf = Object . setPrototypeOf ? Object . getPrototypeOf : function _getPrototypeOf ( o ) { return o . __proto__ || Object . getPrototypeOf ( o ) ; } ; return _getPrototypeOf ( o ) ; }
46
-
47
- 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 ) ; }
53
+ 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 ; } }
48
54
49
- function _setPrototypeOf ( o , p ) { _setPrototypeOf = Object . setPrototypeOf || function _setPrototypeOf ( o , p ) { o . __proto__ = p ; return o ; } ; return _setPrototypeOf ( o , p ) ; }
55
+ function _getPrototypeOf ( o ) { _getPrototypeOf = Object . setPrototypeOf ? Object . getPrototypeOf : function _getPrototypeOf ( o ) { return o . __proto__ || Object . getPrototypeOf ( o ) ; } ; return _getPrototypeOf ( o ) ; }
50
56
51
57
/*
52
58
CSV Parse
@@ -69,16 +75,18 @@ var bom_utf8 = Buffer.from([239, 187, 191]);
69
75
var Parser = /*#__PURE__*/ function ( _Transform ) {
70
76
_inherits ( Parser , _Transform ) ;
71
77
78
+ var _super = _createSuper ( Parser ) ;
79
+
72
80
function Parser ( ) {
73
81
var _this ;
74
82
75
83
var opts = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
76
84
77
85
_classCallCheck ( this , Parser ) ;
78
86
79
- _this = _possibleConstructorReturn ( this , _getPrototypeOf ( Parser ) . call ( this , _objectSpread ( { } , {
87
+ _this = _super . call ( this , _objectSpread ( _objectSpread ( { } , {
80
88
readableObjectMode : true
81
- } , { } , opts ) ) ) ;
89
+ } ) , opts ) ) ;
82
90
var options = { } ; // Merge with user options
83
91
84
92
for ( var opt in opts ) {
@@ -177,18 +185,22 @@ var Parser = /*#__PURE__*/function (_Transform) {
177
185
return delimiter ;
178
186
} ) ; // Normalize option `escape`
179
187
180
- if ( options . escape === undefined || options . escape === null ) {
188
+ if ( options . escape === undefined || options . escape === true ) {
181
189
options . escape = Buffer . from ( '"' ) ;
182
190
} else if ( typeof options . escape === 'string' ) {
183
191
options . escape = Buffer . from ( options . escape ) ;
192
+ } else if ( options . escape === null || options . escape === false ) {
193
+ options . escape = null ;
184
194
}
185
195
186
- if ( ! Buffer . isBuffer ( options . escape ) ) {
187
- throw new Error ( "Invalid Option: escape must be a buffer or a string, got " . concat ( JSON . stringify ( options . escape ) ) ) ;
188
- } else if ( options . escape . length !== 1 ) {
189
- throw new Error ( "Invalid Option Length: escape must be one character, got " . concat ( options . escape . length ) ) ;
190
- } else {
191
- options . escape = options . escape [ 0 ] ;
196
+ if ( options . escape !== null ) {
197
+ if ( ! Buffer . isBuffer ( options . escape ) ) {
198
+ throw new Error ( "Invalid Option: escape must be a buffer, a string or a boolean, got " . concat ( JSON . stringify ( options . escape ) ) ) ;
199
+ } else if ( options . escape . length !== 1 ) {
200
+ throw new Error ( "Invalid Option Length: escape must be one character, got " . concat ( options . escape . length ) ) ;
201
+ } else {
202
+ options . escape = options . escape [ 0 ] ;
203
+ }
192
204
} // Normalize option `from`
193
205
194
206
@@ -608,7 +620,7 @@ var Parser = /*#__PURE__*/function (_Transform) {
608
620
} else {
609
621
// Escape is only active inside quoted fields
610
622
// We are quoting, the char is an escape chr and there is a chr to escape
611
- if ( this . state . quoting === true && chr === escape && pos + 1 < bufLen ) {
623
+ if ( escape !== null && this . state . quoting === true && chr === escape && pos + 1 < bufLen ) {
612
624
if ( escapeIsQuote ) {
613
625
if ( buf [ pos + 1 ] === quote ) {
614
626
this . state . escaping = true ;
@@ -637,7 +649,7 @@ var Parser = /*#__PURE__*/function (_Transform) {
637
649
// Treat next char as a regular character
638
650
// TODO: need to compare bytes instead of single char
639
651
640
- if ( chr === escape && nextChr === quote ) {
652
+ if ( escape !== null && chr === escape && nextChr === quote ) {
641
653
pos ++ ;
642
654
} else if ( ! nextChr || isNextChrDelimiter || isNextChrRowDelimiter || isNextChrComment || isNextChrTrimable ) {
643
655
this . state . quoting = false ;
@@ -1309,13 +1321,15 @@ var parse = function parse() {
1309
1321
var CsvError = /*#__PURE__*/ function ( _Error ) {
1310
1322
_inherits ( CsvError , _Error ) ;
1311
1323
1324
+ var _super2 = _createSuper ( CsvError ) ;
1325
+
1312
1326
function CsvError ( code , message ) {
1313
1327
var _this2 ;
1314
1328
1315
1329
_classCallCheck ( this , CsvError ) ;
1316
1330
1317
1331
if ( Array . isArray ( message ) ) message = message . join ( ' ' ) ;
1318
- _this2 = _possibleConstructorReturn ( this , _getPrototypeOf ( CsvError ) . call ( this , message ) ) ;
1332
+ _this2 = _super2 . call ( this , message ) ;
1319
1333
1320
1334
if ( Error . captureStackTrace !== undefined ) {
1321
1335
Error . captureStackTrace ( _assertThisInitialized ( _this2 ) , CsvError ) ;
0 commit comments