@lizardbyte/contribkit 2025.315.185528

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4905 @@
1
+ import require$$0$1 from 'fs';
2
+ import require$$1 from 'stream';
3
+ import require$$0 from 'string_decoder';
4
+
5
+ function _mergeNamespaces(n, m) {
6
+ for (var i = 0; i < m.length; i++) {
7
+ const e = m[i];
8
+ if (typeof e !== 'string' && !Array.isArray(e)) { for (const k in e) {
9
+ if (k !== 'default' && !(k in n)) {
10
+ n[k] = e[k];
11
+ }
12
+ } }
13
+ }
14
+ return n;
15
+ }
16
+
17
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
18
+
19
+ var src = {};
20
+
21
+ var ParserOptions = {};
22
+
23
+ /**
24
+ * lodash (Custom Build) <https://lodash.com/>
25
+ * Build: `lodash modularize exports="npm" -o ./`
26
+ * Copyright jQuery Foundation and other contributors <https://jquery.org/>
27
+ * Released under MIT license <https://lodash.com/license>
28
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
29
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
30
+ */
31
+
32
+ var lodash_escaperegexp;
33
+ var hasRequiredLodash_escaperegexp;
34
+
35
+ function requireLodash_escaperegexp () {
36
+ if (hasRequiredLodash_escaperegexp) return lodash_escaperegexp;
37
+ hasRequiredLodash_escaperegexp = 1;
38
+
39
+ /** `Object#toString` result references. */
40
+ var symbolTag = '[object Symbol]';
41
+
42
+ /**
43
+ * Used to match `RegExp`
44
+ * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
45
+ */
46
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
47
+ reHasRegExpChar = RegExp(reRegExpChar.source);
48
+
49
+ /** Detect free variable `global` from Node.js. */
50
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
51
+
52
+ /** Detect free variable `self`. */
53
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
54
+
55
+ /** Used as a reference to the global object. */
56
+ var root = freeGlobal || freeSelf || Function('return this')();
57
+
58
+ /** Used for built-in method references. */
59
+ var objectProto = Object.prototype;
60
+
61
+ /**
62
+ * Used to resolve the
63
+ * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
64
+ * of values.
65
+ */
66
+ var objectToString = objectProto.toString;
67
+
68
+ /** Built-in value references. */
69
+ var Symbol = root.Symbol;
70
+
71
+ /** Used to convert symbols to primitives and strings. */
72
+ var symbolProto = Symbol ? Symbol.prototype : undefined,
73
+ symbolToString = symbolProto ? symbolProto.toString : undefined;
74
+
75
+ /**
76
+ * The base implementation of `_.toString` which doesn't convert nullish
77
+ * values to empty strings.
78
+ *
79
+ * @private
80
+ * @param {*} value The value to process.
81
+ * @returns {string} Returns the string.
82
+ */
83
+ function baseToString(value) {
84
+ // Exit early for strings to avoid a performance hit in some environments.
85
+ if (typeof value == 'string') {
86
+ return value;
87
+ }
88
+ if (isSymbol(value)) {
89
+ return symbolToString ? symbolToString.call(value) : '';
90
+ }
91
+ var result = (value + '');
92
+ return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
93
+ }
94
+
95
+ /**
96
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
97
+ * and has a `typeof` result of "object".
98
+ *
99
+ * @static
100
+ * @memberOf _
101
+ * @since 4.0.0
102
+ * @category Lang
103
+ * @param {*} value The value to check.
104
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
105
+ * @example
106
+ *
107
+ * _.isObjectLike({});
108
+ * // => true
109
+ *
110
+ * _.isObjectLike([1, 2, 3]);
111
+ * // => true
112
+ *
113
+ * _.isObjectLike(_.noop);
114
+ * // => false
115
+ *
116
+ * _.isObjectLike(null);
117
+ * // => false
118
+ */
119
+ function isObjectLike(value) {
120
+ return !!value && typeof value == 'object';
121
+ }
122
+
123
+ /**
124
+ * Checks if `value` is classified as a `Symbol` primitive or object.
125
+ *
126
+ * @static
127
+ * @memberOf _
128
+ * @since 4.0.0
129
+ * @category Lang
130
+ * @param {*} value The value to check.
131
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
132
+ * @example
133
+ *
134
+ * _.isSymbol(Symbol.iterator);
135
+ * // => true
136
+ *
137
+ * _.isSymbol('abc');
138
+ * // => false
139
+ */
140
+ function isSymbol(value) {
141
+ return typeof value == 'symbol' ||
142
+ (isObjectLike(value) && objectToString.call(value) == symbolTag);
143
+ }
144
+
145
+ /**
146
+ * Converts `value` to a string. An empty string is returned for `null`
147
+ * and `undefined` values. The sign of `-0` is preserved.
148
+ *
149
+ * @static
150
+ * @memberOf _
151
+ * @since 4.0.0
152
+ * @category Lang
153
+ * @param {*} value The value to process.
154
+ * @returns {string} Returns the string.
155
+ * @example
156
+ *
157
+ * _.toString(null);
158
+ * // => ''
159
+ *
160
+ * _.toString(-0);
161
+ * // => '-0'
162
+ *
163
+ * _.toString([1, 2, 3]);
164
+ * // => '1,2,3'
165
+ */
166
+ function toString(value) {
167
+ return value == null ? '' : baseToString(value);
168
+ }
169
+
170
+ /**
171
+ * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
172
+ * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
173
+ *
174
+ * @static
175
+ * @memberOf _
176
+ * @since 3.0.0
177
+ * @category String
178
+ * @param {string} [string=''] The string to escape.
179
+ * @returns {string} Returns the escaped string.
180
+ * @example
181
+ *
182
+ * _.escapeRegExp('[lodash](https://lodash.com/)');
183
+ * // => '\[lodash\]\(https://lodash\.com/\)'
184
+ */
185
+ function escapeRegExp(string) {
186
+ string = toString(string);
187
+ return (string && reHasRegExpChar.test(string))
188
+ ? string.replace(reRegExpChar, '\\$&')
189
+ : string;
190
+ }
191
+
192
+ lodash_escaperegexp = escapeRegExp;
193
+ return lodash_escaperegexp;
194
+ }
195
+
196
+ /**
197
+ * lodash 4.0.0 (Custom Build) <https://lodash.com/>
198
+ * Build: `lodash modularize exports="npm" -o ./`
199
+ * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
200
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
201
+ * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
202
+ * Available under MIT license <https://lodash.com/license>
203
+ */
204
+
205
+ var lodash_isnil;
206
+ var hasRequiredLodash_isnil;
207
+
208
+ function requireLodash_isnil () {
209
+ if (hasRequiredLodash_isnil) return lodash_isnil;
210
+ hasRequiredLodash_isnil = 1;
211
+ /**
212
+ * Checks if `value` is `null` or `undefined`.
213
+ *
214
+ * @static
215
+ * @memberOf _
216
+ * @category Lang
217
+ * @param {*} value The value to check.
218
+ * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
219
+ * @example
220
+ *
221
+ * _.isNil(null);
222
+ * // => true
223
+ *
224
+ * _.isNil(void 0);
225
+ * // => true
226
+ *
227
+ * _.isNil(NaN);
228
+ * // => false
229
+ */
230
+ function isNil(value) {
231
+ return value == null;
232
+ }
233
+
234
+ lodash_isnil = isNil;
235
+ return lodash_isnil;
236
+ }
237
+
238
+ var hasRequiredParserOptions;
239
+
240
+ function requireParserOptions () {
241
+ if (hasRequiredParserOptions) return ParserOptions;
242
+ hasRequiredParserOptions = 1;
243
+ var __importDefault = (ParserOptions && ParserOptions.__importDefault) || function (mod) {
244
+ return (mod && mod.__esModule) ? mod : { "default": mod };
245
+ };
246
+ Object.defineProperty(ParserOptions, "__esModule", { value: true });
247
+ ParserOptions.ParserOptions = void 0;
248
+ const lodash_escaperegexp_1 = __importDefault(requireLodash_escaperegexp());
249
+ const lodash_isnil_1 = __importDefault(requireLodash_isnil());
250
+ let ParserOptions$1 = class ParserOptions {
251
+ escapedDelimiter;
252
+ objectMode = true;
253
+ delimiter = ',';
254
+ ignoreEmpty = false;
255
+ quote = '"';
256
+ escape = null;
257
+ escapeChar = this.quote;
258
+ comment = null;
259
+ supportsComments = false;
260
+ ltrim = false;
261
+ rtrim = false;
262
+ trim = false;
263
+ headers = null;
264
+ renameHeaders = false;
265
+ strictColumnHandling = false;
266
+ discardUnmappedColumns = false;
267
+ carriageReturn = '\r';
268
+ NEXT_TOKEN_REGEXP;
269
+ encoding = 'utf8';
270
+ limitRows = false;
271
+ maxRows = 0;
272
+ skipLines = 0;
273
+ skipRows = 0;
274
+ constructor(opts) {
275
+ Object.assign(this, opts || {});
276
+ if (this.delimiter.length > 1) {
277
+ throw new Error('delimiter option must be one character long');
278
+ }
279
+ this.escapedDelimiter = (0, lodash_escaperegexp_1.default)(this.delimiter);
280
+ this.escapeChar = this.escape ?? this.quote;
281
+ this.supportsComments = !(0, lodash_isnil_1.default)(this.comment);
282
+ this.NEXT_TOKEN_REGEXP = new RegExp(`([^\\s]|\\r\\n|\\n|\\r|${this.escapedDelimiter})`);
283
+ if (this.maxRows > 0) {
284
+ this.limitRows = true;
285
+ }
286
+ }
287
+ };
288
+ ParserOptions.ParserOptions = ParserOptions$1;
289
+
290
+ return ParserOptions;
291
+ }
292
+
293
+ var CsvParserStream = {};
294
+
295
+ var transforms = {};
296
+
297
+ var RowTransformerValidator = {};
298
+
299
+ /**
300
+ * Lodash (Custom Build) <https://lodash.com/>
301
+ * Build: `lodash modularize exports="npm" -o ./`
302
+ * Copyright JS Foundation and other contributors <https://js.foundation/>
303
+ * Released under MIT license <https://lodash.com/license>
304
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
305
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
306
+ */
307
+
308
+ var lodash_isfunction;
309
+ var hasRequiredLodash_isfunction;
310
+
311
+ function requireLodash_isfunction () {
312
+ if (hasRequiredLodash_isfunction) return lodash_isfunction;
313
+ hasRequiredLodash_isfunction = 1;
314
+ /** `Object#toString` result references. */
315
+ var asyncTag = '[object AsyncFunction]',
316
+ funcTag = '[object Function]',
317
+ genTag = '[object GeneratorFunction]',
318
+ nullTag = '[object Null]',
319
+ proxyTag = '[object Proxy]',
320
+ undefinedTag = '[object Undefined]';
321
+
322
+ /** Detect free variable `global` from Node.js. */
323
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
324
+
325
+ /** Detect free variable `self`. */
326
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
327
+
328
+ /** Used as a reference to the global object. */
329
+ var root = freeGlobal || freeSelf || Function('return this')();
330
+
331
+ /** Used for built-in method references. */
332
+ var objectProto = Object.prototype;
333
+
334
+ /** Used to check objects for own properties. */
335
+ var hasOwnProperty = objectProto.hasOwnProperty;
336
+
337
+ /**
338
+ * Used to resolve the
339
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
340
+ * of values.
341
+ */
342
+ var nativeObjectToString = objectProto.toString;
343
+
344
+ /** Built-in value references. */
345
+ var Symbol = root.Symbol,
346
+ symToStringTag = Symbol ? Symbol.toStringTag : undefined;
347
+
348
+ /**
349
+ * The base implementation of `getTag` without fallbacks for buggy environments.
350
+ *
351
+ * @private
352
+ * @param {*} value The value to query.
353
+ * @returns {string} Returns the `toStringTag`.
354
+ */
355
+ function baseGetTag(value) {
356
+ if (value == null) {
357
+ return value === undefined ? undefinedTag : nullTag;
358
+ }
359
+ return (symToStringTag && symToStringTag in Object(value))
360
+ ? getRawTag(value)
361
+ : objectToString(value);
362
+ }
363
+
364
+ /**
365
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
366
+ *
367
+ * @private
368
+ * @param {*} value The value to query.
369
+ * @returns {string} Returns the raw `toStringTag`.
370
+ */
371
+ function getRawTag(value) {
372
+ var isOwn = hasOwnProperty.call(value, symToStringTag),
373
+ tag = value[symToStringTag];
374
+
375
+ try {
376
+ value[symToStringTag] = undefined;
377
+ var unmasked = true;
378
+ } catch (e) {}
379
+
380
+ var result = nativeObjectToString.call(value);
381
+ if (unmasked) {
382
+ if (isOwn) {
383
+ value[symToStringTag] = tag;
384
+ } else {
385
+ delete value[symToStringTag];
386
+ }
387
+ }
388
+ return result;
389
+ }
390
+
391
+ /**
392
+ * Converts `value` to a string using `Object.prototype.toString`.
393
+ *
394
+ * @private
395
+ * @param {*} value The value to convert.
396
+ * @returns {string} Returns the converted string.
397
+ */
398
+ function objectToString(value) {
399
+ return nativeObjectToString.call(value);
400
+ }
401
+
402
+ /**
403
+ * Checks if `value` is classified as a `Function` object.
404
+ *
405
+ * @static
406
+ * @memberOf _
407
+ * @since 0.1.0
408
+ * @category Lang
409
+ * @param {*} value The value to check.
410
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
411
+ * @example
412
+ *
413
+ * _.isFunction(_);
414
+ * // => true
415
+ *
416
+ * _.isFunction(/abc/);
417
+ * // => false
418
+ */
419
+ function isFunction(value) {
420
+ if (!isObject(value)) {
421
+ return false;
422
+ }
423
+ // The use of `Object#toString` avoids issues with the `typeof` operator
424
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
425
+ var tag = baseGetTag(value);
426
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
427
+ }
428
+
429
+ /**
430
+ * Checks if `value` is the
431
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
432
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
433
+ *
434
+ * @static
435
+ * @memberOf _
436
+ * @since 0.1.0
437
+ * @category Lang
438
+ * @param {*} value The value to check.
439
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
440
+ * @example
441
+ *
442
+ * _.isObject({});
443
+ * // => true
444
+ *
445
+ * _.isObject([1, 2, 3]);
446
+ * // => true
447
+ *
448
+ * _.isObject(_.noop);
449
+ * // => true
450
+ *
451
+ * _.isObject(null);
452
+ * // => false
453
+ */
454
+ function isObject(value) {
455
+ var type = typeof value;
456
+ return value != null && (type == 'object' || type == 'function');
457
+ }
458
+
459
+ lodash_isfunction = isFunction;
460
+ return lodash_isfunction;
461
+ }
462
+
463
+ var types = {};
464
+
465
+ var hasRequiredTypes;
466
+
467
+ function requireTypes () {
468
+ if (hasRequiredTypes) return types;
469
+ hasRequiredTypes = 1;
470
+ Object.defineProperty(types, "__esModule", { value: true });
471
+ types.isSyncValidate = types.isSyncTransform = void 0;
472
+ const isSyncTransform = (transform) => {
473
+ return transform.length === 1;
474
+ };
475
+ types.isSyncTransform = isSyncTransform;
476
+ const isSyncValidate = (validate) => {
477
+ return validate.length === 1;
478
+ };
479
+ types.isSyncValidate = isSyncValidate;
480
+
481
+ return types;
482
+ }
483
+
484
+ var hasRequiredRowTransformerValidator;
485
+
486
+ function requireRowTransformerValidator () {
487
+ if (hasRequiredRowTransformerValidator) return RowTransformerValidator;
488
+ hasRequiredRowTransformerValidator = 1;
489
+ var __importDefault = (RowTransformerValidator && RowTransformerValidator.__importDefault) || function (mod) {
490
+ return (mod && mod.__esModule) ? mod : { "default": mod };
491
+ };
492
+ Object.defineProperty(RowTransformerValidator, "__esModule", { value: true });
493
+ RowTransformerValidator.RowTransformerValidator = void 0;
494
+ const lodash_isfunction_1 = __importDefault(requireLodash_isfunction());
495
+ const types_1 = requireTypes();
496
+ let RowTransformerValidator$1 = class RowTransformerValidator {
497
+ // eslint-disable-next-line @typescript-eslint/no-shadow
498
+ static createTransform(transformFunction) {
499
+ if ((0, types_1.isSyncTransform)(transformFunction)) {
500
+ return (row, cb) => {
501
+ let transformed = null;
502
+ try {
503
+ transformed = transformFunction(row);
504
+ }
505
+ catch (e) {
506
+ return cb(e);
507
+ }
508
+ return cb(null, transformed);
509
+ };
510
+ }
511
+ return transformFunction;
512
+ }
513
+ static createValidator(validateFunction) {
514
+ if ((0, types_1.isSyncValidate)(validateFunction)) {
515
+ return (row, cb) => {
516
+ cb(null, { row, isValid: validateFunction(row) });
517
+ };
518
+ }
519
+ return (row, cb) => {
520
+ validateFunction(row, (err, isValid, reason) => {
521
+ if (err) {
522
+ return cb(err);
523
+ }
524
+ if (isValid) {
525
+ return cb(null, { row, isValid, reason });
526
+ }
527
+ return cb(null, { row, isValid: false, reason });
528
+ });
529
+ };
530
+ }
531
+ _rowTransform = null;
532
+ _rowValidator = null;
533
+ set rowTransform(transformFunction) {
534
+ if (!(0, lodash_isfunction_1.default)(transformFunction)) {
535
+ throw new TypeError('The transform should be a function');
536
+ }
537
+ this._rowTransform = RowTransformerValidator.createTransform(transformFunction);
538
+ }
539
+ set rowValidator(validateFunction) {
540
+ if (!(0, lodash_isfunction_1.default)(validateFunction)) {
541
+ throw new TypeError('The validate should be a function');
542
+ }
543
+ this._rowValidator = RowTransformerValidator.createValidator(validateFunction);
544
+ }
545
+ transformAndValidate(row, cb) {
546
+ return this.callTransformer(row, (transformErr, transformedRow) => {
547
+ if (transformErr) {
548
+ return cb(transformErr);
549
+ }
550
+ if (!transformedRow) {
551
+ return cb(null, { row: null, isValid: true });
552
+ }
553
+ return this.callValidator(transformedRow, (validateErr, validationResult) => {
554
+ if (validateErr) {
555
+ return cb(validateErr);
556
+ }
557
+ if (validationResult && !validationResult.isValid) {
558
+ return cb(null, { row: transformedRow, isValid: false, reason: validationResult.reason });
559
+ }
560
+ return cb(null, { row: transformedRow, isValid: true });
561
+ });
562
+ });
563
+ }
564
+ callTransformer(row, cb) {
565
+ if (!this._rowTransform) {
566
+ return cb(null, row);
567
+ }
568
+ return this._rowTransform(row, cb);
569
+ }
570
+ callValidator(row, cb) {
571
+ if (!this._rowValidator) {
572
+ return cb(null, { row, isValid: true });
573
+ }
574
+ return this._rowValidator(row, cb);
575
+ }
576
+ };
577
+ RowTransformerValidator.RowTransformerValidator = RowTransformerValidator$1;
578
+
579
+ return RowTransformerValidator;
580
+ }
581
+
582
+ var HeaderTransformer = {};
583
+
584
+ /**
585
+ * lodash 3.0.1 (Custom Build) <https://lodash.com/>
586
+ * Build: `lodash modern modularize exports="npm" -o ./`
587
+ * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
588
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
589
+ * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
590
+ * Available under MIT license <https://lodash.com/license>
591
+ */
592
+
593
+ var lodash_isundefined;
594
+ var hasRequiredLodash_isundefined;
595
+
596
+ function requireLodash_isundefined () {
597
+ if (hasRequiredLodash_isundefined) return lodash_isundefined;
598
+ hasRequiredLodash_isundefined = 1;
599
+ /**
600
+ * Checks if `value` is `undefined`.
601
+ *
602
+ * @static
603
+ * @memberOf _
604
+ * @category Lang
605
+ * @param {*} value The value to check.
606
+ * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
607
+ * @example
608
+ *
609
+ * _.isUndefined(void 0);
610
+ * // => true
611
+ *
612
+ * _.isUndefined(null);
613
+ * // => false
614
+ */
615
+ function isUndefined(value) {
616
+ return value === undefined;
617
+ }
618
+
619
+ lodash_isundefined = isUndefined;
620
+ return lodash_isundefined;
621
+ }
622
+
623
+ /**
624
+ * lodash (Custom Build) <https://lodash.com/>
625
+ * Build: `lodash modularize exports="npm" -o ./`
626
+ * Copyright jQuery Foundation and other contributors <https://jquery.org/>
627
+ * Released under MIT license <https://lodash.com/license>
628
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
629
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
630
+ */
631
+
632
+ var lodash_uniq;
633
+ var hasRequiredLodash_uniq;
634
+
635
+ function requireLodash_uniq () {
636
+ if (hasRequiredLodash_uniq) return lodash_uniq;
637
+ hasRequiredLodash_uniq = 1;
638
+ /** Used as the size to enable large array optimizations. */
639
+ var LARGE_ARRAY_SIZE = 200;
640
+
641
+ /** Used to stand-in for `undefined` hash values. */
642
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
643
+
644
+ /** Used as references for various `Number` constants. */
645
+ var INFINITY = 1 / 0;
646
+
647
+ /** `Object#toString` result references. */
648
+ var funcTag = '[object Function]',
649
+ genTag = '[object GeneratorFunction]';
650
+
651
+ /**
652
+ * Used to match `RegExp`
653
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
654
+ */
655
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
656
+
657
+ /** Used to detect host constructors (Safari). */
658
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
659
+
660
+ /** Detect free variable `global` from Node.js. */
661
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
662
+
663
+ /** Detect free variable `self`. */
664
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
665
+
666
+ /** Used as a reference to the global object. */
667
+ var root = freeGlobal || freeSelf || Function('return this')();
668
+
669
+ /**
670
+ * A specialized version of `_.includes` for arrays without support for
671
+ * specifying an index to search from.
672
+ *
673
+ * @private
674
+ * @param {Array} [array] The array to inspect.
675
+ * @param {*} target The value to search for.
676
+ * @returns {boolean} Returns `true` if `target` is found, else `false`.
677
+ */
678
+ function arrayIncludes(array, value) {
679
+ var length = array ? array.length : 0;
680
+ return !!length && baseIndexOf(array, value, 0) > -1;
681
+ }
682
+
683
+ /**
684
+ * The base implementation of `_.findIndex` and `_.findLastIndex` without
685
+ * support for iteratee shorthands.
686
+ *
687
+ * @private
688
+ * @param {Array} array The array to inspect.
689
+ * @param {Function} predicate The function invoked per iteration.
690
+ * @param {number} fromIndex The index to search from.
691
+ * @param {boolean} [fromRight] Specify iterating from right to left.
692
+ * @returns {number} Returns the index of the matched value, else `-1`.
693
+ */
694
+ function baseFindIndex(array, predicate, fromIndex, fromRight) {
695
+ var length = array.length,
696
+ index = fromIndex + (-1);
697
+
698
+ while ((++index < length)) {
699
+ if (predicate(array[index], index, array)) {
700
+ return index;
701
+ }
702
+ }
703
+ return -1;
704
+ }
705
+
706
+ /**
707
+ * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
708
+ *
709
+ * @private
710
+ * @param {Array} array The array to inspect.
711
+ * @param {*} value The value to search for.
712
+ * @param {number} fromIndex The index to search from.
713
+ * @returns {number} Returns the index of the matched value, else `-1`.
714
+ */
715
+ function baseIndexOf(array, value, fromIndex) {
716
+ if (value !== value) {
717
+ return baseFindIndex(array, baseIsNaN, fromIndex);
718
+ }
719
+ var index = fromIndex - 1,
720
+ length = array.length;
721
+
722
+ while (++index < length) {
723
+ if (array[index] === value) {
724
+ return index;
725
+ }
726
+ }
727
+ return -1;
728
+ }
729
+
730
+ /**
731
+ * The base implementation of `_.isNaN` without support for number objects.
732
+ *
733
+ * @private
734
+ * @param {*} value The value to check.
735
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
736
+ */
737
+ function baseIsNaN(value) {
738
+ return value !== value;
739
+ }
740
+
741
+ /**
742
+ * Checks if a cache value for `key` exists.
743
+ *
744
+ * @private
745
+ * @param {Object} cache The cache to query.
746
+ * @param {string} key The key of the entry to check.
747
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
748
+ */
749
+ function cacheHas(cache, key) {
750
+ return cache.has(key);
751
+ }
752
+
753
+ /**
754
+ * Gets the value at `key` of `object`.
755
+ *
756
+ * @private
757
+ * @param {Object} [object] The object to query.
758
+ * @param {string} key The key of the property to get.
759
+ * @returns {*} Returns the property value.
760
+ */
761
+ function getValue(object, key) {
762
+ return object == null ? undefined : object[key];
763
+ }
764
+
765
+ /**
766
+ * Checks if `value` is a host object in IE < 9.
767
+ *
768
+ * @private
769
+ * @param {*} value The value to check.
770
+ * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
771
+ */
772
+ function isHostObject(value) {
773
+ // Many host objects are `Object` objects that can coerce to strings
774
+ // despite having improperly defined `toString` methods.
775
+ var result = false;
776
+ if (value != null && typeof value.toString != 'function') {
777
+ try {
778
+ result = !!(value + '');
779
+ } catch (e) {}
780
+ }
781
+ return result;
782
+ }
783
+
784
+ /**
785
+ * Converts `set` to an array of its values.
786
+ *
787
+ * @private
788
+ * @param {Object} set The set to convert.
789
+ * @returns {Array} Returns the values.
790
+ */
791
+ function setToArray(set) {
792
+ var index = -1,
793
+ result = Array(set.size);
794
+
795
+ set.forEach(function(value) {
796
+ result[++index] = value;
797
+ });
798
+ return result;
799
+ }
800
+
801
+ /** Used for built-in method references. */
802
+ var arrayProto = Array.prototype,
803
+ funcProto = Function.prototype,
804
+ objectProto = Object.prototype;
805
+
806
+ /** Used to detect overreaching core-js shims. */
807
+ var coreJsData = root['__core-js_shared__'];
808
+
809
+ /** Used to detect methods masquerading as native. */
810
+ var maskSrcKey = (function() {
811
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
812
+ return uid ? ('Symbol(src)_1.' + uid) : '';
813
+ }());
814
+
815
+ /** Used to resolve the decompiled source of functions. */
816
+ var funcToString = funcProto.toString;
817
+
818
+ /** Used to check objects for own properties. */
819
+ var hasOwnProperty = objectProto.hasOwnProperty;
820
+
821
+ /**
822
+ * Used to resolve the
823
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
824
+ * of values.
825
+ */
826
+ var objectToString = objectProto.toString;
827
+
828
+ /** Used to detect if a method is native. */
829
+ var reIsNative = RegExp('^' +
830
+ funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
831
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
832
+ );
833
+
834
+ /** Built-in value references. */
835
+ var splice = arrayProto.splice;
836
+
837
+ /* Built-in method references that are verified to be native. */
838
+ var Map = getNative(root, 'Map'),
839
+ Set = getNative(root, 'Set'),
840
+ nativeCreate = getNative(Object, 'create');
841
+
842
+ /**
843
+ * Creates a hash object.
844
+ *
845
+ * @private
846
+ * @constructor
847
+ * @param {Array} [entries] The key-value pairs to cache.
848
+ */
849
+ function Hash(entries) {
850
+ var index = -1,
851
+ length = entries ? entries.length : 0;
852
+
853
+ this.clear();
854
+ while (++index < length) {
855
+ var entry = entries[index];
856
+ this.set(entry[0], entry[1]);
857
+ }
858
+ }
859
+
860
+ /**
861
+ * Removes all key-value entries from the hash.
862
+ *
863
+ * @private
864
+ * @name clear
865
+ * @memberOf Hash
866
+ */
867
+ function hashClear() {
868
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
869
+ }
870
+
871
+ /**
872
+ * Removes `key` and its value from the hash.
873
+ *
874
+ * @private
875
+ * @name delete
876
+ * @memberOf Hash
877
+ * @param {Object} hash The hash to modify.
878
+ * @param {string} key The key of the value to remove.
879
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
880
+ */
881
+ function hashDelete(key) {
882
+ return this.has(key) && delete this.__data__[key];
883
+ }
884
+
885
+ /**
886
+ * Gets the hash value for `key`.
887
+ *
888
+ * @private
889
+ * @name get
890
+ * @memberOf Hash
891
+ * @param {string} key The key of the value to get.
892
+ * @returns {*} Returns the entry value.
893
+ */
894
+ function hashGet(key) {
895
+ var data = this.__data__;
896
+ if (nativeCreate) {
897
+ var result = data[key];
898
+ return result === HASH_UNDEFINED ? undefined : result;
899
+ }
900
+ return hasOwnProperty.call(data, key) ? data[key] : undefined;
901
+ }
902
+
903
+ /**
904
+ * Checks if a hash value for `key` exists.
905
+ *
906
+ * @private
907
+ * @name has
908
+ * @memberOf Hash
909
+ * @param {string} key The key of the entry to check.
910
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
911
+ */
912
+ function hashHas(key) {
913
+ var data = this.__data__;
914
+ return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
915
+ }
916
+
917
+ /**
918
+ * Sets the hash `key` to `value`.
919
+ *
920
+ * @private
921
+ * @name set
922
+ * @memberOf Hash
923
+ * @param {string} key The key of the value to set.
924
+ * @param {*} value The value to set.
925
+ * @returns {Object} Returns the hash instance.
926
+ */
927
+ function hashSet(key, value) {
928
+ var data = this.__data__;
929
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
930
+ return this;
931
+ }
932
+
933
+ // Add methods to `Hash`.
934
+ Hash.prototype.clear = hashClear;
935
+ Hash.prototype['delete'] = hashDelete;
936
+ Hash.prototype.get = hashGet;
937
+ Hash.prototype.has = hashHas;
938
+ Hash.prototype.set = hashSet;
939
+
940
+ /**
941
+ * Creates an list cache object.
942
+ *
943
+ * @private
944
+ * @constructor
945
+ * @param {Array} [entries] The key-value pairs to cache.
946
+ */
947
+ function ListCache(entries) {
948
+ var index = -1,
949
+ length = entries ? entries.length : 0;
950
+
951
+ this.clear();
952
+ while (++index < length) {
953
+ var entry = entries[index];
954
+ this.set(entry[0], entry[1]);
955
+ }
956
+ }
957
+
958
+ /**
959
+ * Removes all key-value entries from the list cache.
960
+ *
961
+ * @private
962
+ * @name clear
963
+ * @memberOf ListCache
964
+ */
965
+ function listCacheClear() {
966
+ this.__data__ = [];
967
+ }
968
+
969
+ /**
970
+ * Removes `key` and its value from the list cache.
971
+ *
972
+ * @private
973
+ * @name delete
974
+ * @memberOf ListCache
975
+ * @param {string} key The key of the value to remove.
976
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
977
+ */
978
+ function listCacheDelete(key) {
979
+ var data = this.__data__,
980
+ index = assocIndexOf(data, key);
981
+
982
+ if (index < 0) {
983
+ return false;
984
+ }
985
+ var lastIndex = data.length - 1;
986
+ if (index == lastIndex) {
987
+ data.pop();
988
+ } else {
989
+ splice.call(data, index, 1);
990
+ }
991
+ return true;
992
+ }
993
+
994
+ /**
995
+ * Gets the list cache value for `key`.
996
+ *
997
+ * @private
998
+ * @name get
999
+ * @memberOf ListCache
1000
+ * @param {string} key The key of the value to get.
1001
+ * @returns {*} Returns the entry value.
1002
+ */
1003
+ function listCacheGet(key) {
1004
+ var data = this.__data__,
1005
+ index = assocIndexOf(data, key);
1006
+
1007
+ return index < 0 ? undefined : data[index][1];
1008
+ }
1009
+
1010
+ /**
1011
+ * Checks if a list cache value for `key` exists.
1012
+ *
1013
+ * @private
1014
+ * @name has
1015
+ * @memberOf ListCache
1016
+ * @param {string} key The key of the entry to check.
1017
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1018
+ */
1019
+ function listCacheHas(key) {
1020
+ return assocIndexOf(this.__data__, key) > -1;
1021
+ }
1022
+
1023
+ /**
1024
+ * Sets the list cache `key` to `value`.
1025
+ *
1026
+ * @private
1027
+ * @name set
1028
+ * @memberOf ListCache
1029
+ * @param {string} key The key of the value to set.
1030
+ * @param {*} value The value to set.
1031
+ * @returns {Object} Returns the list cache instance.
1032
+ */
1033
+ function listCacheSet(key, value) {
1034
+ var data = this.__data__,
1035
+ index = assocIndexOf(data, key);
1036
+
1037
+ if (index < 0) {
1038
+ data.push([key, value]);
1039
+ } else {
1040
+ data[index][1] = value;
1041
+ }
1042
+ return this;
1043
+ }
1044
+
1045
+ // Add methods to `ListCache`.
1046
+ ListCache.prototype.clear = listCacheClear;
1047
+ ListCache.prototype['delete'] = listCacheDelete;
1048
+ ListCache.prototype.get = listCacheGet;
1049
+ ListCache.prototype.has = listCacheHas;
1050
+ ListCache.prototype.set = listCacheSet;
1051
+
1052
+ /**
1053
+ * Creates a map cache object to store key-value pairs.
1054
+ *
1055
+ * @private
1056
+ * @constructor
1057
+ * @param {Array} [entries] The key-value pairs to cache.
1058
+ */
1059
+ function MapCache(entries) {
1060
+ var index = -1,
1061
+ length = entries ? entries.length : 0;
1062
+
1063
+ this.clear();
1064
+ while (++index < length) {
1065
+ var entry = entries[index];
1066
+ this.set(entry[0], entry[1]);
1067
+ }
1068
+ }
1069
+
1070
+ /**
1071
+ * Removes all key-value entries from the map.
1072
+ *
1073
+ * @private
1074
+ * @name clear
1075
+ * @memberOf MapCache
1076
+ */
1077
+ function mapCacheClear() {
1078
+ this.__data__ = {
1079
+ 'hash': new Hash,
1080
+ 'map': new (Map || ListCache),
1081
+ 'string': new Hash
1082
+ };
1083
+ }
1084
+
1085
+ /**
1086
+ * Removes `key` and its value from the map.
1087
+ *
1088
+ * @private
1089
+ * @name delete
1090
+ * @memberOf MapCache
1091
+ * @param {string} key The key of the value to remove.
1092
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1093
+ */
1094
+ function mapCacheDelete(key) {
1095
+ return getMapData(this, key)['delete'](key);
1096
+ }
1097
+
1098
+ /**
1099
+ * Gets the map value for `key`.
1100
+ *
1101
+ * @private
1102
+ * @name get
1103
+ * @memberOf MapCache
1104
+ * @param {string} key The key of the value to get.
1105
+ * @returns {*} Returns the entry value.
1106
+ */
1107
+ function mapCacheGet(key) {
1108
+ return getMapData(this, key).get(key);
1109
+ }
1110
+
1111
+ /**
1112
+ * Checks if a map value for `key` exists.
1113
+ *
1114
+ * @private
1115
+ * @name has
1116
+ * @memberOf MapCache
1117
+ * @param {string} key The key of the entry to check.
1118
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1119
+ */
1120
+ function mapCacheHas(key) {
1121
+ return getMapData(this, key).has(key);
1122
+ }
1123
+
1124
+ /**
1125
+ * Sets the map `key` to `value`.
1126
+ *
1127
+ * @private
1128
+ * @name set
1129
+ * @memberOf MapCache
1130
+ * @param {string} key The key of the value to set.
1131
+ * @param {*} value The value to set.
1132
+ * @returns {Object} Returns the map cache instance.
1133
+ */
1134
+ function mapCacheSet(key, value) {
1135
+ getMapData(this, key).set(key, value);
1136
+ return this;
1137
+ }
1138
+
1139
+ // Add methods to `MapCache`.
1140
+ MapCache.prototype.clear = mapCacheClear;
1141
+ MapCache.prototype['delete'] = mapCacheDelete;
1142
+ MapCache.prototype.get = mapCacheGet;
1143
+ MapCache.prototype.has = mapCacheHas;
1144
+ MapCache.prototype.set = mapCacheSet;
1145
+
1146
+ /**
1147
+ *
1148
+ * Creates an array cache object to store unique values.
1149
+ *
1150
+ * @private
1151
+ * @constructor
1152
+ * @param {Array} [values] The values to cache.
1153
+ */
1154
+ function SetCache(values) {
1155
+ var index = -1,
1156
+ length = values ? values.length : 0;
1157
+
1158
+ this.__data__ = new MapCache;
1159
+ while (++index < length) {
1160
+ this.add(values[index]);
1161
+ }
1162
+ }
1163
+
1164
+ /**
1165
+ * Adds `value` to the array cache.
1166
+ *
1167
+ * @private
1168
+ * @name add
1169
+ * @memberOf SetCache
1170
+ * @alias push
1171
+ * @param {*} value The value to cache.
1172
+ * @returns {Object} Returns the cache instance.
1173
+ */
1174
+ function setCacheAdd(value) {
1175
+ this.__data__.set(value, HASH_UNDEFINED);
1176
+ return this;
1177
+ }
1178
+
1179
+ /**
1180
+ * Checks if `value` is in the array cache.
1181
+ *
1182
+ * @private
1183
+ * @name has
1184
+ * @memberOf SetCache
1185
+ * @param {*} value The value to search for.
1186
+ * @returns {number} Returns `true` if `value` is found, else `false`.
1187
+ */
1188
+ function setCacheHas(value) {
1189
+ return this.__data__.has(value);
1190
+ }
1191
+
1192
+ // Add methods to `SetCache`.
1193
+ SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
1194
+ SetCache.prototype.has = setCacheHas;
1195
+
1196
+ /**
1197
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
1198
+ *
1199
+ * @private
1200
+ * @param {Array} array The array to inspect.
1201
+ * @param {*} key The key to search for.
1202
+ * @returns {number} Returns the index of the matched value, else `-1`.
1203
+ */
1204
+ function assocIndexOf(array, key) {
1205
+ var length = array.length;
1206
+ while (length--) {
1207
+ if (eq(array[length][0], key)) {
1208
+ return length;
1209
+ }
1210
+ }
1211
+ return -1;
1212
+ }
1213
+
1214
+ /**
1215
+ * The base implementation of `_.isNative` without bad shim checks.
1216
+ *
1217
+ * @private
1218
+ * @param {*} value The value to check.
1219
+ * @returns {boolean} Returns `true` if `value` is a native function,
1220
+ * else `false`.
1221
+ */
1222
+ function baseIsNative(value) {
1223
+ if (!isObject(value) || isMasked(value)) {
1224
+ return false;
1225
+ }
1226
+ var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
1227
+ return pattern.test(toSource(value));
1228
+ }
1229
+
1230
+ /**
1231
+ * The base implementation of `_.uniqBy` without support for iteratee shorthands.
1232
+ *
1233
+ * @private
1234
+ * @param {Array} array The array to inspect.
1235
+ * @param {Function} [iteratee] The iteratee invoked per element.
1236
+ * @param {Function} [comparator] The comparator invoked per element.
1237
+ * @returns {Array} Returns the new duplicate free array.
1238
+ */
1239
+ function baseUniq(array, iteratee, comparator) {
1240
+ var index = -1,
1241
+ includes = arrayIncludes,
1242
+ length = array.length,
1243
+ isCommon = true,
1244
+ result = [],
1245
+ seen = result;
1246
+
1247
+ if (length >= LARGE_ARRAY_SIZE) {
1248
+ var set = createSet(array);
1249
+ if (set) {
1250
+ return setToArray(set);
1251
+ }
1252
+ isCommon = false;
1253
+ includes = cacheHas;
1254
+ seen = new SetCache;
1255
+ }
1256
+ else {
1257
+ seen = result;
1258
+ }
1259
+ outer:
1260
+ while (++index < length) {
1261
+ var value = array[index],
1262
+ computed = value;
1263
+
1264
+ value = (value !== 0) ? value : 0;
1265
+ if (isCommon && computed === computed) {
1266
+ var seenIndex = seen.length;
1267
+ while (seenIndex--) {
1268
+ if (seen[seenIndex] === computed) {
1269
+ continue outer;
1270
+ }
1271
+ }
1272
+ result.push(value);
1273
+ }
1274
+ else if (!includes(seen, computed, comparator)) {
1275
+ if (seen !== result) {
1276
+ seen.push(computed);
1277
+ }
1278
+ result.push(value);
1279
+ }
1280
+ }
1281
+ return result;
1282
+ }
1283
+
1284
+ /**
1285
+ * Creates a set object of `values`.
1286
+ *
1287
+ * @private
1288
+ * @param {Array} values The values to add to the set.
1289
+ * @returns {Object} Returns the new set.
1290
+ */
1291
+ var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
1292
+ return new Set(values);
1293
+ };
1294
+
1295
+ /**
1296
+ * Gets the data for `map`.
1297
+ *
1298
+ * @private
1299
+ * @param {Object} map The map to query.
1300
+ * @param {string} key The reference key.
1301
+ * @returns {*} Returns the map data.
1302
+ */
1303
+ function getMapData(map, key) {
1304
+ var data = map.__data__;
1305
+ return isKeyable(key)
1306
+ ? data[typeof key == 'string' ? 'string' : 'hash']
1307
+ : data.map;
1308
+ }
1309
+
1310
+ /**
1311
+ * Gets the native function at `key` of `object`.
1312
+ *
1313
+ * @private
1314
+ * @param {Object} object The object to query.
1315
+ * @param {string} key The key of the method to get.
1316
+ * @returns {*} Returns the function if it's native, else `undefined`.
1317
+ */
1318
+ function getNative(object, key) {
1319
+ var value = getValue(object, key);
1320
+ return baseIsNative(value) ? value : undefined;
1321
+ }
1322
+
1323
+ /**
1324
+ * Checks if `value` is suitable for use as unique object key.
1325
+ *
1326
+ * @private
1327
+ * @param {*} value The value to check.
1328
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1329
+ */
1330
+ function isKeyable(value) {
1331
+ var type = typeof value;
1332
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1333
+ ? (value !== '__proto__')
1334
+ : (value === null);
1335
+ }
1336
+
1337
+ /**
1338
+ * Checks if `func` has its source masked.
1339
+ *
1340
+ * @private
1341
+ * @param {Function} func The function to check.
1342
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1343
+ */
1344
+ function isMasked(func) {
1345
+ return !!maskSrcKey && (maskSrcKey in func);
1346
+ }
1347
+
1348
+ /**
1349
+ * Converts `func` to its source code.
1350
+ *
1351
+ * @private
1352
+ * @param {Function} func The function to process.
1353
+ * @returns {string} Returns the source code.
1354
+ */
1355
+ function toSource(func) {
1356
+ if (func != null) {
1357
+ try {
1358
+ return funcToString.call(func);
1359
+ } catch (e) {}
1360
+ try {
1361
+ return (func + '');
1362
+ } catch (e) {}
1363
+ }
1364
+ return '';
1365
+ }
1366
+
1367
+ /**
1368
+ * Creates a duplicate-free version of an array, using
1369
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1370
+ * for equality comparisons, in which only the first occurrence of each
1371
+ * element is kept.
1372
+ *
1373
+ * @static
1374
+ * @memberOf _
1375
+ * @since 0.1.0
1376
+ * @category Array
1377
+ * @param {Array} array The array to inspect.
1378
+ * @returns {Array} Returns the new duplicate free array.
1379
+ * @example
1380
+ *
1381
+ * _.uniq([2, 1, 2]);
1382
+ * // => [2, 1]
1383
+ */
1384
+ function uniq(array) {
1385
+ return (array && array.length)
1386
+ ? baseUniq(array)
1387
+ : [];
1388
+ }
1389
+
1390
+ /**
1391
+ * Performs a
1392
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1393
+ * comparison between two values to determine if they are equivalent.
1394
+ *
1395
+ * @static
1396
+ * @memberOf _
1397
+ * @since 4.0.0
1398
+ * @category Lang
1399
+ * @param {*} value The value to compare.
1400
+ * @param {*} other The other value to compare.
1401
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1402
+ * @example
1403
+ *
1404
+ * var object = { 'a': 1 };
1405
+ * var other = { 'a': 1 };
1406
+ *
1407
+ * _.eq(object, object);
1408
+ * // => true
1409
+ *
1410
+ * _.eq(object, other);
1411
+ * // => false
1412
+ *
1413
+ * _.eq('a', 'a');
1414
+ * // => true
1415
+ *
1416
+ * _.eq('a', Object('a'));
1417
+ * // => false
1418
+ *
1419
+ * _.eq(NaN, NaN);
1420
+ * // => true
1421
+ */
1422
+ function eq(value, other) {
1423
+ return value === other || (value !== value && other !== other);
1424
+ }
1425
+
1426
+ /**
1427
+ * Checks if `value` is classified as a `Function` object.
1428
+ *
1429
+ * @static
1430
+ * @memberOf _
1431
+ * @since 0.1.0
1432
+ * @category Lang
1433
+ * @param {*} value The value to check.
1434
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1435
+ * @example
1436
+ *
1437
+ * _.isFunction(_);
1438
+ * // => true
1439
+ *
1440
+ * _.isFunction(/abc/);
1441
+ * // => false
1442
+ */
1443
+ function isFunction(value) {
1444
+ // The use of `Object#toString` avoids issues with the `typeof` operator
1445
+ // in Safari 8-9 which returns 'object' for typed array and other constructors.
1446
+ var tag = isObject(value) ? objectToString.call(value) : '';
1447
+ return tag == funcTag || tag == genTag;
1448
+ }
1449
+
1450
+ /**
1451
+ * Checks if `value` is the
1452
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1453
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1454
+ *
1455
+ * @static
1456
+ * @memberOf _
1457
+ * @since 0.1.0
1458
+ * @category Lang
1459
+ * @param {*} value The value to check.
1460
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1461
+ * @example
1462
+ *
1463
+ * _.isObject({});
1464
+ * // => true
1465
+ *
1466
+ * _.isObject([1, 2, 3]);
1467
+ * // => true
1468
+ *
1469
+ * _.isObject(_.noop);
1470
+ * // => true
1471
+ *
1472
+ * _.isObject(null);
1473
+ * // => false
1474
+ */
1475
+ function isObject(value) {
1476
+ var type = typeof value;
1477
+ return !!value && (type == 'object' || type == 'function');
1478
+ }
1479
+
1480
+ /**
1481
+ * This method returns `undefined`.
1482
+ *
1483
+ * @static
1484
+ * @memberOf _
1485
+ * @since 2.3.0
1486
+ * @category Util
1487
+ * @example
1488
+ *
1489
+ * _.times(2, _.noop);
1490
+ * // => [undefined, undefined]
1491
+ */
1492
+ function noop() {
1493
+ // No operation performed.
1494
+ }
1495
+
1496
+ lodash_uniq = uniq;
1497
+ return lodash_uniq;
1498
+ }
1499
+
1500
+ var lodash_groupby = {exports: {}};
1501
+
1502
+ /**
1503
+ * lodash (Custom Build) <https://lodash.com/>
1504
+ * Build: `lodash modularize exports="npm" -o ./`
1505
+ * Copyright jQuery Foundation and other contributors <https://jquery.org/>
1506
+ * Released under MIT license <https://lodash.com/license>
1507
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
1508
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
1509
+ */
1510
+ lodash_groupby.exports;
1511
+
1512
+ var hasRequiredLodash_groupby;
1513
+
1514
+ function requireLodash_groupby () {
1515
+ if (hasRequiredLodash_groupby) return lodash_groupby.exports;
1516
+ hasRequiredLodash_groupby = 1;
1517
+ (function (module, exports) {
1518
+ /** Used as the size to enable large array optimizations. */
1519
+ var LARGE_ARRAY_SIZE = 200;
1520
+
1521
+ /** Used as the `TypeError` message for "Functions" methods. */
1522
+ var FUNC_ERROR_TEXT = 'Expected a function';
1523
+
1524
+ /** Used to stand-in for `undefined` hash values. */
1525
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
1526
+
1527
+ /** Used to compose bitmasks for comparison styles. */
1528
+ var UNORDERED_COMPARE_FLAG = 1,
1529
+ PARTIAL_COMPARE_FLAG = 2;
1530
+
1531
+ /** Used as references for various `Number` constants. */
1532
+ var MAX_SAFE_INTEGER = 9007199254740991;
1533
+
1534
+ /** `Object#toString` result references. */
1535
+ var argsTag = '[object Arguments]',
1536
+ arrayTag = '[object Array]',
1537
+ boolTag = '[object Boolean]',
1538
+ dateTag = '[object Date]',
1539
+ errorTag = '[object Error]',
1540
+ funcTag = '[object Function]',
1541
+ genTag = '[object GeneratorFunction]',
1542
+ mapTag = '[object Map]',
1543
+ numberTag = '[object Number]',
1544
+ objectTag = '[object Object]',
1545
+ promiseTag = '[object Promise]',
1546
+ regexpTag = '[object RegExp]',
1547
+ setTag = '[object Set]',
1548
+ stringTag = '[object String]',
1549
+ symbolTag = '[object Symbol]',
1550
+ weakMapTag = '[object WeakMap]';
1551
+
1552
+ var arrayBufferTag = '[object ArrayBuffer]',
1553
+ dataViewTag = '[object DataView]',
1554
+ float32Tag = '[object Float32Array]',
1555
+ float64Tag = '[object Float64Array]',
1556
+ int8Tag = '[object Int8Array]',
1557
+ int16Tag = '[object Int16Array]',
1558
+ int32Tag = '[object Int32Array]',
1559
+ uint8Tag = '[object Uint8Array]',
1560
+ uint8ClampedTag = '[object Uint8ClampedArray]',
1561
+ uint16Tag = '[object Uint16Array]',
1562
+ uint32Tag = '[object Uint32Array]';
1563
+
1564
+ /** Used to match property names within property paths. */
1565
+ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
1566
+ reIsPlainProp = /^\w*$/,
1567
+ reLeadingDot = /^\./,
1568
+ rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
1569
+
1570
+ /**
1571
+ * Used to match `RegExp`
1572
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
1573
+ */
1574
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
1575
+
1576
+ /** Used to match backslashes in property paths. */
1577
+ var reEscapeChar = /\\(\\)?/g;
1578
+
1579
+ /** Used to detect host constructors (Safari). */
1580
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
1581
+
1582
+ /** Used to detect unsigned integer values. */
1583
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
1584
+
1585
+ /** Used to identify `toStringTag` values of typed arrays. */
1586
+ var typedArrayTags = {};
1587
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
1588
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
1589
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
1590
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
1591
+ typedArrayTags[uint32Tag] = true;
1592
+ typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
1593
+ typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
1594
+ typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
1595
+ typedArrayTags[errorTag] = typedArrayTags[funcTag] =
1596
+ typedArrayTags[mapTag] = typedArrayTags[numberTag] =
1597
+ typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
1598
+ typedArrayTags[setTag] = typedArrayTags[stringTag] =
1599
+ typedArrayTags[weakMapTag] = false;
1600
+
1601
+ /** Detect free variable `global` from Node.js. */
1602
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
1603
+
1604
+ /** Detect free variable `self`. */
1605
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
1606
+
1607
+ /** Used as a reference to the global object. */
1608
+ var root = freeGlobal || freeSelf || Function('return this')();
1609
+
1610
+ /** Detect free variable `exports`. */
1611
+ var freeExports = exports && !exports.nodeType && exports;
1612
+
1613
+ /** Detect free variable `module`. */
1614
+ var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
1615
+
1616
+ /** Detect the popular CommonJS extension `module.exports`. */
1617
+ var moduleExports = freeModule && freeModule.exports === freeExports;
1618
+
1619
+ /** Detect free variable `process` from Node.js. */
1620
+ var freeProcess = moduleExports && freeGlobal.process;
1621
+
1622
+ /** Used to access faster Node.js helpers. */
1623
+ var nodeUtil = (function() {
1624
+ try {
1625
+ return freeProcess && freeProcess.binding('util');
1626
+ } catch (e) {}
1627
+ }());
1628
+
1629
+ /* Node.js helper references. */
1630
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
1631
+
1632
+ /**
1633
+ * A specialized version of `baseAggregator` for arrays.
1634
+ *
1635
+ * @private
1636
+ * @param {Array} [array] The array to iterate over.
1637
+ * @param {Function} setter The function to set `accumulator` values.
1638
+ * @param {Function} iteratee The iteratee to transform keys.
1639
+ * @param {Object} accumulator The initial aggregated object.
1640
+ * @returns {Function} Returns `accumulator`.
1641
+ */
1642
+ function arrayAggregator(array, setter, iteratee, accumulator) {
1643
+ var index = -1,
1644
+ length = array ? array.length : 0;
1645
+
1646
+ while (++index < length) {
1647
+ var value = array[index];
1648
+ setter(accumulator, value, iteratee(value), array);
1649
+ }
1650
+ return accumulator;
1651
+ }
1652
+
1653
+ /**
1654
+ * A specialized version of `_.some` for arrays without support for iteratee
1655
+ * shorthands.
1656
+ *
1657
+ * @private
1658
+ * @param {Array} [array] The array to iterate over.
1659
+ * @param {Function} predicate The function invoked per iteration.
1660
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
1661
+ * else `false`.
1662
+ */
1663
+ function arraySome(array, predicate) {
1664
+ var index = -1,
1665
+ length = array ? array.length : 0;
1666
+
1667
+ while (++index < length) {
1668
+ if (predicate(array[index], index, array)) {
1669
+ return true;
1670
+ }
1671
+ }
1672
+ return false;
1673
+ }
1674
+
1675
+ /**
1676
+ * The base implementation of `_.property` without support for deep paths.
1677
+ *
1678
+ * @private
1679
+ * @param {string} key The key of the property to get.
1680
+ * @returns {Function} Returns the new accessor function.
1681
+ */
1682
+ function baseProperty(key) {
1683
+ return function(object) {
1684
+ return object == null ? undefined : object[key];
1685
+ };
1686
+ }
1687
+
1688
+ /**
1689
+ * The base implementation of `_.times` without support for iteratee shorthands
1690
+ * or max array length checks.
1691
+ *
1692
+ * @private
1693
+ * @param {number} n The number of times to invoke `iteratee`.
1694
+ * @param {Function} iteratee The function invoked per iteration.
1695
+ * @returns {Array} Returns the array of results.
1696
+ */
1697
+ function baseTimes(n, iteratee) {
1698
+ var index = -1,
1699
+ result = Array(n);
1700
+
1701
+ while (++index < n) {
1702
+ result[index] = iteratee(index);
1703
+ }
1704
+ return result;
1705
+ }
1706
+
1707
+ /**
1708
+ * The base implementation of `_.unary` without support for storing metadata.
1709
+ *
1710
+ * @private
1711
+ * @param {Function} func The function to cap arguments for.
1712
+ * @returns {Function} Returns the new capped function.
1713
+ */
1714
+ function baseUnary(func) {
1715
+ return function(value) {
1716
+ return func(value);
1717
+ };
1718
+ }
1719
+
1720
+ /**
1721
+ * Gets the value at `key` of `object`.
1722
+ *
1723
+ * @private
1724
+ * @param {Object} [object] The object to query.
1725
+ * @param {string} key The key of the property to get.
1726
+ * @returns {*} Returns the property value.
1727
+ */
1728
+ function getValue(object, key) {
1729
+ return object == null ? undefined : object[key];
1730
+ }
1731
+
1732
+ /**
1733
+ * Checks if `value` is a host object in IE < 9.
1734
+ *
1735
+ * @private
1736
+ * @param {*} value The value to check.
1737
+ * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
1738
+ */
1739
+ function isHostObject(value) {
1740
+ // Many host objects are `Object` objects that can coerce to strings
1741
+ // despite having improperly defined `toString` methods.
1742
+ var result = false;
1743
+ if (value != null && typeof value.toString != 'function') {
1744
+ try {
1745
+ result = !!(value + '');
1746
+ } catch (e) {}
1747
+ }
1748
+ return result;
1749
+ }
1750
+
1751
+ /**
1752
+ * Converts `map` to its key-value pairs.
1753
+ *
1754
+ * @private
1755
+ * @param {Object} map The map to convert.
1756
+ * @returns {Array} Returns the key-value pairs.
1757
+ */
1758
+ function mapToArray(map) {
1759
+ var index = -1,
1760
+ result = Array(map.size);
1761
+
1762
+ map.forEach(function(value, key) {
1763
+ result[++index] = [key, value];
1764
+ });
1765
+ return result;
1766
+ }
1767
+
1768
+ /**
1769
+ * Creates a unary function that invokes `func` with its argument transformed.
1770
+ *
1771
+ * @private
1772
+ * @param {Function} func The function to wrap.
1773
+ * @param {Function} transform The argument transform.
1774
+ * @returns {Function} Returns the new function.
1775
+ */
1776
+ function overArg(func, transform) {
1777
+ return function(arg) {
1778
+ return func(transform(arg));
1779
+ };
1780
+ }
1781
+
1782
+ /**
1783
+ * Converts `set` to an array of its values.
1784
+ *
1785
+ * @private
1786
+ * @param {Object} set The set to convert.
1787
+ * @returns {Array} Returns the values.
1788
+ */
1789
+ function setToArray(set) {
1790
+ var index = -1,
1791
+ result = Array(set.size);
1792
+
1793
+ set.forEach(function(value) {
1794
+ result[++index] = value;
1795
+ });
1796
+ return result;
1797
+ }
1798
+
1799
+ /** Used for built-in method references. */
1800
+ var arrayProto = Array.prototype,
1801
+ funcProto = Function.prototype,
1802
+ objectProto = Object.prototype;
1803
+
1804
+ /** Used to detect overreaching core-js shims. */
1805
+ var coreJsData = root['__core-js_shared__'];
1806
+
1807
+ /** Used to detect methods masquerading as native. */
1808
+ var maskSrcKey = (function() {
1809
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1810
+ return uid ? ('Symbol(src)_1.' + uid) : '';
1811
+ }());
1812
+
1813
+ /** Used to resolve the decompiled source of functions. */
1814
+ var funcToString = funcProto.toString;
1815
+
1816
+ /** Used to check objects for own properties. */
1817
+ var hasOwnProperty = objectProto.hasOwnProperty;
1818
+
1819
+ /**
1820
+ * Used to resolve the
1821
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1822
+ * of values.
1823
+ */
1824
+ var objectToString = objectProto.toString;
1825
+
1826
+ /** Used to detect if a method is native. */
1827
+ var reIsNative = RegExp('^' +
1828
+ funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
1829
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1830
+ );
1831
+
1832
+ /** Built-in value references. */
1833
+ var Symbol = root.Symbol,
1834
+ Uint8Array = root.Uint8Array,
1835
+ propertyIsEnumerable = objectProto.propertyIsEnumerable,
1836
+ splice = arrayProto.splice;
1837
+
1838
+ /* Built-in method references for those with the same name as other `lodash` methods. */
1839
+ var nativeKeys = overArg(Object.keys, Object);
1840
+
1841
+ /* Built-in method references that are verified to be native. */
1842
+ var DataView = getNative(root, 'DataView'),
1843
+ Map = getNative(root, 'Map'),
1844
+ Promise = getNative(root, 'Promise'),
1845
+ Set = getNative(root, 'Set'),
1846
+ WeakMap = getNative(root, 'WeakMap'),
1847
+ nativeCreate = getNative(Object, 'create');
1848
+
1849
+ /** Used to detect maps, sets, and weakmaps. */
1850
+ var dataViewCtorString = toSource(DataView),
1851
+ mapCtorString = toSource(Map),
1852
+ promiseCtorString = toSource(Promise),
1853
+ setCtorString = toSource(Set),
1854
+ weakMapCtorString = toSource(WeakMap);
1855
+
1856
+ /** Used to convert symbols to primitives and strings. */
1857
+ var symbolProto = Symbol ? Symbol.prototype : undefined,
1858
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
1859
+ symbolToString = symbolProto ? symbolProto.toString : undefined;
1860
+
1861
+ /**
1862
+ * Creates a hash object.
1863
+ *
1864
+ * @private
1865
+ * @constructor
1866
+ * @param {Array} [entries] The key-value pairs to cache.
1867
+ */
1868
+ function Hash(entries) {
1869
+ var index = -1,
1870
+ length = entries ? entries.length : 0;
1871
+
1872
+ this.clear();
1873
+ while (++index < length) {
1874
+ var entry = entries[index];
1875
+ this.set(entry[0], entry[1]);
1876
+ }
1877
+ }
1878
+
1879
+ /**
1880
+ * Removes all key-value entries from the hash.
1881
+ *
1882
+ * @private
1883
+ * @name clear
1884
+ * @memberOf Hash
1885
+ */
1886
+ function hashClear() {
1887
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
1888
+ }
1889
+
1890
+ /**
1891
+ * Removes `key` and its value from the hash.
1892
+ *
1893
+ * @private
1894
+ * @name delete
1895
+ * @memberOf Hash
1896
+ * @param {Object} hash The hash to modify.
1897
+ * @param {string} key The key of the value to remove.
1898
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1899
+ */
1900
+ function hashDelete(key) {
1901
+ return this.has(key) && delete this.__data__[key];
1902
+ }
1903
+
1904
+ /**
1905
+ * Gets the hash value for `key`.
1906
+ *
1907
+ * @private
1908
+ * @name get
1909
+ * @memberOf Hash
1910
+ * @param {string} key The key of the value to get.
1911
+ * @returns {*} Returns the entry value.
1912
+ */
1913
+ function hashGet(key) {
1914
+ var data = this.__data__;
1915
+ if (nativeCreate) {
1916
+ var result = data[key];
1917
+ return result === HASH_UNDEFINED ? undefined : result;
1918
+ }
1919
+ return hasOwnProperty.call(data, key) ? data[key] : undefined;
1920
+ }
1921
+
1922
+ /**
1923
+ * Checks if a hash value for `key` exists.
1924
+ *
1925
+ * @private
1926
+ * @name has
1927
+ * @memberOf Hash
1928
+ * @param {string} key The key of the entry to check.
1929
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1930
+ */
1931
+ function hashHas(key) {
1932
+ var data = this.__data__;
1933
+ return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
1934
+ }
1935
+
1936
+ /**
1937
+ * Sets the hash `key` to `value`.
1938
+ *
1939
+ * @private
1940
+ * @name set
1941
+ * @memberOf Hash
1942
+ * @param {string} key The key of the value to set.
1943
+ * @param {*} value The value to set.
1944
+ * @returns {Object} Returns the hash instance.
1945
+ */
1946
+ function hashSet(key, value) {
1947
+ var data = this.__data__;
1948
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
1949
+ return this;
1950
+ }
1951
+
1952
+ // Add methods to `Hash`.
1953
+ Hash.prototype.clear = hashClear;
1954
+ Hash.prototype['delete'] = hashDelete;
1955
+ Hash.prototype.get = hashGet;
1956
+ Hash.prototype.has = hashHas;
1957
+ Hash.prototype.set = hashSet;
1958
+
1959
+ /**
1960
+ * Creates an list cache object.
1961
+ *
1962
+ * @private
1963
+ * @constructor
1964
+ * @param {Array} [entries] The key-value pairs to cache.
1965
+ */
1966
+ function ListCache(entries) {
1967
+ var index = -1,
1968
+ length = entries ? entries.length : 0;
1969
+
1970
+ this.clear();
1971
+ while (++index < length) {
1972
+ var entry = entries[index];
1973
+ this.set(entry[0], entry[1]);
1974
+ }
1975
+ }
1976
+
1977
+ /**
1978
+ * Removes all key-value entries from the list cache.
1979
+ *
1980
+ * @private
1981
+ * @name clear
1982
+ * @memberOf ListCache
1983
+ */
1984
+ function listCacheClear() {
1985
+ this.__data__ = [];
1986
+ }
1987
+
1988
+ /**
1989
+ * Removes `key` and its value from the list cache.
1990
+ *
1991
+ * @private
1992
+ * @name delete
1993
+ * @memberOf ListCache
1994
+ * @param {string} key The key of the value to remove.
1995
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1996
+ */
1997
+ function listCacheDelete(key) {
1998
+ var data = this.__data__,
1999
+ index = assocIndexOf(data, key);
2000
+
2001
+ if (index < 0) {
2002
+ return false;
2003
+ }
2004
+ var lastIndex = data.length - 1;
2005
+ if (index == lastIndex) {
2006
+ data.pop();
2007
+ } else {
2008
+ splice.call(data, index, 1);
2009
+ }
2010
+ return true;
2011
+ }
2012
+
2013
+ /**
2014
+ * Gets the list cache value for `key`.
2015
+ *
2016
+ * @private
2017
+ * @name get
2018
+ * @memberOf ListCache
2019
+ * @param {string} key The key of the value to get.
2020
+ * @returns {*} Returns the entry value.
2021
+ */
2022
+ function listCacheGet(key) {
2023
+ var data = this.__data__,
2024
+ index = assocIndexOf(data, key);
2025
+
2026
+ return index < 0 ? undefined : data[index][1];
2027
+ }
2028
+
2029
+ /**
2030
+ * Checks if a list cache value for `key` exists.
2031
+ *
2032
+ * @private
2033
+ * @name has
2034
+ * @memberOf ListCache
2035
+ * @param {string} key The key of the entry to check.
2036
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2037
+ */
2038
+ function listCacheHas(key) {
2039
+ return assocIndexOf(this.__data__, key) > -1;
2040
+ }
2041
+
2042
+ /**
2043
+ * Sets the list cache `key` to `value`.
2044
+ *
2045
+ * @private
2046
+ * @name set
2047
+ * @memberOf ListCache
2048
+ * @param {string} key The key of the value to set.
2049
+ * @param {*} value The value to set.
2050
+ * @returns {Object} Returns the list cache instance.
2051
+ */
2052
+ function listCacheSet(key, value) {
2053
+ var data = this.__data__,
2054
+ index = assocIndexOf(data, key);
2055
+
2056
+ if (index < 0) {
2057
+ data.push([key, value]);
2058
+ } else {
2059
+ data[index][1] = value;
2060
+ }
2061
+ return this;
2062
+ }
2063
+
2064
+ // Add methods to `ListCache`.
2065
+ ListCache.prototype.clear = listCacheClear;
2066
+ ListCache.prototype['delete'] = listCacheDelete;
2067
+ ListCache.prototype.get = listCacheGet;
2068
+ ListCache.prototype.has = listCacheHas;
2069
+ ListCache.prototype.set = listCacheSet;
2070
+
2071
+ /**
2072
+ * Creates a map cache object to store key-value pairs.
2073
+ *
2074
+ * @private
2075
+ * @constructor
2076
+ * @param {Array} [entries] The key-value pairs to cache.
2077
+ */
2078
+ function MapCache(entries) {
2079
+ var index = -1,
2080
+ length = entries ? entries.length : 0;
2081
+
2082
+ this.clear();
2083
+ while (++index < length) {
2084
+ var entry = entries[index];
2085
+ this.set(entry[0], entry[1]);
2086
+ }
2087
+ }
2088
+
2089
+ /**
2090
+ * Removes all key-value entries from the map.
2091
+ *
2092
+ * @private
2093
+ * @name clear
2094
+ * @memberOf MapCache
2095
+ */
2096
+ function mapCacheClear() {
2097
+ this.__data__ = {
2098
+ 'hash': new Hash,
2099
+ 'map': new (Map || ListCache),
2100
+ 'string': new Hash
2101
+ };
2102
+ }
2103
+
2104
+ /**
2105
+ * Removes `key` and its value from the map.
2106
+ *
2107
+ * @private
2108
+ * @name delete
2109
+ * @memberOf MapCache
2110
+ * @param {string} key The key of the value to remove.
2111
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2112
+ */
2113
+ function mapCacheDelete(key) {
2114
+ return getMapData(this, key)['delete'](key);
2115
+ }
2116
+
2117
+ /**
2118
+ * Gets the map value for `key`.
2119
+ *
2120
+ * @private
2121
+ * @name get
2122
+ * @memberOf MapCache
2123
+ * @param {string} key The key of the value to get.
2124
+ * @returns {*} Returns the entry value.
2125
+ */
2126
+ function mapCacheGet(key) {
2127
+ return getMapData(this, key).get(key);
2128
+ }
2129
+
2130
+ /**
2131
+ * Checks if a map value for `key` exists.
2132
+ *
2133
+ * @private
2134
+ * @name has
2135
+ * @memberOf MapCache
2136
+ * @param {string} key The key of the entry to check.
2137
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2138
+ */
2139
+ function mapCacheHas(key) {
2140
+ return getMapData(this, key).has(key);
2141
+ }
2142
+
2143
+ /**
2144
+ * Sets the map `key` to `value`.
2145
+ *
2146
+ * @private
2147
+ * @name set
2148
+ * @memberOf MapCache
2149
+ * @param {string} key The key of the value to set.
2150
+ * @param {*} value The value to set.
2151
+ * @returns {Object} Returns the map cache instance.
2152
+ */
2153
+ function mapCacheSet(key, value) {
2154
+ getMapData(this, key).set(key, value);
2155
+ return this;
2156
+ }
2157
+
2158
+ // Add methods to `MapCache`.
2159
+ MapCache.prototype.clear = mapCacheClear;
2160
+ MapCache.prototype['delete'] = mapCacheDelete;
2161
+ MapCache.prototype.get = mapCacheGet;
2162
+ MapCache.prototype.has = mapCacheHas;
2163
+ MapCache.prototype.set = mapCacheSet;
2164
+
2165
+ /**
2166
+ *
2167
+ * Creates an array cache object to store unique values.
2168
+ *
2169
+ * @private
2170
+ * @constructor
2171
+ * @param {Array} [values] The values to cache.
2172
+ */
2173
+ function SetCache(values) {
2174
+ var index = -1,
2175
+ length = values ? values.length : 0;
2176
+
2177
+ this.__data__ = new MapCache;
2178
+ while (++index < length) {
2179
+ this.add(values[index]);
2180
+ }
2181
+ }
2182
+
2183
+ /**
2184
+ * Adds `value` to the array cache.
2185
+ *
2186
+ * @private
2187
+ * @name add
2188
+ * @memberOf SetCache
2189
+ * @alias push
2190
+ * @param {*} value The value to cache.
2191
+ * @returns {Object} Returns the cache instance.
2192
+ */
2193
+ function setCacheAdd(value) {
2194
+ this.__data__.set(value, HASH_UNDEFINED);
2195
+ return this;
2196
+ }
2197
+
2198
+ /**
2199
+ * Checks if `value` is in the array cache.
2200
+ *
2201
+ * @private
2202
+ * @name has
2203
+ * @memberOf SetCache
2204
+ * @param {*} value The value to search for.
2205
+ * @returns {number} Returns `true` if `value` is found, else `false`.
2206
+ */
2207
+ function setCacheHas(value) {
2208
+ return this.__data__.has(value);
2209
+ }
2210
+
2211
+ // Add methods to `SetCache`.
2212
+ SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
2213
+ SetCache.prototype.has = setCacheHas;
2214
+
2215
+ /**
2216
+ * Creates a stack cache object to store key-value pairs.
2217
+ *
2218
+ * @private
2219
+ * @constructor
2220
+ * @param {Array} [entries] The key-value pairs to cache.
2221
+ */
2222
+ function Stack(entries) {
2223
+ this.__data__ = new ListCache(entries);
2224
+ }
2225
+
2226
+ /**
2227
+ * Removes all key-value entries from the stack.
2228
+ *
2229
+ * @private
2230
+ * @name clear
2231
+ * @memberOf Stack
2232
+ */
2233
+ function stackClear() {
2234
+ this.__data__ = new ListCache;
2235
+ }
2236
+
2237
+ /**
2238
+ * Removes `key` and its value from the stack.
2239
+ *
2240
+ * @private
2241
+ * @name delete
2242
+ * @memberOf Stack
2243
+ * @param {string} key The key of the value to remove.
2244
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2245
+ */
2246
+ function stackDelete(key) {
2247
+ return this.__data__['delete'](key);
2248
+ }
2249
+
2250
+ /**
2251
+ * Gets the stack value for `key`.
2252
+ *
2253
+ * @private
2254
+ * @name get
2255
+ * @memberOf Stack
2256
+ * @param {string} key The key of the value to get.
2257
+ * @returns {*} Returns the entry value.
2258
+ */
2259
+ function stackGet(key) {
2260
+ return this.__data__.get(key);
2261
+ }
2262
+
2263
+ /**
2264
+ * Checks if a stack value for `key` exists.
2265
+ *
2266
+ * @private
2267
+ * @name has
2268
+ * @memberOf Stack
2269
+ * @param {string} key The key of the entry to check.
2270
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2271
+ */
2272
+ function stackHas(key) {
2273
+ return this.__data__.has(key);
2274
+ }
2275
+
2276
+ /**
2277
+ * Sets the stack `key` to `value`.
2278
+ *
2279
+ * @private
2280
+ * @name set
2281
+ * @memberOf Stack
2282
+ * @param {string} key The key of the value to set.
2283
+ * @param {*} value The value to set.
2284
+ * @returns {Object} Returns the stack cache instance.
2285
+ */
2286
+ function stackSet(key, value) {
2287
+ var cache = this.__data__;
2288
+ if (cache instanceof ListCache) {
2289
+ var pairs = cache.__data__;
2290
+ if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2291
+ pairs.push([key, value]);
2292
+ return this;
2293
+ }
2294
+ cache = this.__data__ = new MapCache(pairs);
2295
+ }
2296
+ cache.set(key, value);
2297
+ return this;
2298
+ }
2299
+
2300
+ // Add methods to `Stack`.
2301
+ Stack.prototype.clear = stackClear;
2302
+ Stack.prototype['delete'] = stackDelete;
2303
+ Stack.prototype.get = stackGet;
2304
+ Stack.prototype.has = stackHas;
2305
+ Stack.prototype.set = stackSet;
2306
+
2307
+ /**
2308
+ * Creates an array of the enumerable property names of the array-like `value`.
2309
+ *
2310
+ * @private
2311
+ * @param {*} value The value to query.
2312
+ * @param {boolean} inherited Specify returning inherited property names.
2313
+ * @returns {Array} Returns the array of property names.
2314
+ */
2315
+ function arrayLikeKeys(value, inherited) {
2316
+ // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
2317
+ // Safari 9 makes `arguments.length` enumerable in strict mode.
2318
+ var result = (isArray(value) || isArguments(value))
2319
+ ? baseTimes(value.length, String)
2320
+ : [];
2321
+
2322
+ var length = result.length,
2323
+ skipIndexes = !!length;
2324
+
2325
+ for (var key in value) {
2326
+ if ((hasOwnProperty.call(value, key)) &&
2327
+ !(skipIndexes && (key == 'length' || isIndex(key, length)))) {
2328
+ result.push(key);
2329
+ }
2330
+ }
2331
+ return result;
2332
+ }
2333
+
2334
+ /**
2335
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
2336
+ *
2337
+ * @private
2338
+ * @param {Array} array The array to inspect.
2339
+ * @param {*} key The key to search for.
2340
+ * @returns {number} Returns the index of the matched value, else `-1`.
2341
+ */
2342
+ function assocIndexOf(array, key) {
2343
+ var length = array.length;
2344
+ while (length--) {
2345
+ if (eq(array[length][0], key)) {
2346
+ return length;
2347
+ }
2348
+ }
2349
+ return -1;
2350
+ }
2351
+
2352
+ /**
2353
+ * Aggregates elements of `collection` on `accumulator` with keys transformed
2354
+ * by `iteratee` and values set by `setter`.
2355
+ *
2356
+ * @private
2357
+ * @param {Array|Object} collection The collection to iterate over.
2358
+ * @param {Function} setter The function to set `accumulator` values.
2359
+ * @param {Function} iteratee The iteratee to transform keys.
2360
+ * @param {Object} accumulator The initial aggregated object.
2361
+ * @returns {Function} Returns `accumulator`.
2362
+ */
2363
+ function baseAggregator(collection, setter, iteratee, accumulator) {
2364
+ baseEach(collection, function(value, key, collection) {
2365
+ setter(accumulator, value, iteratee(value), collection);
2366
+ });
2367
+ return accumulator;
2368
+ }
2369
+
2370
+ /**
2371
+ * The base implementation of `_.forEach` without support for iteratee shorthands.
2372
+ *
2373
+ * @private
2374
+ * @param {Array|Object} collection The collection to iterate over.
2375
+ * @param {Function} iteratee The function invoked per iteration.
2376
+ * @returns {Array|Object} Returns `collection`.
2377
+ */
2378
+ var baseEach = createBaseEach(baseForOwn);
2379
+
2380
+ /**
2381
+ * The base implementation of `baseForOwn` which iterates over `object`
2382
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
2383
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
2384
+ *
2385
+ * @private
2386
+ * @param {Object} object The object to iterate over.
2387
+ * @param {Function} iteratee The function invoked per iteration.
2388
+ * @param {Function} keysFunc The function to get the keys of `object`.
2389
+ * @returns {Object} Returns `object`.
2390
+ */
2391
+ var baseFor = createBaseFor();
2392
+
2393
+ /**
2394
+ * The base implementation of `_.forOwn` without support for iteratee shorthands.
2395
+ *
2396
+ * @private
2397
+ * @param {Object} object The object to iterate over.
2398
+ * @param {Function} iteratee The function invoked per iteration.
2399
+ * @returns {Object} Returns `object`.
2400
+ */
2401
+ function baseForOwn(object, iteratee) {
2402
+ return object && baseFor(object, iteratee, keys);
2403
+ }
2404
+
2405
+ /**
2406
+ * The base implementation of `_.get` without support for default values.
2407
+ *
2408
+ * @private
2409
+ * @param {Object} object The object to query.
2410
+ * @param {Array|string} path The path of the property to get.
2411
+ * @returns {*} Returns the resolved value.
2412
+ */
2413
+ function baseGet(object, path) {
2414
+ path = isKey(path, object) ? [path] : castPath(path);
2415
+
2416
+ var index = 0,
2417
+ length = path.length;
2418
+
2419
+ while (object != null && index < length) {
2420
+ object = object[toKey(path[index++])];
2421
+ }
2422
+ return (index && index == length) ? object : undefined;
2423
+ }
2424
+
2425
+ /**
2426
+ * The base implementation of `getTag`.
2427
+ *
2428
+ * @private
2429
+ * @param {*} value The value to query.
2430
+ * @returns {string} Returns the `toStringTag`.
2431
+ */
2432
+ function baseGetTag(value) {
2433
+ return objectToString.call(value);
2434
+ }
2435
+
2436
+ /**
2437
+ * The base implementation of `_.hasIn` without support for deep paths.
2438
+ *
2439
+ * @private
2440
+ * @param {Object} [object] The object to query.
2441
+ * @param {Array|string} key The key to check.
2442
+ * @returns {boolean} Returns `true` if `key` exists, else `false`.
2443
+ */
2444
+ function baseHasIn(object, key) {
2445
+ return object != null && key in Object(object);
2446
+ }
2447
+
2448
+ /**
2449
+ * The base implementation of `_.isEqual` which supports partial comparisons
2450
+ * and tracks traversed objects.
2451
+ *
2452
+ * @private
2453
+ * @param {*} value The value to compare.
2454
+ * @param {*} other The other value to compare.
2455
+ * @param {Function} [customizer] The function to customize comparisons.
2456
+ * @param {boolean} [bitmask] The bitmask of comparison flags.
2457
+ * The bitmask may be composed of the following flags:
2458
+ * 1 - Unordered comparison
2459
+ * 2 - Partial comparison
2460
+ * @param {Object} [stack] Tracks traversed `value` and `other` objects.
2461
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2462
+ */
2463
+ function baseIsEqual(value, other, customizer, bitmask, stack) {
2464
+ if (value === other) {
2465
+ return true;
2466
+ }
2467
+ if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
2468
+ return value !== value && other !== other;
2469
+ }
2470
+ return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
2471
+ }
2472
+
2473
+ /**
2474
+ * A specialized version of `baseIsEqual` for arrays and objects which performs
2475
+ * deep comparisons and tracks traversed objects enabling objects with circular
2476
+ * references to be compared.
2477
+ *
2478
+ * @private
2479
+ * @param {Object} object The object to compare.
2480
+ * @param {Object} other The other object to compare.
2481
+ * @param {Function} equalFunc The function to determine equivalents of values.
2482
+ * @param {Function} [customizer] The function to customize comparisons.
2483
+ * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
2484
+ * for more details.
2485
+ * @param {Object} [stack] Tracks traversed `object` and `other` objects.
2486
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2487
+ */
2488
+ function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
2489
+ var objIsArr = isArray(object),
2490
+ othIsArr = isArray(other),
2491
+ objTag = arrayTag,
2492
+ othTag = arrayTag;
2493
+
2494
+ if (!objIsArr) {
2495
+ objTag = getTag(object);
2496
+ objTag = objTag == argsTag ? objectTag : objTag;
2497
+ }
2498
+ if (!othIsArr) {
2499
+ othTag = getTag(other);
2500
+ othTag = othTag == argsTag ? objectTag : othTag;
2501
+ }
2502
+ var objIsObj = objTag == objectTag && !isHostObject(object),
2503
+ othIsObj = othTag == objectTag && !isHostObject(other),
2504
+ isSameTag = objTag == othTag;
2505
+
2506
+ if (isSameTag && !objIsObj) {
2507
+ stack || (stack = new Stack);
2508
+ return (objIsArr || isTypedArray(object))
2509
+ ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
2510
+ : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
2511
+ }
2512
+ if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
2513
+ var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
2514
+ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
2515
+
2516
+ if (objIsWrapped || othIsWrapped) {
2517
+ var objUnwrapped = objIsWrapped ? object.value() : object,
2518
+ othUnwrapped = othIsWrapped ? other.value() : other;
2519
+
2520
+ stack || (stack = new Stack);
2521
+ return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
2522
+ }
2523
+ }
2524
+ if (!isSameTag) {
2525
+ return false;
2526
+ }
2527
+ stack || (stack = new Stack);
2528
+ return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
2529
+ }
2530
+
2531
+ /**
2532
+ * The base implementation of `_.isMatch` without support for iteratee shorthands.
2533
+ *
2534
+ * @private
2535
+ * @param {Object} object The object to inspect.
2536
+ * @param {Object} source The object of property values to match.
2537
+ * @param {Array} matchData The property names, values, and compare flags to match.
2538
+ * @param {Function} [customizer] The function to customize comparisons.
2539
+ * @returns {boolean} Returns `true` if `object` is a match, else `false`.
2540
+ */
2541
+ function baseIsMatch(object, source, matchData, customizer) {
2542
+ var index = matchData.length,
2543
+ length = index;
2544
+
2545
+ if (object == null) {
2546
+ return !length;
2547
+ }
2548
+ object = Object(object);
2549
+ while (index--) {
2550
+ var data = matchData[index];
2551
+ if ((data[2])
2552
+ ? data[1] !== object[data[0]]
2553
+ : !(data[0] in object)
2554
+ ) {
2555
+ return false;
2556
+ }
2557
+ }
2558
+ while (++index < length) {
2559
+ data = matchData[index];
2560
+ var key = data[0],
2561
+ objValue = object[key],
2562
+ srcValue = data[1];
2563
+
2564
+ if (data[2]) {
2565
+ if (objValue === undefined && !(key in object)) {
2566
+ return false;
2567
+ }
2568
+ } else {
2569
+ var stack = new Stack;
2570
+ var result;
2571
+ if (!(result === undefined
2572
+ ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
2573
+ : result
2574
+ )) {
2575
+ return false;
2576
+ }
2577
+ }
2578
+ }
2579
+ return true;
2580
+ }
2581
+
2582
+ /**
2583
+ * The base implementation of `_.isNative` without bad shim checks.
2584
+ *
2585
+ * @private
2586
+ * @param {*} value The value to check.
2587
+ * @returns {boolean} Returns `true` if `value` is a native function,
2588
+ * else `false`.
2589
+ */
2590
+ function baseIsNative(value) {
2591
+ if (!isObject(value) || isMasked(value)) {
2592
+ return false;
2593
+ }
2594
+ var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
2595
+ return pattern.test(toSource(value));
2596
+ }
2597
+
2598
+ /**
2599
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
2600
+ *
2601
+ * @private
2602
+ * @param {*} value The value to check.
2603
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2604
+ */
2605
+ function baseIsTypedArray(value) {
2606
+ return isObjectLike(value) &&
2607
+ isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
2608
+ }
2609
+
2610
+ /**
2611
+ * The base implementation of `_.iteratee`.
2612
+ *
2613
+ * @private
2614
+ * @param {*} [value=_.identity] The value to convert to an iteratee.
2615
+ * @returns {Function} Returns the iteratee.
2616
+ */
2617
+ function baseIteratee(value) {
2618
+ // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
2619
+ // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
2620
+ if (typeof value == 'function') {
2621
+ return value;
2622
+ }
2623
+ if (value == null) {
2624
+ return identity;
2625
+ }
2626
+ if (typeof value == 'object') {
2627
+ return isArray(value)
2628
+ ? baseMatchesProperty(value[0], value[1])
2629
+ : baseMatches(value);
2630
+ }
2631
+ return property(value);
2632
+ }
2633
+
2634
+ /**
2635
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
2636
+ *
2637
+ * @private
2638
+ * @param {Object} object The object to query.
2639
+ * @returns {Array} Returns the array of property names.
2640
+ */
2641
+ function baseKeys(object) {
2642
+ if (!isPrototype(object)) {
2643
+ return nativeKeys(object);
2644
+ }
2645
+ var result = [];
2646
+ for (var key in Object(object)) {
2647
+ if (hasOwnProperty.call(object, key) && key != 'constructor') {
2648
+ result.push(key);
2649
+ }
2650
+ }
2651
+ return result;
2652
+ }
2653
+
2654
+ /**
2655
+ * The base implementation of `_.matches` which doesn't clone `source`.
2656
+ *
2657
+ * @private
2658
+ * @param {Object} source The object of property values to match.
2659
+ * @returns {Function} Returns the new spec function.
2660
+ */
2661
+ function baseMatches(source) {
2662
+ var matchData = getMatchData(source);
2663
+ if (matchData.length == 1 && matchData[0][2]) {
2664
+ return matchesStrictComparable(matchData[0][0], matchData[0][1]);
2665
+ }
2666
+ return function(object) {
2667
+ return object === source || baseIsMatch(object, source, matchData);
2668
+ };
2669
+ }
2670
+
2671
+ /**
2672
+ * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
2673
+ *
2674
+ * @private
2675
+ * @param {string} path The path of the property to get.
2676
+ * @param {*} srcValue The value to match.
2677
+ * @returns {Function} Returns the new spec function.
2678
+ */
2679
+ function baseMatchesProperty(path, srcValue) {
2680
+ if (isKey(path) && isStrictComparable(srcValue)) {
2681
+ return matchesStrictComparable(toKey(path), srcValue);
2682
+ }
2683
+ return function(object) {
2684
+ var objValue = get(object, path);
2685
+ return (objValue === undefined && objValue === srcValue)
2686
+ ? hasIn(object, path)
2687
+ : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
2688
+ };
2689
+ }
2690
+
2691
+ /**
2692
+ * A specialized version of `baseProperty` which supports deep paths.
2693
+ *
2694
+ * @private
2695
+ * @param {Array|string} path The path of the property to get.
2696
+ * @returns {Function} Returns the new accessor function.
2697
+ */
2698
+ function basePropertyDeep(path) {
2699
+ return function(object) {
2700
+ return baseGet(object, path);
2701
+ };
2702
+ }
2703
+
2704
+ /**
2705
+ * The base implementation of `_.toString` which doesn't convert nullish
2706
+ * values to empty strings.
2707
+ *
2708
+ * @private
2709
+ * @param {*} value The value to process.
2710
+ * @returns {string} Returns the string.
2711
+ */
2712
+ function baseToString(value) {
2713
+ // Exit early for strings to avoid a performance hit in some environments.
2714
+ if (typeof value == 'string') {
2715
+ return value;
2716
+ }
2717
+ if (isSymbol(value)) {
2718
+ return symbolToString ? symbolToString.call(value) : '';
2719
+ }
2720
+ var result = (value + '');
2721
+ return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
2722
+ }
2723
+
2724
+ /**
2725
+ * Casts `value` to a path array if it's not one.
2726
+ *
2727
+ * @private
2728
+ * @param {*} value The value to inspect.
2729
+ * @returns {Array} Returns the cast property path array.
2730
+ */
2731
+ function castPath(value) {
2732
+ return isArray(value) ? value : stringToPath(value);
2733
+ }
2734
+
2735
+ /**
2736
+ * Creates a function like `_.groupBy`.
2737
+ *
2738
+ * @private
2739
+ * @param {Function} setter The function to set accumulator values.
2740
+ * @param {Function} [initializer] The accumulator object initializer.
2741
+ * @returns {Function} Returns the new aggregator function.
2742
+ */
2743
+ function createAggregator(setter, initializer) {
2744
+ return function(collection, iteratee) {
2745
+ var func = isArray(collection) ? arrayAggregator : baseAggregator,
2746
+ accumulator = {};
2747
+
2748
+ return func(collection, setter, baseIteratee(iteratee), accumulator);
2749
+ };
2750
+ }
2751
+
2752
+ /**
2753
+ * Creates a `baseEach` or `baseEachRight` function.
2754
+ *
2755
+ * @private
2756
+ * @param {Function} eachFunc The function to iterate over a collection.
2757
+ * @param {boolean} [fromRight] Specify iterating from right to left.
2758
+ * @returns {Function} Returns the new base function.
2759
+ */
2760
+ function createBaseEach(eachFunc, fromRight) {
2761
+ return function(collection, iteratee) {
2762
+ if (collection == null) {
2763
+ return collection;
2764
+ }
2765
+ if (!isArrayLike(collection)) {
2766
+ return eachFunc(collection, iteratee);
2767
+ }
2768
+ var length = collection.length,
2769
+ index = -1,
2770
+ iterable = Object(collection);
2771
+
2772
+ while ((++index < length)) {
2773
+ if (iteratee(iterable[index], index, iterable) === false) {
2774
+ break;
2775
+ }
2776
+ }
2777
+ return collection;
2778
+ };
2779
+ }
2780
+
2781
+ /**
2782
+ * Creates a base function for methods like `_.forIn` and `_.forOwn`.
2783
+ *
2784
+ * @private
2785
+ * @param {boolean} [fromRight] Specify iterating from right to left.
2786
+ * @returns {Function} Returns the new base function.
2787
+ */
2788
+ function createBaseFor(fromRight) {
2789
+ return function(object, iteratee, keysFunc) {
2790
+ var index = -1,
2791
+ iterable = Object(object),
2792
+ props = keysFunc(object),
2793
+ length = props.length;
2794
+
2795
+ while (length--) {
2796
+ var key = props[++index];
2797
+ if (iteratee(iterable[key], key, iterable) === false) {
2798
+ break;
2799
+ }
2800
+ }
2801
+ return object;
2802
+ };
2803
+ }
2804
+
2805
+ /**
2806
+ * A specialized version of `baseIsEqualDeep` for arrays with support for
2807
+ * partial deep comparisons.
2808
+ *
2809
+ * @private
2810
+ * @param {Array} array The array to compare.
2811
+ * @param {Array} other The other array to compare.
2812
+ * @param {Function} equalFunc The function to determine equivalents of values.
2813
+ * @param {Function} customizer The function to customize comparisons.
2814
+ * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
2815
+ * for more details.
2816
+ * @param {Object} stack Tracks traversed `array` and `other` objects.
2817
+ * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
2818
+ */
2819
+ function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
2820
+ var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
2821
+ arrLength = array.length,
2822
+ othLength = other.length;
2823
+
2824
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
2825
+ return false;
2826
+ }
2827
+ // Assume cyclic values are equal.
2828
+ var stacked = stack.get(array);
2829
+ if (stacked && stack.get(other)) {
2830
+ return stacked == other;
2831
+ }
2832
+ var index = -1,
2833
+ result = true,
2834
+ seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
2835
+
2836
+ stack.set(array, other);
2837
+ stack.set(other, array);
2838
+
2839
+ // Ignore non-index properties.
2840
+ while (++index < arrLength) {
2841
+ var arrValue = array[index],
2842
+ othValue = other[index];
2843
+
2844
+ if (customizer) {
2845
+ var compared = isPartial
2846
+ ? customizer(othValue, arrValue, index, other, array, stack)
2847
+ : customizer(arrValue, othValue, index, array, other, stack);
2848
+ }
2849
+ if (compared !== undefined) {
2850
+ if (compared) {
2851
+ continue;
2852
+ }
2853
+ result = false;
2854
+ break;
2855
+ }
2856
+ // Recursively compare arrays (susceptible to call stack limits).
2857
+ if (seen) {
2858
+ if (!arraySome(other, function(othValue, othIndex) {
2859
+ if (!seen.has(othIndex) &&
2860
+ (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
2861
+ return seen.add(othIndex);
2862
+ }
2863
+ })) {
2864
+ result = false;
2865
+ break;
2866
+ }
2867
+ } else if (!(
2868
+ arrValue === othValue ||
2869
+ equalFunc(arrValue, othValue, customizer, bitmask, stack)
2870
+ )) {
2871
+ result = false;
2872
+ break;
2873
+ }
2874
+ }
2875
+ stack['delete'](array);
2876
+ stack['delete'](other);
2877
+ return result;
2878
+ }
2879
+
2880
+ /**
2881
+ * A specialized version of `baseIsEqualDeep` for comparing objects of
2882
+ * the same `toStringTag`.
2883
+ *
2884
+ * **Note:** This function only supports comparing values with tags of
2885
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
2886
+ *
2887
+ * @private
2888
+ * @param {Object} object The object to compare.
2889
+ * @param {Object} other The other object to compare.
2890
+ * @param {string} tag The `toStringTag` of the objects to compare.
2891
+ * @param {Function} equalFunc The function to determine equivalents of values.
2892
+ * @param {Function} customizer The function to customize comparisons.
2893
+ * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
2894
+ * for more details.
2895
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
2896
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2897
+ */
2898
+ function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
2899
+ switch (tag) {
2900
+ case dataViewTag:
2901
+ if ((object.byteLength != other.byteLength) ||
2902
+ (object.byteOffset != other.byteOffset)) {
2903
+ return false;
2904
+ }
2905
+ object = object.buffer;
2906
+ other = other.buffer;
2907
+
2908
+ case arrayBufferTag:
2909
+ if ((object.byteLength != other.byteLength) ||
2910
+ !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
2911
+ return false;
2912
+ }
2913
+ return true;
2914
+
2915
+ case boolTag:
2916
+ case dateTag:
2917
+ case numberTag:
2918
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
2919
+ // Invalid dates are coerced to `NaN`.
2920
+ return eq(+object, +other);
2921
+
2922
+ case errorTag:
2923
+ return object.name == other.name && object.message == other.message;
2924
+
2925
+ case regexpTag:
2926
+ case stringTag:
2927
+ // Coerce regexes to strings and treat strings, primitives and objects,
2928
+ // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
2929
+ // for more details.
2930
+ return object == (other + '');
2931
+
2932
+ case mapTag:
2933
+ var convert = mapToArray;
2934
+
2935
+ case setTag:
2936
+ var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
2937
+ convert || (convert = setToArray);
2938
+
2939
+ if (object.size != other.size && !isPartial) {
2940
+ return false;
2941
+ }
2942
+ // Assume cyclic values are equal.
2943
+ var stacked = stack.get(object);
2944
+ if (stacked) {
2945
+ return stacked == other;
2946
+ }
2947
+ bitmask |= UNORDERED_COMPARE_FLAG;
2948
+
2949
+ // Recursively compare objects (susceptible to call stack limits).
2950
+ stack.set(object, other);
2951
+ var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
2952
+ stack['delete'](object);
2953
+ return result;
2954
+
2955
+ case symbolTag:
2956
+ if (symbolValueOf) {
2957
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
2958
+ }
2959
+ }
2960
+ return false;
2961
+ }
2962
+
2963
+ /**
2964
+ * A specialized version of `baseIsEqualDeep` for objects with support for
2965
+ * partial deep comparisons.
2966
+ *
2967
+ * @private
2968
+ * @param {Object} object The object to compare.
2969
+ * @param {Object} other The other object to compare.
2970
+ * @param {Function} equalFunc The function to determine equivalents of values.
2971
+ * @param {Function} customizer The function to customize comparisons.
2972
+ * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
2973
+ * for more details.
2974
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
2975
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2976
+ */
2977
+ function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
2978
+ var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
2979
+ objProps = keys(object),
2980
+ objLength = objProps.length,
2981
+ othProps = keys(other),
2982
+ othLength = othProps.length;
2983
+
2984
+ if (objLength != othLength && !isPartial) {
2985
+ return false;
2986
+ }
2987
+ var index = objLength;
2988
+ while (index--) {
2989
+ var key = objProps[index];
2990
+ if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
2991
+ return false;
2992
+ }
2993
+ }
2994
+ // Assume cyclic values are equal.
2995
+ var stacked = stack.get(object);
2996
+ if (stacked && stack.get(other)) {
2997
+ return stacked == other;
2998
+ }
2999
+ var result = true;
3000
+ stack.set(object, other);
3001
+ stack.set(other, object);
3002
+
3003
+ var skipCtor = isPartial;
3004
+ while (++index < objLength) {
3005
+ key = objProps[index];
3006
+ var objValue = object[key],
3007
+ othValue = other[key];
3008
+
3009
+ if (customizer) {
3010
+ var compared = isPartial
3011
+ ? customizer(othValue, objValue, key, other, object, stack)
3012
+ : customizer(objValue, othValue, key, object, other, stack);
3013
+ }
3014
+ // Recursively compare objects (susceptible to call stack limits).
3015
+ if (!(compared === undefined
3016
+ ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
3017
+ : compared
3018
+ )) {
3019
+ result = false;
3020
+ break;
3021
+ }
3022
+ skipCtor || (skipCtor = key == 'constructor');
3023
+ }
3024
+ if (result && !skipCtor) {
3025
+ var objCtor = object.constructor,
3026
+ othCtor = other.constructor;
3027
+
3028
+ // Non `Object` object instances with different constructors are not equal.
3029
+ if (objCtor != othCtor &&
3030
+ ('constructor' in object && 'constructor' in other) &&
3031
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
3032
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
3033
+ result = false;
3034
+ }
3035
+ }
3036
+ stack['delete'](object);
3037
+ stack['delete'](other);
3038
+ return result;
3039
+ }
3040
+
3041
+ /**
3042
+ * Gets the data for `map`.
3043
+ *
3044
+ * @private
3045
+ * @param {Object} map The map to query.
3046
+ * @param {string} key The reference key.
3047
+ * @returns {*} Returns the map data.
3048
+ */
3049
+ function getMapData(map, key) {
3050
+ var data = map.__data__;
3051
+ return isKeyable(key)
3052
+ ? data[typeof key == 'string' ? 'string' : 'hash']
3053
+ : data.map;
3054
+ }
3055
+
3056
+ /**
3057
+ * Gets the property names, values, and compare flags of `object`.
3058
+ *
3059
+ * @private
3060
+ * @param {Object} object The object to query.
3061
+ * @returns {Array} Returns the match data of `object`.
3062
+ */
3063
+ function getMatchData(object) {
3064
+ var result = keys(object),
3065
+ length = result.length;
3066
+
3067
+ while (length--) {
3068
+ var key = result[length],
3069
+ value = object[key];
3070
+
3071
+ result[length] = [key, value, isStrictComparable(value)];
3072
+ }
3073
+ return result;
3074
+ }
3075
+
3076
+ /**
3077
+ * Gets the native function at `key` of `object`.
3078
+ *
3079
+ * @private
3080
+ * @param {Object} object The object to query.
3081
+ * @param {string} key The key of the method to get.
3082
+ * @returns {*} Returns the function if it's native, else `undefined`.
3083
+ */
3084
+ function getNative(object, key) {
3085
+ var value = getValue(object, key);
3086
+ return baseIsNative(value) ? value : undefined;
3087
+ }
3088
+
3089
+ /**
3090
+ * Gets the `toStringTag` of `value`.
3091
+ *
3092
+ * @private
3093
+ * @param {*} value The value to query.
3094
+ * @returns {string} Returns the `toStringTag`.
3095
+ */
3096
+ var getTag = baseGetTag;
3097
+
3098
+ // Fallback for data views, maps, sets, and weak maps in IE 11,
3099
+ // for data views in Edge < 14, and promises in Node.js.
3100
+ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
3101
+ (Map && getTag(new Map) != mapTag) ||
3102
+ (Promise && getTag(Promise.resolve()) != promiseTag) ||
3103
+ (Set && getTag(new Set) != setTag) ||
3104
+ (WeakMap && getTag(new WeakMap) != weakMapTag)) {
3105
+ getTag = function(value) {
3106
+ var result = objectToString.call(value),
3107
+ Ctor = result == objectTag ? value.constructor : undefined,
3108
+ ctorString = Ctor ? toSource(Ctor) : undefined;
3109
+
3110
+ if (ctorString) {
3111
+ switch (ctorString) {
3112
+ case dataViewCtorString: return dataViewTag;
3113
+ case mapCtorString: return mapTag;
3114
+ case promiseCtorString: return promiseTag;
3115
+ case setCtorString: return setTag;
3116
+ case weakMapCtorString: return weakMapTag;
3117
+ }
3118
+ }
3119
+ return result;
3120
+ };
3121
+ }
3122
+
3123
+ /**
3124
+ * Checks if `path` exists on `object`.
3125
+ *
3126
+ * @private
3127
+ * @param {Object} object The object to query.
3128
+ * @param {Array|string} path The path to check.
3129
+ * @param {Function} hasFunc The function to check properties.
3130
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
3131
+ */
3132
+ function hasPath(object, path, hasFunc) {
3133
+ path = isKey(path, object) ? [path] : castPath(path);
3134
+
3135
+ var result,
3136
+ index = -1,
3137
+ length = path.length;
3138
+
3139
+ while (++index < length) {
3140
+ var key = toKey(path[index]);
3141
+ if (!(result = object != null && hasFunc(object, key))) {
3142
+ break;
3143
+ }
3144
+ object = object[key];
3145
+ }
3146
+ if (result) {
3147
+ return result;
3148
+ }
3149
+ var length = object ? object.length : 0;
3150
+ return !!length && isLength(length) && isIndex(key, length) &&
3151
+ (isArray(object) || isArguments(object));
3152
+ }
3153
+
3154
+ /**
3155
+ * Checks if `value` is a valid array-like index.
3156
+ *
3157
+ * @private
3158
+ * @param {*} value The value to check.
3159
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
3160
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
3161
+ */
3162
+ function isIndex(value, length) {
3163
+ length = length == null ? MAX_SAFE_INTEGER : length;
3164
+ return !!length &&
3165
+ (typeof value == 'number' || reIsUint.test(value)) &&
3166
+ (value > -1 && value % 1 == 0 && value < length);
3167
+ }
3168
+
3169
+ /**
3170
+ * Checks if `value` is a property name and not a property path.
3171
+ *
3172
+ * @private
3173
+ * @param {*} value The value to check.
3174
+ * @param {Object} [object] The object to query keys on.
3175
+ * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
3176
+ */
3177
+ function isKey(value, object) {
3178
+ if (isArray(value)) {
3179
+ return false;
3180
+ }
3181
+ var type = typeof value;
3182
+ if (type == 'number' || type == 'symbol' || type == 'boolean' ||
3183
+ value == null || isSymbol(value)) {
3184
+ return true;
3185
+ }
3186
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
3187
+ (object != null && value in Object(object));
3188
+ }
3189
+
3190
+ /**
3191
+ * Checks if `value` is suitable for use as unique object key.
3192
+ *
3193
+ * @private
3194
+ * @param {*} value The value to check.
3195
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
3196
+ */
3197
+ function isKeyable(value) {
3198
+ var type = typeof value;
3199
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
3200
+ ? (value !== '__proto__')
3201
+ : (value === null);
3202
+ }
3203
+
3204
+ /**
3205
+ * Checks if `func` has its source masked.
3206
+ *
3207
+ * @private
3208
+ * @param {Function} func The function to check.
3209
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
3210
+ */
3211
+ function isMasked(func) {
3212
+ return !!maskSrcKey && (maskSrcKey in func);
3213
+ }
3214
+
3215
+ /**
3216
+ * Checks if `value` is likely a prototype object.
3217
+ *
3218
+ * @private
3219
+ * @param {*} value The value to check.
3220
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
3221
+ */
3222
+ function isPrototype(value) {
3223
+ var Ctor = value && value.constructor,
3224
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
3225
+
3226
+ return value === proto;
3227
+ }
3228
+
3229
+ /**
3230
+ * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
3231
+ *
3232
+ * @private
3233
+ * @param {*} value The value to check.
3234
+ * @returns {boolean} Returns `true` if `value` if suitable for strict
3235
+ * equality comparisons, else `false`.
3236
+ */
3237
+ function isStrictComparable(value) {
3238
+ return value === value && !isObject(value);
3239
+ }
3240
+
3241
+ /**
3242
+ * A specialized version of `matchesProperty` for source values suitable
3243
+ * for strict equality comparisons, i.e. `===`.
3244
+ *
3245
+ * @private
3246
+ * @param {string} key The key of the property to get.
3247
+ * @param {*} srcValue The value to match.
3248
+ * @returns {Function} Returns the new spec function.
3249
+ */
3250
+ function matchesStrictComparable(key, srcValue) {
3251
+ return function(object) {
3252
+ if (object == null) {
3253
+ return false;
3254
+ }
3255
+ return object[key] === srcValue &&
3256
+ (srcValue !== undefined || (key in Object(object)));
3257
+ };
3258
+ }
3259
+
3260
+ /**
3261
+ * Converts `string` to a property path array.
3262
+ *
3263
+ * @private
3264
+ * @param {string} string The string to convert.
3265
+ * @returns {Array} Returns the property path array.
3266
+ */
3267
+ var stringToPath = memoize(function(string) {
3268
+ string = toString(string);
3269
+
3270
+ var result = [];
3271
+ if (reLeadingDot.test(string)) {
3272
+ result.push('');
3273
+ }
3274
+ string.replace(rePropName, function(match, number, quote, string) {
3275
+ result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
3276
+ });
3277
+ return result;
3278
+ });
3279
+
3280
+ /**
3281
+ * Converts `value` to a string key if it's not a string or symbol.
3282
+ *
3283
+ * @private
3284
+ * @param {*} value The value to inspect.
3285
+ * @returns {string|symbol} Returns the key.
3286
+ */
3287
+ function toKey(value) {
3288
+ if (typeof value == 'string' || isSymbol(value)) {
3289
+ return value;
3290
+ }
3291
+ var result = (value + '');
3292
+ return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
3293
+ }
3294
+
3295
+ /**
3296
+ * Converts `func` to its source code.
3297
+ *
3298
+ * @private
3299
+ * @param {Function} func The function to process.
3300
+ * @returns {string} Returns the source code.
3301
+ */
3302
+ function toSource(func) {
3303
+ if (func != null) {
3304
+ try {
3305
+ return funcToString.call(func);
3306
+ } catch (e) {}
3307
+ try {
3308
+ return (func + '');
3309
+ } catch (e) {}
3310
+ }
3311
+ return '';
3312
+ }
3313
+
3314
+ /**
3315
+ * Creates an object composed of keys generated from the results of running
3316
+ * each element of `collection` thru `iteratee`. The order of grouped values
3317
+ * is determined by the order they occur in `collection`. The corresponding
3318
+ * value of each key is an array of elements responsible for generating the
3319
+ * key. The iteratee is invoked with one argument: (value).
3320
+ *
3321
+ * @static
3322
+ * @memberOf _
3323
+ * @since 0.1.0
3324
+ * @category Collection
3325
+ * @param {Array|Object} collection The collection to iterate over.
3326
+ * @param {Function} [iteratee=_.identity]
3327
+ * The iteratee to transform keys.
3328
+ * @returns {Object} Returns the composed aggregate object.
3329
+ * @example
3330
+ *
3331
+ * _.groupBy([6.1, 4.2, 6.3], Math.floor);
3332
+ * // => { '4': [4.2], '6': [6.1, 6.3] }
3333
+ *
3334
+ * // The `_.property` iteratee shorthand.
3335
+ * _.groupBy(['one', 'two', 'three'], 'length');
3336
+ * // => { '3': ['one', 'two'], '5': ['three'] }
3337
+ */
3338
+ var groupBy = createAggregator(function(result, value, key) {
3339
+ if (hasOwnProperty.call(result, key)) {
3340
+ result[key].push(value);
3341
+ } else {
3342
+ result[key] = [value];
3343
+ }
3344
+ });
3345
+
3346
+ /**
3347
+ * Creates a function that memoizes the result of `func`. If `resolver` is
3348
+ * provided, it determines the cache key for storing the result based on the
3349
+ * arguments provided to the memoized function. By default, the first argument
3350
+ * provided to the memoized function is used as the map cache key. The `func`
3351
+ * is invoked with the `this` binding of the memoized function.
3352
+ *
3353
+ * **Note:** The cache is exposed as the `cache` property on the memoized
3354
+ * function. Its creation may be customized by replacing the `_.memoize.Cache`
3355
+ * constructor with one whose instances implement the
3356
+ * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
3357
+ * method interface of `delete`, `get`, `has`, and `set`.
3358
+ *
3359
+ * @static
3360
+ * @memberOf _
3361
+ * @since 0.1.0
3362
+ * @category Function
3363
+ * @param {Function} func The function to have its output memoized.
3364
+ * @param {Function} [resolver] The function to resolve the cache key.
3365
+ * @returns {Function} Returns the new memoized function.
3366
+ * @example
3367
+ *
3368
+ * var object = { 'a': 1, 'b': 2 };
3369
+ * var other = { 'c': 3, 'd': 4 };
3370
+ *
3371
+ * var values = _.memoize(_.values);
3372
+ * values(object);
3373
+ * // => [1, 2]
3374
+ *
3375
+ * values(other);
3376
+ * // => [3, 4]
3377
+ *
3378
+ * object.a = 2;
3379
+ * values(object);
3380
+ * // => [1, 2]
3381
+ *
3382
+ * // Modify the result cache.
3383
+ * values.cache.set(object, ['a', 'b']);
3384
+ * values(object);
3385
+ * // => ['a', 'b']
3386
+ *
3387
+ * // Replace `_.memoize.Cache`.
3388
+ * _.memoize.Cache = WeakMap;
3389
+ */
3390
+ function memoize(func, resolver) {
3391
+ if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
3392
+ throw new TypeError(FUNC_ERROR_TEXT);
3393
+ }
3394
+ var memoized = function() {
3395
+ var args = arguments,
3396
+ key = resolver ? resolver.apply(this, args) : args[0],
3397
+ cache = memoized.cache;
3398
+
3399
+ if (cache.has(key)) {
3400
+ return cache.get(key);
3401
+ }
3402
+ var result = func.apply(this, args);
3403
+ memoized.cache = cache.set(key, result);
3404
+ return result;
3405
+ };
3406
+ memoized.cache = new (memoize.Cache || MapCache);
3407
+ return memoized;
3408
+ }
3409
+
3410
+ // Assign cache to `_.memoize`.
3411
+ memoize.Cache = MapCache;
3412
+
3413
+ /**
3414
+ * Performs a
3415
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
3416
+ * comparison between two values to determine if they are equivalent.
3417
+ *
3418
+ * @static
3419
+ * @memberOf _
3420
+ * @since 4.0.0
3421
+ * @category Lang
3422
+ * @param {*} value The value to compare.
3423
+ * @param {*} other The other value to compare.
3424
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3425
+ * @example
3426
+ *
3427
+ * var object = { 'a': 1 };
3428
+ * var other = { 'a': 1 };
3429
+ *
3430
+ * _.eq(object, object);
3431
+ * // => true
3432
+ *
3433
+ * _.eq(object, other);
3434
+ * // => false
3435
+ *
3436
+ * _.eq('a', 'a');
3437
+ * // => true
3438
+ *
3439
+ * _.eq('a', Object('a'));
3440
+ * // => false
3441
+ *
3442
+ * _.eq(NaN, NaN);
3443
+ * // => true
3444
+ */
3445
+ function eq(value, other) {
3446
+ return value === other || (value !== value && other !== other);
3447
+ }
3448
+
3449
+ /**
3450
+ * Checks if `value` is likely an `arguments` object.
3451
+ *
3452
+ * @static
3453
+ * @memberOf _
3454
+ * @since 0.1.0
3455
+ * @category Lang
3456
+ * @param {*} value The value to check.
3457
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3458
+ * else `false`.
3459
+ * @example
3460
+ *
3461
+ * _.isArguments(function() { return arguments; }());
3462
+ * // => true
3463
+ *
3464
+ * _.isArguments([1, 2, 3]);
3465
+ * // => false
3466
+ */
3467
+ function isArguments(value) {
3468
+ // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
3469
+ return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
3470
+ (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
3471
+ }
3472
+
3473
+ /**
3474
+ * Checks if `value` is classified as an `Array` object.
3475
+ *
3476
+ * @static
3477
+ * @memberOf _
3478
+ * @since 0.1.0
3479
+ * @category Lang
3480
+ * @param {*} value The value to check.
3481
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
3482
+ * @example
3483
+ *
3484
+ * _.isArray([1, 2, 3]);
3485
+ * // => true
3486
+ *
3487
+ * _.isArray(document.body.children);
3488
+ * // => false
3489
+ *
3490
+ * _.isArray('abc');
3491
+ * // => false
3492
+ *
3493
+ * _.isArray(_.noop);
3494
+ * // => false
3495
+ */
3496
+ var isArray = Array.isArray;
3497
+
3498
+ /**
3499
+ * Checks if `value` is array-like. A value is considered array-like if it's
3500
+ * not a function and has a `value.length` that's an integer greater than or
3501
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
3502
+ *
3503
+ * @static
3504
+ * @memberOf _
3505
+ * @since 4.0.0
3506
+ * @category Lang
3507
+ * @param {*} value The value to check.
3508
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
3509
+ * @example
3510
+ *
3511
+ * _.isArrayLike([1, 2, 3]);
3512
+ * // => true
3513
+ *
3514
+ * _.isArrayLike(document.body.children);
3515
+ * // => true
3516
+ *
3517
+ * _.isArrayLike('abc');
3518
+ * // => true
3519
+ *
3520
+ * _.isArrayLike(_.noop);
3521
+ * // => false
3522
+ */
3523
+ function isArrayLike(value) {
3524
+ return value != null && isLength(value.length) && !isFunction(value);
3525
+ }
3526
+
3527
+ /**
3528
+ * This method is like `_.isArrayLike` except that it also checks if `value`
3529
+ * is an object.
3530
+ *
3531
+ * @static
3532
+ * @memberOf _
3533
+ * @since 4.0.0
3534
+ * @category Lang
3535
+ * @param {*} value The value to check.
3536
+ * @returns {boolean} Returns `true` if `value` is an array-like object,
3537
+ * else `false`.
3538
+ * @example
3539
+ *
3540
+ * _.isArrayLikeObject([1, 2, 3]);
3541
+ * // => true
3542
+ *
3543
+ * _.isArrayLikeObject(document.body.children);
3544
+ * // => true
3545
+ *
3546
+ * _.isArrayLikeObject('abc');
3547
+ * // => false
3548
+ *
3549
+ * _.isArrayLikeObject(_.noop);
3550
+ * // => false
3551
+ */
3552
+ function isArrayLikeObject(value) {
3553
+ return isObjectLike(value) && isArrayLike(value);
3554
+ }
3555
+
3556
+ /**
3557
+ * Checks if `value` is classified as a `Function` object.
3558
+ *
3559
+ * @static
3560
+ * @memberOf _
3561
+ * @since 0.1.0
3562
+ * @category Lang
3563
+ * @param {*} value The value to check.
3564
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
3565
+ * @example
3566
+ *
3567
+ * _.isFunction(_);
3568
+ * // => true
3569
+ *
3570
+ * _.isFunction(/abc/);
3571
+ * // => false
3572
+ */
3573
+ function isFunction(value) {
3574
+ // The use of `Object#toString` avoids issues with the `typeof` operator
3575
+ // in Safari 8-9 which returns 'object' for typed array and other constructors.
3576
+ var tag = isObject(value) ? objectToString.call(value) : '';
3577
+ return tag == funcTag || tag == genTag;
3578
+ }
3579
+
3580
+ /**
3581
+ * Checks if `value` is a valid array-like length.
3582
+ *
3583
+ * **Note:** This method is loosely based on
3584
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
3585
+ *
3586
+ * @static
3587
+ * @memberOf _
3588
+ * @since 4.0.0
3589
+ * @category Lang
3590
+ * @param {*} value The value to check.
3591
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
3592
+ * @example
3593
+ *
3594
+ * _.isLength(3);
3595
+ * // => true
3596
+ *
3597
+ * _.isLength(Number.MIN_VALUE);
3598
+ * // => false
3599
+ *
3600
+ * _.isLength(Infinity);
3601
+ * // => false
3602
+ *
3603
+ * _.isLength('3');
3604
+ * // => false
3605
+ */
3606
+ function isLength(value) {
3607
+ return typeof value == 'number' &&
3608
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
3609
+ }
3610
+
3611
+ /**
3612
+ * Checks if `value` is the
3613
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
3614
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
3615
+ *
3616
+ * @static
3617
+ * @memberOf _
3618
+ * @since 0.1.0
3619
+ * @category Lang
3620
+ * @param {*} value The value to check.
3621
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
3622
+ * @example
3623
+ *
3624
+ * _.isObject({});
3625
+ * // => true
3626
+ *
3627
+ * _.isObject([1, 2, 3]);
3628
+ * // => true
3629
+ *
3630
+ * _.isObject(_.noop);
3631
+ * // => true
3632
+ *
3633
+ * _.isObject(null);
3634
+ * // => false
3635
+ */
3636
+ function isObject(value) {
3637
+ var type = typeof value;
3638
+ return !!value && (type == 'object' || type == 'function');
3639
+ }
3640
+
3641
+ /**
3642
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
3643
+ * and has a `typeof` result of "object".
3644
+ *
3645
+ * @static
3646
+ * @memberOf _
3647
+ * @since 4.0.0
3648
+ * @category Lang
3649
+ * @param {*} value The value to check.
3650
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
3651
+ * @example
3652
+ *
3653
+ * _.isObjectLike({});
3654
+ * // => true
3655
+ *
3656
+ * _.isObjectLike([1, 2, 3]);
3657
+ * // => true
3658
+ *
3659
+ * _.isObjectLike(_.noop);
3660
+ * // => false
3661
+ *
3662
+ * _.isObjectLike(null);
3663
+ * // => false
3664
+ */
3665
+ function isObjectLike(value) {
3666
+ return !!value && typeof value == 'object';
3667
+ }
3668
+
3669
+ /**
3670
+ * Checks if `value` is classified as a `Symbol` primitive or object.
3671
+ *
3672
+ * @static
3673
+ * @memberOf _
3674
+ * @since 4.0.0
3675
+ * @category Lang
3676
+ * @param {*} value The value to check.
3677
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
3678
+ * @example
3679
+ *
3680
+ * _.isSymbol(Symbol.iterator);
3681
+ * // => true
3682
+ *
3683
+ * _.isSymbol('abc');
3684
+ * // => false
3685
+ */
3686
+ function isSymbol(value) {
3687
+ return typeof value == 'symbol' ||
3688
+ (isObjectLike(value) && objectToString.call(value) == symbolTag);
3689
+ }
3690
+
3691
+ /**
3692
+ * Checks if `value` is classified as a typed array.
3693
+ *
3694
+ * @static
3695
+ * @memberOf _
3696
+ * @since 3.0.0
3697
+ * @category Lang
3698
+ * @param {*} value The value to check.
3699
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3700
+ * @example
3701
+ *
3702
+ * _.isTypedArray(new Uint8Array);
3703
+ * // => true
3704
+ *
3705
+ * _.isTypedArray([]);
3706
+ * // => false
3707
+ */
3708
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
3709
+
3710
+ /**
3711
+ * Converts `value` to a string. An empty string is returned for `null`
3712
+ * and `undefined` values. The sign of `-0` is preserved.
3713
+ *
3714
+ * @static
3715
+ * @memberOf _
3716
+ * @since 4.0.0
3717
+ * @category Lang
3718
+ * @param {*} value The value to process.
3719
+ * @returns {string} Returns the string.
3720
+ * @example
3721
+ *
3722
+ * _.toString(null);
3723
+ * // => ''
3724
+ *
3725
+ * _.toString(-0);
3726
+ * // => '-0'
3727
+ *
3728
+ * _.toString([1, 2, 3]);
3729
+ * // => '1,2,3'
3730
+ */
3731
+ function toString(value) {
3732
+ return value == null ? '' : baseToString(value);
3733
+ }
3734
+
3735
+ /**
3736
+ * Gets the value at `path` of `object`. If the resolved value is
3737
+ * `undefined`, the `defaultValue` is returned in its place.
3738
+ *
3739
+ * @static
3740
+ * @memberOf _
3741
+ * @since 3.7.0
3742
+ * @category Object
3743
+ * @param {Object} object The object to query.
3744
+ * @param {Array|string} path The path of the property to get.
3745
+ * @param {*} [defaultValue] The value returned for `undefined` resolved values.
3746
+ * @returns {*} Returns the resolved value.
3747
+ * @example
3748
+ *
3749
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
3750
+ *
3751
+ * _.get(object, 'a[0].b.c');
3752
+ * // => 3
3753
+ *
3754
+ * _.get(object, ['a', '0', 'b', 'c']);
3755
+ * // => 3
3756
+ *
3757
+ * _.get(object, 'a.b.c', 'default');
3758
+ * // => 'default'
3759
+ */
3760
+ function get(object, path, defaultValue) {
3761
+ var result = object == null ? undefined : baseGet(object, path);
3762
+ return result === undefined ? defaultValue : result;
3763
+ }
3764
+
3765
+ /**
3766
+ * Checks if `path` is a direct or inherited property of `object`.
3767
+ *
3768
+ * @static
3769
+ * @memberOf _
3770
+ * @since 4.0.0
3771
+ * @category Object
3772
+ * @param {Object} object The object to query.
3773
+ * @param {Array|string} path The path to check.
3774
+ * @returns {boolean} Returns `true` if `path` exists, else `false`.
3775
+ * @example
3776
+ *
3777
+ * var object = _.create({ 'a': _.create({ 'b': 2 }) });
3778
+ *
3779
+ * _.hasIn(object, 'a');
3780
+ * // => true
3781
+ *
3782
+ * _.hasIn(object, 'a.b');
3783
+ * // => true
3784
+ *
3785
+ * _.hasIn(object, ['a', 'b']);
3786
+ * // => true
3787
+ *
3788
+ * _.hasIn(object, 'b');
3789
+ * // => false
3790
+ */
3791
+ function hasIn(object, path) {
3792
+ return object != null && hasPath(object, path, baseHasIn);
3793
+ }
3794
+
3795
+ /**
3796
+ * Creates an array of the own enumerable property names of `object`.
3797
+ *
3798
+ * **Note:** Non-object values are coerced to objects. See the
3799
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
3800
+ * for more details.
3801
+ *
3802
+ * @static
3803
+ * @since 0.1.0
3804
+ * @memberOf _
3805
+ * @category Object
3806
+ * @param {Object} object The object to query.
3807
+ * @returns {Array} Returns the array of property names.
3808
+ * @example
3809
+ *
3810
+ * function Foo() {
3811
+ * this.a = 1;
3812
+ * this.b = 2;
3813
+ * }
3814
+ *
3815
+ * Foo.prototype.c = 3;
3816
+ *
3817
+ * _.keys(new Foo);
3818
+ * // => ['a', 'b'] (iteration order is not guaranteed)
3819
+ *
3820
+ * _.keys('hi');
3821
+ * // => ['0', '1']
3822
+ */
3823
+ function keys(object) {
3824
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
3825
+ }
3826
+
3827
+ /**
3828
+ * This method returns the first argument it receives.
3829
+ *
3830
+ * @static
3831
+ * @since 0.1.0
3832
+ * @memberOf _
3833
+ * @category Util
3834
+ * @param {*} value Any value.
3835
+ * @returns {*} Returns `value`.
3836
+ * @example
3837
+ *
3838
+ * var object = { 'a': 1 };
3839
+ *
3840
+ * console.log(_.identity(object) === object);
3841
+ * // => true
3842
+ */
3843
+ function identity(value) {
3844
+ return value;
3845
+ }
3846
+
3847
+ /**
3848
+ * Creates a function that returns the value at `path` of a given object.
3849
+ *
3850
+ * @static
3851
+ * @memberOf _
3852
+ * @since 2.4.0
3853
+ * @category Util
3854
+ * @param {Array|string} path The path of the property to get.
3855
+ * @returns {Function} Returns the new accessor function.
3856
+ * @example
3857
+ *
3858
+ * var objects = [
3859
+ * { 'a': { 'b': 2 } },
3860
+ * { 'a': { 'b': 1 } }
3861
+ * ];
3862
+ *
3863
+ * _.map(objects, _.property('a.b'));
3864
+ * // => [2, 1]
3865
+ *
3866
+ * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
3867
+ * // => [1, 2]
3868
+ */
3869
+ function property(path) {
3870
+ return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
3871
+ }
3872
+
3873
+ module.exports = groupBy;
3874
+ } (lodash_groupby, lodash_groupby.exports));
3875
+ return lodash_groupby.exports;
3876
+ }
3877
+
3878
+ var hasRequiredHeaderTransformer;
3879
+
3880
+ function requireHeaderTransformer () {
3881
+ if (hasRequiredHeaderTransformer) return HeaderTransformer;
3882
+ hasRequiredHeaderTransformer = 1;
3883
+ var __importDefault = (HeaderTransformer && HeaderTransformer.__importDefault) || function (mod) {
3884
+ return (mod && mod.__esModule) ? mod : { "default": mod };
3885
+ };
3886
+ Object.defineProperty(HeaderTransformer, "__esModule", { value: true });
3887
+ HeaderTransformer.HeaderTransformer = void 0;
3888
+ const lodash_isundefined_1 = __importDefault(requireLodash_isundefined());
3889
+ const lodash_isfunction_1 = __importDefault(requireLodash_isfunction());
3890
+ const lodash_uniq_1 = __importDefault(requireLodash_uniq());
3891
+ const lodash_groupby_1 = __importDefault(requireLodash_groupby());
3892
+ let HeaderTransformer$1 = class HeaderTransformer {
3893
+ parserOptions;
3894
+ headers = null;
3895
+ receivedHeaders = false;
3896
+ shouldUseFirstRow = false;
3897
+ processedFirstRow = false;
3898
+ headersLength = 0;
3899
+ headersTransform;
3900
+ constructor(parserOptions) {
3901
+ this.parserOptions = parserOptions;
3902
+ if (parserOptions.headers === true) {
3903
+ this.shouldUseFirstRow = true;
3904
+ }
3905
+ else if (Array.isArray(parserOptions.headers)) {
3906
+ this.setHeaders(parserOptions.headers);
3907
+ }
3908
+ else if ((0, lodash_isfunction_1.default)(parserOptions.headers)) {
3909
+ this.headersTransform = parserOptions.headers;
3910
+ }
3911
+ }
3912
+ transform(row, cb) {
3913
+ if (!this.shouldMapRow(row)) {
3914
+ return cb(null, { row: null, isValid: true });
3915
+ }
3916
+ return cb(null, this.processRow(row));
3917
+ }
3918
+ shouldMapRow(row) {
3919
+ const { parserOptions } = this;
3920
+ if (!this.headersTransform && parserOptions.renameHeaders && !this.processedFirstRow) {
3921
+ if (!this.receivedHeaders) {
3922
+ throw new Error('Error renaming headers: new headers must be provided in an array');
3923
+ }
3924
+ this.processedFirstRow = true;
3925
+ return false;
3926
+ }
3927
+ if (!this.receivedHeaders && Array.isArray(row)) {
3928
+ if (this.headersTransform) {
3929
+ this.setHeaders(this.headersTransform(row));
3930
+ }
3931
+ else if (this.shouldUseFirstRow) {
3932
+ this.setHeaders(row);
3933
+ }
3934
+ else {
3935
+ // dont do anything with the headers if we didnt receive a transform or shouldnt use the first row.
3936
+ return true;
3937
+ }
3938
+ return false;
3939
+ }
3940
+ return true;
3941
+ }
3942
+ processRow(row) {
3943
+ if (!this.headers) {
3944
+ return { row: row, isValid: true };
3945
+ }
3946
+ const { parserOptions } = this;
3947
+ if (!parserOptions.discardUnmappedColumns && row.length > this.headersLength) {
3948
+ if (!parserOptions.strictColumnHandling) {
3949
+ throw new Error(`Unexpected Error: column header mismatch expected: ${this.headersLength} columns got: ${row.length}`);
3950
+ }
3951
+ return {
3952
+ row: row,
3953
+ isValid: false,
3954
+ reason: `Column header mismatch expected: ${this.headersLength} columns got: ${row.length}`,
3955
+ };
3956
+ }
3957
+ if (parserOptions.strictColumnHandling && row.length < this.headersLength) {
3958
+ return {
3959
+ row: row,
3960
+ isValid: false,
3961
+ reason: `Column header mismatch expected: ${this.headersLength} columns got: ${row.length}`,
3962
+ };
3963
+ }
3964
+ return { row: this.mapHeaders(row), isValid: true };
3965
+ }
3966
+ mapHeaders(row) {
3967
+ const rowMap = {};
3968
+ const { headers, headersLength } = this;
3969
+ for (let i = 0; i < headersLength; i += 1) {
3970
+ const header = headers[i];
3971
+ if (!(0, lodash_isundefined_1.default)(header)) {
3972
+ const val = row[i];
3973
+ // eslint-disable-next-line no-param-reassign
3974
+ if ((0, lodash_isundefined_1.default)(val)) {
3975
+ rowMap[header] = '';
3976
+ }
3977
+ else {
3978
+ rowMap[header] = val;
3979
+ }
3980
+ }
3981
+ }
3982
+ return rowMap;
3983
+ }
3984
+ setHeaders(headers) {
3985
+ const filteredHeaders = headers.filter((h) => {
3986
+ return !!h;
3987
+ });
3988
+ if ((0, lodash_uniq_1.default)(filteredHeaders).length !== filteredHeaders.length) {
3989
+ const grouped = (0, lodash_groupby_1.default)(filteredHeaders);
3990
+ const duplicates = Object.keys(grouped).filter((dup) => {
3991
+ return grouped[dup].length > 1;
3992
+ });
3993
+ throw new Error(`Duplicate headers found ${JSON.stringify(duplicates)}`);
3994
+ }
3995
+ this.headers = headers;
3996
+ this.receivedHeaders = true;
3997
+ this.headersLength = this.headers?.length || 0;
3998
+ }
3999
+ };
4000
+ HeaderTransformer.HeaderTransformer = HeaderTransformer$1;
4001
+
4002
+ return HeaderTransformer;
4003
+ }
4004
+
4005
+ var hasRequiredTransforms;
4006
+
4007
+ function requireTransforms () {
4008
+ if (hasRequiredTransforms) return transforms;
4009
+ hasRequiredTransforms = 1;
4010
+ (function (exports) {
4011
+ Object.defineProperty(exports, "__esModule", { value: true });
4012
+ exports.HeaderTransformer = exports.RowTransformerValidator = void 0;
4013
+ var RowTransformerValidator_1 = requireRowTransformerValidator();
4014
+ Object.defineProperty(exports, "RowTransformerValidator", { enumerable: true, get: function () { return RowTransformerValidator_1.RowTransformerValidator; } });
4015
+ var HeaderTransformer_1 = requireHeaderTransformer();
4016
+ Object.defineProperty(exports, "HeaderTransformer", { enumerable: true, get: function () { return HeaderTransformer_1.HeaderTransformer; } });
4017
+
4018
+ } (transforms));
4019
+ return transforms;
4020
+ }
4021
+
4022
+ var parser = {};
4023
+
4024
+ var Parser = {};
4025
+
4026
+ var Scanner = {};
4027
+
4028
+ var Token = {};
4029
+
4030
+ var hasRequiredToken;
4031
+
4032
+ function requireToken () {
4033
+ if (hasRequiredToken) return Token;
4034
+ hasRequiredToken = 1;
4035
+ Object.defineProperty(Token, "__esModule", { value: true });
4036
+ Token.Token = void 0;
4037
+ let Token$1 = class Token {
4038
+ static isTokenRowDelimiter(token) {
4039
+ const content = token.token;
4040
+ return content === '\r' || content === '\n' || content === '\r\n';
4041
+ }
4042
+ static isTokenCarriageReturn(token, parserOptions) {
4043
+ return token.token === parserOptions.carriageReturn;
4044
+ }
4045
+ static isTokenComment(token, parserOptions) {
4046
+ return parserOptions.supportsComments && !!token && token.token === parserOptions.comment;
4047
+ }
4048
+ static isTokenEscapeCharacter(token, parserOptions) {
4049
+ return token.token === parserOptions.escapeChar;
4050
+ }
4051
+ static isTokenQuote(token, parserOptions) {
4052
+ return token.token === parserOptions.quote;
4053
+ }
4054
+ static isTokenDelimiter(token, parserOptions) {
4055
+ return token.token === parserOptions.delimiter;
4056
+ }
4057
+ token;
4058
+ startCursor;
4059
+ endCursor;
4060
+ constructor(tokenArgs) {
4061
+ this.token = tokenArgs.token;
4062
+ this.startCursor = tokenArgs.startCursor;
4063
+ this.endCursor = tokenArgs.endCursor;
4064
+ }
4065
+ };
4066
+ Token.Token = Token$1;
4067
+
4068
+ return Token;
4069
+ }
4070
+
4071
+ var hasRequiredScanner;
4072
+
4073
+ function requireScanner () {
4074
+ if (hasRequiredScanner) return Scanner;
4075
+ hasRequiredScanner = 1;
4076
+ Object.defineProperty(Scanner, "__esModule", { value: true });
4077
+ Scanner.Scanner = void 0;
4078
+ const Token_1 = requireToken();
4079
+ const ROW_DELIMITER = /((?:\r\n)|\n|\r)/;
4080
+ let Scanner$1 = class Scanner {
4081
+ line;
4082
+ parserOptions;
4083
+ lineLength;
4084
+ hasMoreData;
4085
+ cursor = 0;
4086
+ constructor(args) {
4087
+ this.line = args.line;
4088
+ this.lineLength = this.line.length;
4089
+ this.parserOptions = args.parserOptions;
4090
+ this.hasMoreData = args.hasMoreData;
4091
+ this.cursor = args.cursor || 0;
4092
+ }
4093
+ get hasMoreCharacters() {
4094
+ return this.lineLength > this.cursor;
4095
+ }
4096
+ get nextNonSpaceToken() {
4097
+ const { lineFromCursor } = this;
4098
+ const regex = this.parserOptions.NEXT_TOKEN_REGEXP;
4099
+ if (lineFromCursor.search(regex) === -1) {
4100
+ return null;
4101
+ }
4102
+ const match = regex.exec(lineFromCursor);
4103
+ if (match == null) {
4104
+ return null;
4105
+ }
4106
+ const token = match[1];
4107
+ const startCursor = this.cursor + (match.index || 0);
4108
+ return new Token_1.Token({
4109
+ token,
4110
+ startCursor,
4111
+ endCursor: startCursor + token.length - 1,
4112
+ });
4113
+ }
4114
+ get nextCharacterToken() {
4115
+ const { cursor, lineLength } = this;
4116
+ if (lineLength <= cursor) {
4117
+ return null;
4118
+ }
4119
+ return new Token_1.Token({
4120
+ token: this.line[cursor],
4121
+ startCursor: cursor,
4122
+ endCursor: cursor,
4123
+ });
4124
+ }
4125
+ get lineFromCursor() {
4126
+ return this.line.substr(this.cursor);
4127
+ }
4128
+ advancePastLine() {
4129
+ const match = ROW_DELIMITER.exec(this.lineFromCursor);
4130
+ if (!match) {
4131
+ if (this.hasMoreData) {
4132
+ return null;
4133
+ }
4134
+ this.cursor = this.lineLength;
4135
+ return this;
4136
+ }
4137
+ this.cursor += (match.index || 0) + match[0].length;
4138
+ return this;
4139
+ }
4140
+ advanceTo(cursor) {
4141
+ this.cursor = cursor;
4142
+ return this;
4143
+ }
4144
+ advanceToToken(token) {
4145
+ this.cursor = token.startCursor;
4146
+ return this;
4147
+ }
4148
+ advancePastToken(token) {
4149
+ this.cursor = token.endCursor + 1;
4150
+ return this;
4151
+ }
4152
+ truncateToCursor() {
4153
+ this.line = this.lineFromCursor;
4154
+ this.lineLength = this.line.length;
4155
+ this.cursor = 0;
4156
+ return this;
4157
+ }
4158
+ };
4159
+ Scanner.Scanner = Scanner$1;
4160
+
4161
+ return Scanner;
4162
+ }
4163
+
4164
+ var RowParser = {};
4165
+
4166
+ var column = {};
4167
+
4168
+ var ColumnParser = {};
4169
+
4170
+ var NonQuotedColumnParser = {};
4171
+
4172
+ var ColumnFormatter = {};
4173
+
4174
+ var hasRequiredColumnFormatter;
4175
+
4176
+ function requireColumnFormatter () {
4177
+ if (hasRequiredColumnFormatter) return ColumnFormatter;
4178
+ hasRequiredColumnFormatter = 1;
4179
+ Object.defineProperty(ColumnFormatter, "__esModule", { value: true });
4180
+ ColumnFormatter.ColumnFormatter = void 0;
4181
+ let ColumnFormatter$1 = class ColumnFormatter {
4182
+ format;
4183
+ constructor(parserOptions) {
4184
+ if (parserOptions.trim) {
4185
+ this.format = (col) => {
4186
+ return col.trim();
4187
+ };
4188
+ }
4189
+ else if (parserOptions.ltrim) {
4190
+ this.format = (col) => {
4191
+ return col.trimLeft();
4192
+ };
4193
+ }
4194
+ else if (parserOptions.rtrim) {
4195
+ this.format = (col) => {
4196
+ return col.trimRight();
4197
+ };
4198
+ }
4199
+ else {
4200
+ this.format = (col) => {
4201
+ return col;
4202
+ };
4203
+ }
4204
+ }
4205
+ };
4206
+ ColumnFormatter.ColumnFormatter = ColumnFormatter$1;
4207
+
4208
+ return ColumnFormatter;
4209
+ }
4210
+
4211
+ var hasRequiredNonQuotedColumnParser;
4212
+
4213
+ function requireNonQuotedColumnParser () {
4214
+ if (hasRequiredNonQuotedColumnParser) return NonQuotedColumnParser;
4215
+ hasRequiredNonQuotedColumnParser = 1;
4216
+ Object.defineProperty(NonQuotedColumnParser, "__esModule", { value: true });
4217
+ NonQuotedColumnParser.NonQuotedColumnParser = void 0;
4218
+ const ColumnFormatter_1 = requireColumnFormatter();
4219
+ const Token_1 = requireToken();
4220
+ let NonQuotedColumnParser$1 = class NonQuotedColumnParser {
4221
+ parserOptions;
4222
+ columnFormatter;
4223
+ constructor(parserOptions) {
4224
+ this.parserOptions = parserOptions;
4225
+ this.columnFormatter = new ColumnFormatter_1.ColumnFormatter(parserOptions);
4226
+ }
4227
+ parse(scanner) {
4228
+ if (!scanner.hasMoreCharacters) {
4229
+ return null;
4230
+ }
4231
+ const { parserOptions } = this;
4232
+ const characters = [];
4233
+ let nextToken = scanner.nextCharacterToken;
4234
+ for (; nextToken; nextToken = scanner.nextCharacterToken) {
4235
+ if (Token_1.Token.isTokenDelimiter(nextToken, parserOptions) || Token_1.Token.isTokenRowDelimiter(nextToken)) {
4236
+ break;
4237
+ }
4238
+ characters.push(nextToken.token);
4239
+ scanner.advancePastToken(nextToken);
4240
+ }
4241
+ return this.columnFormatter.format(characters.join(''));
4242
+ }
4243
+ };
4244
+ NonQuotedColumnParser.NonQuotedColumnParser = NonQuotedColumnParser$1;
4245
+
4246
+ return NonQuotedColumnParser;
4247
+ }
4248
+
4249
+ var QuotedColumnParser = {};
4250
+
4251
+ var hasRequiredQuotedColumnParser;
4252
+
4253
+ function requireQuotedColumnParser () {
4254
+ if (hasRequiredQuotedColumnParser) return QuotedColumnParser;
4255
+ hasRequiredQuotedColumnParser = 1;
4256
+ Object.defineProperty(QuotedColumnParser, "__esModule", { value: true });
4257
+ QuotedColumnParser.QuotedColumnParser = void 0;
4258
+ const ColumnFormatter_1 = requireColumnFormatter();
4259
+ const Token_1 = requireToken();
4260
+ let QuotedColumnParser$1 = class QuotedColumnParser {
4261
+ parserOptions;
4262
+ columnFormatter;
4263
+ constructor(parserOptions) {
4264
+ this.parserOptions = parserOptions;
4265
+ this.columnFormatter = new ColumnFormatter_1.ColumnFormatter(parserOptions);
4266
+ }
4267
+ parse(scanner) {
4268
+ if (!scanner.hasMoreCharacters) {
4269
+ return null;
4270
+ }
4271
+ const originalCursor = scanner.cursor;
4272
+ const { foundClosingQuote, col } = this.gatherDataBetweenQuotes(scanner);
4273
+ if (!foundClosingQuote) {
4274
+ // reset the cursor to the original
4275
+ scanner.advanceTo(originalCursor);
4276
+ // if we didnt find a closing quote but we potentially have more data then skip the parsing
4277
+ // and return the original scanner.
4278
+ if (!scanner.hasMoreData) {
4279
+ throw new Error(`Parse Error: missing closing: '${this.parserOptions.quote || ''}' in line: at '${scanner.lineFromCursor.replace(/[\r\n]/g, "\\n'")}'`);
4280
+ }
4281
+ return null;
4282
+ }
4283
+ this.checkForMalformedColumn(scanner);
4284
+ return col;
4285
+ }
4286
+ gatherDataBetweenQuotes(scanner) {
4287
+ const { parserOptions } = this;
4288
+ let foundStartingQuote = false;
4289
+ let foundClosingQuote = false;
4290
+ const characters = [];
4291
+ let nextToken = scanner.nextCharacterToken;
4292
+ for (; !foundClosingQuote && nextToken !== null; nextToken = scanner.nextCharacterToken) {
4293
+ const isQuote = Token_1.Token.isTokenQuote(nextToken, parserOptions);
4294
+ // ignore first quote
4295
+ if (!foundStartingQuote && isQuote) {
4296
+ foundStartingQuote = true;
4297
+ }
4298
+ else if (foundStartingQuote) {
4299
+ if (Token_1.Token.isTokenEscapeCharacter(nextToken, parserOptions)) {
4300
+ // advance past the escape character so we can get the next one in line
4301
+ scanner.advancePastToken(nextToken);
4302
+ const tokenFollowingEscape = scanner.nextCharacterToken;
4303
+ // if the character following the escape is a quote character then just add
4304
+ // the quote and advance to that character
4305
+ if (tokenFollowingEscape !== null &&
4306
+ (Token_1.Token.isTokenQuote(tokenFollowingEscape, parserOptions) ||
4307
+ Token_1.Token.isTokenEscapeCharacter(tokenFollowingEscape, parserOptions))) {
4308
+ characters.push(tokenFollowingEscape.token);
4309
+ nextToken = tokenFollowingEscape;
4310
+ }
4311
+ else if (isQuote) {
4312
+ // if the escape is also a quote then we found our closing quote and finish early
4313
+ foundClosingQuote = true;
4314
+ }
4315
+ else {
4316
+ // other wise add the escape token to the characters since it wast escaping anything
4317
+ characters.push(nextToken.token);
4318
+ }
4319
+ }
4320
+ else if (isQuote) {
4321
+ // we found our closing quote!
4322
+ foundClosingQuote = true;
4323
+ }
4324
+ else {
4325
+ // add the token to the characters
4326
+ characters.push(nextToken.token);
4327
+ }
4328
+ }
4329
+ scanner.advancePastToken(nextToken);
4330
+ }
4331
+ return { col: this.columnFormatter.format(characters.join('')), foundClosingQuote };
4332
+ }
4333
+ checkForMalformedColumn(scanner) {
4334
+ const { parserOptions } = this;
4335
+ const { nextNonSpaceToken } = scanner;
4336
+ if (nextNonSpaceToken) {
4337
+ const isNextTokenADelimiter = Token_1.Token.isTokenDelimiter(nextNonSpaceToken, parserOptions);
4338
+ const isNextTokenARowDelimiter = Token_1.Token.isTokenRowDelimiter(nextNonSpaceToken);
4339
+ if (!(isNextTokenADelimiter || isNextTokenARowDelimiter)) {
4340
+ // if the final quote was NOT followed by a column (,) or row(\n) delimiter then its a bad column
4341
+ // tldr: only part of the column was quoted
4342
+ const linePreview = scanner.lineFromCursor.substr(0, 10).replace(/[\r\n]/g, "\\n'");
4343
+ throw new Error(`Parse Error: expected: '${parserOptions.escapedDelimiter}' OR new line got: '${nextNonSpaceToken.token}'. at '${linePreview}'`);
4344
+ }
4345
+ scanner.advanceToToken(nextNonSpaceToken);
4346
+ }
4347
+ else if (!scanner.hasMoreData) {
4348
+ scanner.advancePastLine();
4349
+ }
4350
+ }
4351
+ };
4352
+ QuotedColumnParser.QuotedColumnParser = QuotedColumnParser$1;
4353
+
4354
+ return QuotedColumnParser;
4355
+ }
4356
+
4357
+ var hasRequiredColumnParser;
4358
+
4359
+ function requireColumnParser () {
4360
+ if (hasRequiredColumnParser) return ColumnParser;
4361
+ hasRequiredColumnParser = 1;
4362
+ Object.defineProperty(ColumnParser, "__esModule", { value: true });
4363
+ ColumnParser.ColumnParser = void 0;
4364
+ const NonQuotedColumnParser_1 = requireNonQuotedColumnParser();
4365
+ const QuotedColumnParser_1 = requireQuotedColumnParser();
4366
+ const Token_1 = requireToken();
4367
+ let ColumnParser$1 = class ColumnParser {
4368
+ parserOptions;
4369
+ nonQuotedColumnParser;
4370
+ quotedColumnParser;
4371
+ constructor(parserOptions) {
4372
+ this.parserOptions = parserOptions;
4373
+ this.quotedColumnParser = new QuotedColumnParser_1.QuotedColumnParser(parserOptions);
4374
+ this.nonQuotedColumnParser = new NonQuotedColumnParser_1.NonQuotedColumnParser(parserOptions);
4375
+ }
4376
+ parse(scanner) {
4377
+ const { nextNonSpaceToken } = scanner;
4378
+ if (nextNonSpaceToken !== null && Token_1.Token.isTokenQuote(nextNonSpaceToken, this.parserOptions)) {
4379
+ scanner.advanceToToken(nextNonSpaceToken);
4380
+ return this.quotedColumnParser.parse(scanner);
4381
+ }
4382
+ return this.nonQuotedColumnParser.parse(scanner);
4383
+ }
4384
+ };
4385
+ ColumnParser.ColumnParser = ColumnParser$1;
4386
+
4387
+ return ColumnParser;
4388
+ }
4389
+
4390
+ var hasRequiredColumn;
4391
+
4392
+ function requireColumn () {
4393
+ if (hasRequiredColumn) return column;
4394
+ hasRequiredColumn = 1;
4395
+ (function (exports) {
4396
+ Object.defineProperty(exports, "__esModule", { value: true });
4397
+ exports.ColumnFormatter = exports.QuotedColumnParser = exports.NonQuotedColumnParser = exports.ColumnParser = void 0;
4398
+ var ColumnParser_1 = requireColumnParser();
4399
+ Object.defineProperty(exports, "ColumnParser", { enumerable: true, get: function () { return ColumnParser_1.ColumnParser; } });
4400
+ var NonQuotedColumnParser_1 = requireNonQuotedColumnParser();
4401
+ Object.defineProperty(exports, "NonQuotedColumnParser", { enumerable: true, get: function () { return NonQuotedColumnParser_1.NonQuotedColumnParser; } });
4402
+ var QuotedColumnParser_1 = requireQuotedColumnParser();
4403
+ Object.defineProperty(exports, "QuotedColumnParser", { enumerable: true, get: function () { return QuotedColumnParser_1.QuotedColumnParser; } });
4404
+ var ColumnFormatter_1 = requireColumnFormatter();
4405
+ Object.defineProperty(exports, "ColumnFormatter", { enumerable: true, get: function () { return ColumnFormatter_1.ColumnFormatter; } });
4406
+
4407
+ } (column));
4408
+ return column;
4409
+ }
4410
+
4411
+ var hasRequiredRowParser;
4412
+
4413
+ function requireRowParser () {
4414
+ if (hasRequiredRowParser) return RowParser;
4415
+ hasRequiredRowParser = 1;
4416
+ Object.defineProperty(RowParser, "__esModule", { value: true });
4417
+ RowParser.RowParser = void 0;
4418
+ const column_1 = requireColumn();
4419
+ const Token_1 = requireToken();
4420
+ const EMPTY_STRING = '';
4421
+ let RowParser$1 = class RowParser {
4422
+ static isEmptyRow(row) {
4423
+ return row.join(EMPTY_STRING).replace(/\s+/g, EMPTY_STRING) === EMPTY_STRING;
4424
+ }
4425
+ parserOptions;
4426
+ columnParser;
4427
+ constructor(parserOptions) {
4428
+ this.parserOptions = parserOptions;
4429
+ this.columnParser = new column_1.ColumnParser(parserOptions);
4430
+ }
4431
+ parse(scanner) {
4432
+ const { parserOptions } = this;
4433
+ const { hasMoreData } = scanner;
4434
+ const currentScanner = scanner;
4435
+ const columns = [];
4436
+ let currentToken = this.getStartToken(currentScanner, columns);
4437
+ while (currentToken) {
4438
+ if (Token_1.Token.isTokenRowDelimiter(currentToken)) {
4439
+ currentScanner.advancePastToken(currentToken);
4440
+ // if ends with CR and there is more data, keep unparsed due to possible
4441
+ // coming LF in CRLF
4442
+ if (!currentScanner.hasMoreCharacters &&
4443
+ Token_1.Token.isTokenCarriageReturn(currentToken, parserOptions) &&
4444
+ hasMoreData) {
4445
+ return null;
4446
+ }
4447
+ currentScanner.truncateToCursor();
4448
+ return columns;
4449
+ }
4450
+ if (!this.shouldSkipColumnParse(currentScanner, currentToken, columns)) {
4451
+ const item = this.columnParser.parse(currentScanner);
4452
+ if (item === null) {
4453
+ return null;
4454
+ }
4455
+ columns.push(item);
4456
+ }
4457
+ currentToken = currentScanner.nextNonSpaceToken;
4458
+ }
4459
+ if (!hasMoreData) {
4460
+ currentScanner.truncateToCursor();
4461
+ return columns;
4462
+ }
4463
+ return null;
4464
+ }
4465
+ getStartToken(scanner, columns) {
4466
+ const currentToken = scanner.nextNonSpaceToken;
4467
+ if (currentToken !== null && Token_1.Token.isTokenDelimiter(currentToken, this.parserOptions)) {
4468
+ columns.push('');
4469
+ return scanner.nextNonSpaceToken;
4470
+ }
4471
+ return currentToken;
4472
+ }
4473
+ shouldSkipColumnParse(scanner, currentToken, columns) {
4474
+ const { parserOptions } = this;
4475
+ if (Token_1.Token.isTokenDelimiter(currentToken, parserOptions)) {
4476
+ scanner.advancePastToken(currentToken);
4477
+ // if the delimiter is at the end of a line
4478
+ const nextToken = scanner.nextCharacterToken;
4479
+ if (!scanner.hasMoreCharacters || (nextToken !== null && Token_1.Token.isTokenRowDelimiter(nextToken))) {
4480
+ columns.push('');
4481
+ return true;
4482
+ }
4483
+ if (nextToken !== null && Token_1.Token.isTokenDelimiter(nextToken, parserOptions)) {
4484
+ columns.push('');
4485
+ return true;
4486
+ }
4487
+ }
4488
+ return false;
4489
+ }
4490
+ };
4491
+ RowParser.RowParser = RowParser$1;
4492
+
4493
+ return RowParser;
4494
+ }
4495
+
4496
+ var hasRequiredParser$1;
4497
+
4498
+ function requireParser$1 () {
4499
+ if (hasRequiredParser$1) return Parser;
4500
+ hasRequiredParser$1 = 1;
4501
+ Object.defineProperty(Parser, "__esModule", { value: true });
4502
+ Parser.Parser = void 0;
4503
+ const Scanner_1 = requireScanner();
4504
+ const RowParser_1 = requireRowParser();
4505
+ const Token_1 = requireToken();
4506
+ let Parser$1 = class Parser {
4507
+ static removeBOM(line) {
4508
+ // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
4509
+ // conversion translates it to FEFF (UTF-16 BOM)
4510
+ if (line && line.charCodeAt(0) === 0xfeff) {
4511
+ return line.slice(1);
4512
+ }
4513
+ return line;
4514
+ }
4515
+ parserOptions;
4516
+ rowParser;
4517
+ constructor(parserOptions) {
4518
+ this.parserOptions = parserOptions;
4519
+ this.rowParser = new RowParser_1.RowParser(this.parserOptions);
4520
+ }
4521
+ parse(line, hasMoreData) {
4522
+ const scanner = new Scanner_1.Scanner({
4523
+ line: Parser.removeBOM(line),
4524
+ parserOptions: this.parserOptions,
4525
+ hasMoreData,
4526
+ });
4527
+ if (this.parserOptions.supportsComments) {
4528
+ return this.parseWithComments(scanner);
4529
+ }
4530
+ return this.parseWithoutComments(scanner);
4531
+ }
4532
+ parseWithoutComments(scanner) {
4533
+ const rows = [];
4534
+ let shouldContinue = true;
4535
+ while (shouldContinue) {
4536
+ shouldContinue = this.parseRow(scanner, rows);
4537
+ }
4538
+ return { line: scanner.line, rows };
4539
+ }
4540
+ parseWithComments(scanner) {
4541
+ const { parserOptions } = this;
4542
+ const rows = [];
4543
+ for (let nextToken = scanner.nextCharacterToken; nextToken !== null; nextToken = scanner.nextCharacterToken) {
4544
+ if (Token_1.Token.isTokenComment(nextToken, parserOptions)) {
4545
+ const cursor = scanner.advancePastLine();
4546
+ if (cursor === null) {
4547
+ return { line: scanner.lineFromCursor, rows };
4548
+ }
4549
+ if (!scanner.hasMoreCharacters) {
4550
+ return { line: scanner.lineFromCursor, rows };
4551
+ }
4552
+ scanner.truncateToCursor();
4553
+ }
4554
+ else if (!this.parseRow(scanner, rows)) {
4555
+ break;
4556
+ }
4557
+ }
4558
+ return { line: scanner.line, rows };
4559
+ }
4560
+ parseRow(scanner, rows) {
4561
+ const nextToken = scanner.nextNonSpaceToken;
4562
+ if (!nextToken) {
4563
+ return false;
4564
+ }
4565
+ const row = this.rowParser.parse(scanner);
4566
+ if (row === null) {
4567
+ return false;
4568
+ }
4569
+ if (this.parserOptions.ignoreEmpty && RowParser_1.RowParser.isEmptyRow(row)) {
4570
+ return true;
4571
+ }
4572
+ rows.push(row);
4573
+ return true;
4574
+ }
4575
+ };
4576
+ Parser.Parser = Parser$1;
4577
+
4578
+ return Parser;
4579
+ }
4580
+
4581
+ var hasRequiredParser;
4582
+
4583
+ function requireParser () {
4584
+ if (hasRequiredParser) return parser;
4585
+ hasRequiredParser = 1;
4586
+ (function (exports) {
4587
+ Object.defineProperty(exports, "__esModule", { value: true });
4588
+ exports.QuotedColumnParser = exports.NonQuotedColumnParser = exports.ColumnParser = exports.Token = exports.Scanner = exports.RowParser = exports.Parser = void 0;
4589
+ var Parser_1 = requireParser$1();
4590
+ Object.defineProperty(exports, "Parser", { enumerable: true, get: function () { return Parser_1.Parser; } });
4591
+ var RowParser_1 = requireRowParser();
4592
+ Object.defineProperty(exports, "RowParser", { enumerable: true, get: function () { return RowParser_1.RowParser; } });
4593
+ var Scanner_1 = requireScanner();
4594
+ Object.defineProperty(exports, "Scanner", { enumerable: true, get: function () { return Scanner_1.Scanner; } });
4595
+ var Token_1 = requireToken();
4596
+ Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return Token_1.Token; } });
4597
+ var column_1 = requireColumn();
4598
+ Object.defineProperty(exports, "ColumnParser", { enumerable: true, get: function () { return column_1.ColumnParser; } });
4599
+ Object.defineProperty(exports, "NonQuotedColumnParser", { enumerable: true, get: function () { return column_1.NonQuotedColumnParser; } });
4600
+ Object.defineProperty(exports, "QuotedColumnParser", { enumerable: true, get: function () { return column_1.QuotedColumnParser; } });
4601
+
4602
+ } (parser));
4603
+ return parser;
4604
+ }
4605
+
4606
+ var hasRequiredCsvParserStream;
4607
+
4608
+ function requireCsvParserStream () {
4609
+ if (hasRequiredCsvParserStream) return CsvParserStream;
4610
+ hasRequiredCsvParserStream = 1;
4611
+ Object.defineProperty(CsvParserStream, "__esModule", { value: true });
4612
+ CsvParserStream.CsvParserStream = void 0;
4613
+ const string_decoder_1 = require$$0;
4614
+ const stream_1 = require$$1;
4615
+ const transforms_1 = requireTransforms();
4616
+ const parser_1 = requireParser();
4617
+ let CsvParserStream$1 = class CsvParserStream extends stream_1.Transform {
4618
+ parserOptions;
4619
+ decoder;
4620
+ parser;
4621
+ headerTransformer;
4622
+ rowTransformerValidator;
4623
+ lines = '';
4624
+ rowCount = 0;
4625
+ parsedRowCount = 0;
4626
+ parsedLineCount = 0;
4627
+ endEmitted = false;
4628
+ headersEmitted = false;
4629
+ constructor(parserOptions) {
4630
+ super({ objectMode: parserOptions.objectMode });
4631
+ this.parserOptions = parserOptions;
4632
+ this.parser = new parser_1.Parser(parserOptions);
4633
+ this.headerTransformer = new transforms_1.HeaderTransformer(parserOptions);
4634
+ this.decoder = new string_decoder_1.StringDecoder(parserOptions.encoding);
4635
+ this.rowTransformerValidator = new transforms_1.RowTransformerValidator();
4636
+ }
4637
+ get hasHitRowLimit() {
4638
+ return this.parserOptions.limitRows && this.rowCount >= this.parserOptions.maxRows;
4639
+ }
4640
+ get shouldEmitRows() {
4641
+ return this.parsedRowCount > this.parserOptions.skipRows;
4642
+ }
4643
+ get shouldSkipLine() {
4644
+ return this.parsedLineCount <= this.parserOptions.skipLines;
4645
+ }
4646
+ transform(transformFunction) {
4647
+ this.rowTransformerValidator.rowTransform = transformFunction;
4648
+ return this;
4649
+ }
4650
+ validate(validateFunction) {
4651
+ this.rowTransformerValidator.rowValidator = validateFunction;
4652
+ return this;
4653
+ }
4654
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4655
+ emit(event, ...rest) {
4656
+ if (event === 'end') {
4657
+ if (!this.endEmitted) {
4658
+ this.endEmitted = true;
4659
+ super.emit('end', this.rowCount);
4660
+ }
4661
+ return false;
4662
+ }
4663
+ return super.emit(event, ...rest);
4664
+ }
4665
+ _transform(data, encoding, done) {
4666
+ // if we have hit our maxRows parsing limit then skip parsing
4667
+ if (this.hasHitRowLimit) {
4668
+ return done();
4669
+ }
4670
+ const wrappedCallback = CsvParserStream.wrapDoneCallback(done);
4671
+ try {
4672
+ const { lines } = this;
4673
+ const newLine = lines + this.decoder.write(data);
4674
+ const rows = this.parse(newLine, true);
4675
+ return this.processRows(rows, wrappedCallback);
4676
+ }
4677
+ catch (e) {
4678
+ return wrappedCallback(e);
4679
+ }
4680
+ }
4681
+ _flush(done) {
4682
+ const wrappedCallback = CsvParserStream.wrapDoneCallback(done);
4683
+ // if we have hit our maxRows parsing limit then skip parsing
4684
+ if (this.hasHitRowLimit) {
4685
+ return wrappedCallback();
4686
+ }
4687
+ try {
4688
+ const newLine = this.lines + this.decoder.end();
4689
+ const rows = this.parse(newLine, false);
4690
+ return this.processRows(rows, wrappedCallback);
4691
+ }
4692
+ catch (e) {
4693
+ return wrappedCallback(e);
4694
+ }
4695
+ }
4696
+ parse(data, hasMoreData) {
4697
+ if (!data) {
4698
+ return [];
4699
+ }
4700
+ const { line, rows } = this.parser.parse(data, hasMoreData);
4701
+ this.lines = line;
4702
+ return rows;
4703
+ }
4704
+ processRows(rows, cb) {
4705
+ const rowsLength = rows.length;
4706
+ const iterate = (i) => {
4707
+ const callNext = (err) => {
4708
+ if (err) {
4709
+ return cb(err);
4710
+ }
4711
+ if (i % 100 === 0) {
4712
+ // incase the transform are sync insert a next tick to prevent stack overflow
4713
+ setImmediate(() => {
4714
+ return iterate(i + 1);
4715
+ });
4716
+ return undefined;
4717
+ }
4718
+ return iterate(i + 1);
4719
+ };
4720
+ this.checkAndEmitHeaders();
4721
+ // if we have emitted all rows or we have hit the maxRows limit option
4722
+ // then end
4723
+ if (i >= rowsLength || this.hasHitRowLimit) {
4724
+ return cb();
4725
+ }
4726
+ this.parsedLineCount += 1;
4727
+ if (this.shouldSkipLine) {
4728
+ return callNext();
4729
+ }
4730
+ const row = rows[i];
4731
+ this.rowCount += 1;
4732
+ this.parsedRowCount += 1;
4733
+ const nextRowCount = this.rowCount;
4734
+ return this.transformRow(row, (err, transformResult) => {
4735
+ if (err) {
4736
+ this.rowCount -= 1;
4737
+ return callNext(err);
4738
+ }
4739
+ if (!transformResult) {
4740
+ return callNext(new Error('expected transform result'));
4741
+ }
4742
+ if (!transformResult.isValid) {
4743
+ this.emit('data-invalid', transformResult.row, nextRowCount, transformResult.reason);
4744
+ }
4745
+ else if (transformResult.row) {
4746
+ return this.pushRow(transformResult.row, callNext);
4747
+ }
4748
+ return callNext();
4749
+ });
4750
+ };
4751
+ iterate(0);
4752
+ }
4753
+ transformRow(parsedRow, cb) {
4754
+ try {
4755
+ this.headerTransformer.transform(parsedRow, (err, withHeaders) => {
4756
+ if (err) {
4757
+ return cb(err);
4758
+ }
4759
+ if (!withHeaders) {
4760
+ return cb(new Error('Expected result from header transform'));
4761
+ }
4762
+ if (!withHeaders.isValid) {
4763
+ if (this.shouldEmitRows) {
4764
+ return cb(null, { isValid: false, row: parsedRow });
4765
+ }
4766
+ // skipped because of skipRows option remove from total row count
4767
+ return this.skipRow(cb);
4768
+ }
4769
+ if (withHeaders.row) {
4770
+ if (this.shouldEmitRows) {
4771
+ return this.rowTransformerValidator.transformAndValidate(withHeaders.row, cb);
4772
+ }
4773
+ // skipped because of skipRows option remove from total row count
4774
+ return this.skipRow(cb);
4775
+ }
4776
+ // this is a header row dont include in the rowCount or parsedRowCount
4777
+ this.rowCount -= 1;
4778
+ this.parsedRowCount -= 1;
4779
+ return cb(null, { row: null, isValid: true });
4780
+ });
4781
+ }
4782
+ catch (e) {
4783
+ cb(e);
4784
+ }
4785
+ }
4786
+ checkAndEmitHeaders() {
4787
+ if (!this.headersEmitted && this.headerTransformer.headers) {
4788
+ this.headersEmitted = true;
4789
+ this.emit('headers', this.headerTransformer.headers);
4790
+ }
4791
+ }
4792
+ skipRow(cb) {
4793
+ // skipped because of skipRows option remove from total row count
4794
+ this.rowCount -= 1;
4795
+ return cb(null, { row: null, isValid: true });
4796
+ }
4797
+ pushRow(row, cb) {
4798
+ try {
4799
+ if (!this.parserOptions.objectMode) {
4800
+ this.push(JSON.stringify(row));
4801
+ }
4802
+ else {
4803
+ this.push(row);
4804
+ }
4805
+ cb();
4806
+ }
4807
+ catch (e) {
4808
+ cb(e);
4809
+ }
4810
+ }
4811
+ static wrapDoneCallback(done) {
4812
+ let errorCalled = false;
4813
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4814
+ return (err, ...args) => {
4815
+ if (err) {
4816
+ if (errorCalled) {
4817
+ throw err;
4818
+ }
4819
+ errorCalled = true;
4820
+ done(err);
4821
+ return;
4822
+ }
4823
+ done(...args);
4824
+ };
4825
+ }
4826
+ };
4827
+ CsvParserStream.CsvParserStream = CsvParserStream$1;
4828
+
4829
+ return CsvParserStream;
4830
+ }
4831
+
4832
+ var hasRequiredSrc;
4833
+
4834
+ function requireSrc () {
4835
+ if (hasRequiredSrc) return src;
4836
+ hasRequiredSrc = 1;
4837
+ (function (exports) {
4838
+ var __createBinding = (src && src.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4839
+ if (k2 === undefined) k2 = k;
4840
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4841
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4842
+ desc = { enumerable: true, get: function() { return m[k]; } };
4843
+ }
4844
+ Object.defineProperty(o, k2, desc);
4845
+ }) : (function(o, m, k, k2) {
4846
+ if (k2 === undefined) k2 = k;
4847
+ o[k2] = m[k];
4848
+ }));
4849
+ var __setModuleDefault = (src && src.__setModuleDefault) || (Object.create ? (function(o, v) {
4850
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
4851
+ }) : function(o, v) {
4852
+ o["default"] = v;
4853
+ });
4854
+ var __importStar = (src && src.__importStar) || function (mod) {
4855
+ if (mod && mod.__esModule) return mod;
4856
+ var result = {};
4857
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
4858
+ __setModuleDefault(result, mod);
4859
+ return result;
4860
+ };
4861
+ var __exportStar = (src && src.__exportStar) || function(m, exports) {
4862
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
4863
+ };
4864
+ Object.defineProperty(exports, "__esModule", { value: true });
4865
+ exports.parseString = exports.parseFile = exports.parseStream = exports.parse = exports.ParserOptions = exports.CsvParserStream = void 0;
4866
+ const fs = __importStar(require$$0$1);
4867
+ const stream_1 = require$$1;
4868
+ const ParserOptions_1 = requireParserOptions();
4869
+ const CsvParserStream_1 = requireCsvParserStream();
4870
+ __exportStar(requireTypes(), exports);
4871
+ var CsvParserStream_2 = requireCsvParserStream();
4872
+ Object.defineProperty(exports, "CsvParserStream", { enumerable: true, get: function () { return CsvParserStream_2.CsvParserStream; } });
4873
+ var ParserOptions_2 = requireParserOptions();
4874
+ Object.defineProperty(exports, "ParserOptions", { enumerable: true, get: function () { return ParserOptions_2.ParserOptions; } });
4875
+ const parse = (args) => {
4876
+ return new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(args));
4877
+ };
4878
+ exports.parse = parse;
4879
+ const parseStream = (stream, options) => {
4880
+ return stream.pipe(new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(options)));
4881
+ };
4882
+ exports.parseStream = parseStream;
4883
+ const parseFile = (location, options = {}) => {
4884
+ return fs.createReadStream(location).pipe(new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(options)));
4885
+ };
4886
+ exports.parseFile = parseFile;
4887
+ const parseString = (string, options) => {
4888
+ const rs = new stream_1.Readable();
4889
+ rs.push(string);
4890
+ rs.push(null);
4891
+ return rs.pipe(new CsvParserStream_1.CsvParserStream(new ParserOptions_1.ParserOptions(options)));
4892
+ };
4893
+ exports.parseString = parseString;
4894
+
4895
+ } (src));
4896
+ return src;
4897
+ }
4898
+
4899
+ var srcExports = requireSrc();
4900
+
4901
+ const index = /*#__PURE__*/_mergeNamespaces({
4902
+ __proto__: null
4903
+ }, [srcExports]);
4904
+
4905
+ export { index as i };