@bigbinary/neeto-molecules 3.2.1 → 3.2.3

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.
Files changed (61) hide show
  1. package/dist/BrowserSupport.js +2 -1
  2. package/dist/BrowserSupport.js.map +1 -1
  3. package/dist/DownloadMobileAppCallout.js +2 -1
  4. package/dist/DownloadMobileAppCallout.js.map +1 -1
  5. package/dist/EmailForm.js +2 -1
  6. package/dist/EmailForm.js.map +1 -1
  7. package/dist/FloatingActionMenu.js +2 -1
  8. package/dist/FloatingActionMenu.js.map +1 -1
  9. package/dist/IconPicker.js +916 -4
  10. package/dist/IconPicker.js.map +1 -1
  11. package/dist/IpRestriction.js +3093 -7
  12. package/dist/IpRestriction.js.map +1 -1
  13. package/dist/KeyboardShortcuts.js +2 -1
  14. package/dist/KeyboardShortcuts.js.map +1 -1
  15. package/dist/MenuBar.js +1804 -12
  16. package/dist/MenuBar.js.map +1 -1
  17. package/dist/NeetoWidget.js +1957 -3
  18. package/dist/NeetoWidget.js.map +1 -1
  19. package/dist/PhoneNumber.js +12 -4
  20. package/dist/PhoneNumber.js.map +1 -1
  21. package/dist/SendToFields.js +1919 -1
  22. package/dist/SendToFields.js.map +1 -1
  23. package/dist/ShareViaEmail.js +2 -1
  24. package/dist/ShareViaEmail.js.map +1 -1
  25. package/dist/ShareViaLink.js +860 -2
  26. package/dist/ShareViaLink.js.map +1 -1
  27. package/dist/_commonjsHelpers-1c8beb5f.js +4 -0
  28. package/dist/_commonjsHelpers-1c8beb5f.js.map +1 -0
  29. package/dist/cjs/BrowserSupport.js +3 -3
  30. package/dist/cjs/BrowserSupport.js.map +1 -1
  31. package/dist/cjs/DownloadMobileAppCallout.js +3 -3
  32. package/dist/cjs/DownloadMobileAppCallout.js.map +1 -1
  33. package/dist/cjs/EmailForm.js +2 -1
  34. package/dist/cjs/EmailForm.js.map +1 -1
  35. package/dist/cjs/FloatingActionMenu.js +2 -1
  36. package/dist/cjs/FloatingActionMenu.js.map +1 -1
  37. package/dist/cjs/IconPicker.js +920 -5
  38. package/dist/cjs/IconPicker.js.map +1 -1
  39. package/dist/cjs/IpRestriction.js +3101 -15
  40. package/dist/cjs/IpRestriction.js.map +1 -1
  41. package/dist/cjs/KeyboardShortcuts.js +3 -3
  42. package/dist/cjs/KeyboardShortcuts.js.map +1 -1
  43. package/dist/cjs/MenuBar.js +1807 -10
  44. package/dist/cjs/MenuBar.js.map +1 -1
  45. package/dist/cjs/NeetoWidget.js +1958 -5
  46. package/dist/cjs/NeetoWidget.js.map +1 -1
  47. package/dist/cjs/PhoneNumber.js +12 -4
  48. package/dist/cjs/PhoneNumber.js.map +1 -1
  49. package/dist/cjs/SendToFields.js +1921 -3
  50. package/dist/cjs/SendToFields.js.map +1 -1
  51. package/dist/cjs/ShareViaEmail.js +2 -1
  52. package/dist/cjs/ShareViaEmail.js.map +1 -1
  53. package/dist/cjs/ShareViaLink.js +860 -3
  54. package/dist/cjs/ShareViaLink.js.map +1 -1
  55. package/dist/cjs/_commonjsHelpers-68cdf74f.js +6 -0
  56. package/dist/cjs/_commonjsHelpers-68cdf74f.js.map +1 -0
  57. package/dist/cjs/platform-628b3bd8.js +1252 -0
  58. package/dist/cjs/platform-628b3bd8.js.map +1 -0
  59. package/dist/platform-e221afea.js +1250 -0
  60. package/dist/platform-e221afea.js.map +1 -0
  61. package/package.json +16 -17
@@ -18,7 +18,8 @@ var withT = require('@bigbinary/neeto-commons-frontend/react-utils/withT');
18
18
  var Download = require('@bigbinary/neeto-icons/Download');
19
19
  var Callout = require('@bigbinary/neetoui/Callout');
20
20
  var i18next = require('i18next');
21
- var Papa = require('papaparse');
21
+ var _commonjsHelpers = require('./_commonjsHelpers-68cdf74f.js');
22
+ var require$$0 = require('stream');
22
23
  var ramda = require('ramda');
23
24
  var yup = require('yup');
24
25
 
@@ -38,7 +39,7 @@ var Pane__default = /*#__PURE__*/_interopDefaultLegacy(Pane);
38
39
  var withT__default = /*#__PURE__*/_interopDefaultLegacy(withT);
39
40
  var Download__default = /*#__PURE__*/_interopDefaultLegacy(Download);
40
41
  var Callout__default = /*#__PURE__*/_interopDefaultLegacy(Callout);
41
- var Papa__default = /*#__PURE__*/_interopDefaultLegacy(Papa);
42
+ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
42
43
 
43
44
  var CSV_FILE_SIZE_IN_KB = 32;
44
45
  var ONE_KILOBYTE_IN_BYTES = 1024;
@@ -170,6 +171,1923 @@ var BulkUploadPane = function BulkUploadPane(_ref) {
170
171
  }))));
171
172
  };
172
173
 
174
+ var papaparse = {exports: {}};
175
+
176
+ /* @license
177
+ Papa Parse
178
+ v5.4.1
179
+ https://github.com/mholt/PapaParse
180
+ License: MIT
181
+ */
182
+
183
+ (function (module, exports) {
184
+ (function(root, factory)
185
+ {
186
+ /* globals define */
187
+ {
188
+ // Node. Does not work with strict CommonJS, but
189
+ // only CommonJS-like environments that support module.exports,
190
+ // like Node.
191
+ module.exports = factory();
192
+ }
193
+ // in strict mode we cannot access arguments.callee, so we need a named reference to
194
+ // stringify the factory method for the blob worker
195
+ // eslint-disable-next-line func-name
196
+ }(_commonjsHelpers.commonjsGlobal, function moduleFactory()
197
+ {
198
+
199
+ var global = (function() {
200
+ // alternative method, similar to `Function('return this')()`
201
+ // but without using `eval` (which is disabled when
202
+ // using Content Security Policy).
203
+
204
+ if (typeof self !== 'undefined') { return self; }
205
+ if (typeof window !== 'undefined') { return window; }
206
+ if (typeof global !== 'undefined') { return global; }
207
+
208
+ // When running tests none of the above have been defined
209
+ return {};
210
+ })();
211
+
212
+
213
+ function getWorkerBlob() {
214
+ var URL = global.URL || global.webkitURL || null;
215
+ var code = moduleFactory.toString();
216
+ return Papa.BLOB_URL || (Papa.BLOB_URL = URL.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ", '(', code, ')();'], {type: 'text/javascript'})));
217
+ }
218
+
219
+ var IS_WORKER = !global.document && !!global.postMessage,
220
+ IS_PAPA_WORKER = global.IS_PAPA_WORKER || false;
221
+
222
+ var workers = {}, workerIdCounter = 0;
223
+
224
+ var Papa = {};
225
+
226
+ Papa.parse = CsvToJson;
227
+ Papa.unparse = JsonToCsv;
228
+
229
+ Papa.RECORD_SEP = String.fromCharCode(30);
230
+ Papa.UNIT_SEP = String.fromCharCode(31);
231
+ Papa.BYTE_ORDER_MARK = '\ufeff';
232
+ Papa.BAD_DELIMITERS = ['\r', '\n', '"', Papa.BYTE_ORDER_MARK];
233
+ Papa.WORKERS_SUPPORTED = !IS_WORKER && !!global.Worker;
234
+ Papa.NODE_STREAM_INPUT = 1;
235
+
236
+ // Configurable chunk sizes for local and remote files, respectively
237
+ Papa.LocalChunkSize = 1024 * 1024 * 10; // 10 MB
238
+ Papa.RemoteChunkSize = 1024 * 1024 * 5; // 5 MB
239
+ Papa.DefaultDelimiter = ','; // Used if not specified and detection fails
240
+
241
+ // Exposed for testing and development only
242
+ Papa.Parser = Parser;
243
+ Papa.ParserHandle = ParserHandle;
244
+ Papa.NetworkStreamer = NetworkStreamer;
245
+ Papa.FileStreamer = FileStreamer;
246
+ Papa.StringStreamer = StringStreamer;
247
+ Papa.ReadableStreamStreamer = ReadableStreamStreamer;
248
+ if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
249
+ Papa.DuplexStreamStreamer = DuplexStreamStreamer;
250
+ }
251
+
252
+ if (global.jQuery)
253
+ {
254
+ var $ = global.jQuery;
255
+ $.fn.parse = function(options)
256
+ {
257
+ var config = options.config || {};
258
+ var queue = [];
259
+
260
+ this.each(function(idx)
261
+ {
262
+ var supported = $(this).prop('tagName').toUpperCase() === 'INPUT'
263
+ && $(this).attr('type').toLowerCase() === 'file'
264
+ && global.FileReader;
265
+
266
+ if (!supported || !this.files || this.files.length === 0)
267
+ return true; // continue to next input element
268
+
269
+ for (var i = 0; i < this.files.length; i++)
270
+ {
271
+ queue.push({
272
+ file: this.files[i],
273
+ inputElem: this,
274
+ instanceConfig: $.extend({}, config)
275
+ });
276
+ }
277
+ });
278
+
279
+ parseNextFile(); // begin parsing
280
+ return this; // maintains chainability
281
+
282
+
283
+ function parseNextFile()
284
+ {
285
+ if (queue.length === 0)
286
+ {
287
+ if (isFunction(options.complete))
288
+ options.complete();
289
+ return;
290
+ }
291
+
292
+ var f = queue[0];
293
+
294
+ if (isFunction(options.before))
295
+ {
296
+ var returned = options.before(f.file, f.inputElem);
297
+
298
+ if (typeof returned === 'object')
299
+ {
300
+ if (returned.action === 'abort')
301
+ {
302
+ error('AbortError', f.file, f.inputElem, returned.reason);
303
+ return; // Aborts all queued files immediately
304
+ }
305
+ else if (returned.action === 'skip')
306
+ {
307
+ fileComplete(); // parse the next file in the queue, if any
308
+ return;
309
+ }
310
+ else if (typeof returned.config === 'object')
311
+ f.instanceConfig = $.extend(f.instanceConfig, returned.config);
312
+ }
313
+ else if (returned === 'skip')
314
+ {
315
+ fileComplete(); // parse the next file in the queue, if any
316
+ return;
317
+ }
318
+ }
319
+
320
+ // Wrap up the user's complete callback, if any, so that ours also gets executed
321
+ var userCompleteFunc = f.instanceConfig.complete;
322
+ f.instanceConfig.complete = function(results)
323
+ {
324
+ if (isFunction(userCompleteFunc))
325
+ userCompleteFunc(results, f.file, f.inputElem);
326
+ fileComplete();
327
+ };
328
+
329
+ Papa.parse(f.file, f.instanceConfig);
330
+ }
331
+
332
+ function error(name, file, elem, reason)
333
+ {
334
+ if (isFunction(options.error))
335
+ options.error({name: name}, file, elem, reason);
336
+ }
337
+
338
+ function fileComplete()
339
+ {
340
+ queue.splice(0, 1);
341
+ parseNextFile();
342
+ }
343
+ };
344
+ }
345
+
346
+
347
+ if (IS_PAPA_WORKER)
348
+ {
349
+ global.onmessage = workerThreadReceivedMessage;
350
+ }
351
+
352
+
353
+
354
+
355
+ function CsvToJson(_input, _config)
356
+ {
357
+ _config = _config || {};
358
+ var dynamicTyping = _config.dynamicTyping || false;
359
+ if (isFunction(dynamicTyping)) {
360
+ _config.dynamicTypingFunction = dynamicTyping;
361
+ // Will be filled on first row call
362
+ dynamicTyping = {};
363
+ }
364
+ _config.dynamicTyping = dynamicTyping;
365
+
366
+ _config.transform = isFunction(_config.transform) ? _config.transform : false;
367
+
368
+ if (_config.worker && Papa.WORKERS_SUPPORTED)
369
+ {
370
+ var w = newWorker();
371
+
372
+ w.userStep = _config.step;
373
+ w.userChunk = _config.chunk;
374
+ w.userComplete = _config.complete;
375
+ w.userError = _config.error;
376
+
377
+ _config.step = isFunction(_config.step);
378
+ _config.chunk = isFunction(_config.chunk);
379
+ _config.complete = isFunction(_config.complete);
380
+ _config.error = isFunction(_config.error);
381
+ delete _config.worker; // prevent infinite loop
382
+
383
+ w.postMessage({
384
+ input: _input,
385
+ config: _config,
386
+ workerId: w.id
387
+ });
388
+
389
+ return;
390
+ }
391
+
392
+ var streamer = null;
393
+ if (_input === Papa.NODE_STREAM_INPUT && typeof PAPA_BROWSER_CONTEXT === 'undefined')
394
+ {
395
+ // create a node Duplex stream for use
396
+ // with .pipe
397
+ streamer = new DuplexStreamStreamer(_config);
398
+ return streamer.getStream();
399
+ }
400
+ else if (typeof _input === 'string')
401
+ {
402
+ _input = stripBom(_input);
403
+ if (_config.download)
404
+ streamer = new NetworkStreamer(_config);
405
+ else
406
+ streamer = new StringStreamer(_config);
407
+ }
408
+ else if (_input.readable === true && isFunction(_input.read) && isFunction(_input.on))
409
+ {
410
+ streamer = new ReadableStreamStreamer(_config);
411
+ }
412
+ else if ((global.File && _input instanceof File) || _input instanceof Object) // ...Safari. (see issue #106)
413
+ streamer = new FileStreamer(_config);
414
+
415
+ return streamer.stream(_input);
416
+
417
+ // Strip character from UTF-8 BOM encoded files that cause issue parsing the file
418
+ function stripBom(string) {
419
+ if (string.charCodeAt(0) === 0xfeff) {
420
+ return string.slice(1);
421
+ }
422
+ return string;
423
+ }
424
+ }
425
+
426
+
427
+
428
+
429
+
430
+
431
+ function JsonToCsv(_input, _config)
432
+ {
433
+ // Default configuration
434
+
435
+ /** whether to surround every datum with quotes */
436
+ var _quotes = false;
437
+
438
+ /** whether to write headers */
439
+ var _writeHeader = true;
440
+
441
+ /** delimiting character(s) */
442
+ var _delimiter = ',';
443
+
444
+ /** newline character(s) */
445
+ var _newline = '\r\n';
446
+
447
+ /** quote character */
448
+ var _quoteChar = '"';
449
+
450
+ /** escaped quote character, either "" or <config.escapeChar>" */
451
+ var _escapedQuote = _quoteChar + _quoteChar;
452
+
453
+ /** whether to skip empty lines */
454
+ var _skipEmptyLines = false;
455
+
456
+ /** the columns (keys) we expect when we unparse objects */
457
+ var _columns = null;
458
+
459
+ /** whether to prevent outputting cells that can be parsed as formulae by spreadsheet software (Excel and LibreOffice) */
460
+ var _escapeFormulae = false;
461
+
462
+ unpackConfig();
463
+
464
+ var quoteCharRegex = new RegExp(escapeRegExp(_quoteChar), 'g');
465
+
466
+ if (typeof _input === 'string')
467
+ _input = JSON.parse(_input);
468
+
469
+ if (Array.isArray(_input))
470
+ {
471
+ if (!_input.length || Array.isArray(_input[0]))
472
+ return serialize(null, _input, _skipEmptyLines);
473
+ else if (typeof _input[0] === 'object')
474
+ return serialize(_columns || Object.keys(_input[0]), _input, _skipEmptyLines);
475
+ }
476
+ else if (typeof _input === 'object')
477
+ {
478
+ if (typeof _input.data === 'string')
479
+ _input.data = JSON.parse(_input.data);
480
+
481
+ if (Array.isArray(_input.data))
482
+ {
483
+ if (!_input.fields)
484
+ _input.fields = _input.meta && _input.meta.fields || _columns;
485
+
486
+ if (!_input.fields)
487
+ _input.fields = Array.isArray(_input.data[0])
488
+ ? _input.fields
489
+ : typeof _input.data[0] === 'object'
490
+ ? Object.keys(_input.data[0])
491
+ : [];
492
+
493
+ if (!(Array.isArray(_input.data[0])) && typeof _input.data[0] !== 'object')
494
+ _input.data = [_input.data]; // handles input like [1,2,3] or ['asdf']
495
+ }
496
+
497
+ return serialize(_input.fields || [], _input.data || [], _skipEmptyLines);
498
+ }
499
+
500
+ // Default (any valid paths should return before this)
501
+ throw new Error('Unable to serialize unrecognized input');
502
+
503
+
504
+ function unpackConfig()
505
+ {
506
+ if (typeof _config !== 'object')
507
+ return;
508
+
509
+ if (typeof _config.delimiter === 'string'
510
+ && !Papa.BAD_DELIMITERS.filter(function(value) { return _config.delimiter.indexOf(value) !== -1; }).length)
511
+ {
512
+ _delimiter = _config.delimiter;
513
+ }
514
+
515
+ if (typeof _config.quotes === 'boolean'
516
+ || typeof _config.quotes === 'function'
517
+ || Array.isArray(_config.quotes))
518
+ _quotes = _config.quotes;
519
+
520
+ if (typeof _config.skipEmptyLines === 'boolean'
521
+ || typeof _config.skipEmptyLines === 'string')
522
+ _skipEmptyLines = _config.skipEmptyLines;
523
+
524
+ if (typeof _config.newline === 'string')
525
+ _newline = _config.newline;
526
+
527
+ if (typeof _config.quoteChar === 'string')
528
+ _quoteChar = _config.quoteChar;
529
+
530
+ if (typeof _config.header === 'boolean')
531
+ _writeHeader = _config.header;
532
+
533
+ if (Array.isArray(_config.columns)) {
534
+
535
+ if (_config.columns.length === 0) throw new Error('Option columns is empty');
536
+
537
+ _columns = _config.columns;
538
+ }
539
+
540
+ if (_config.escapeChar !== undefined) {
541
+ _escapedQuote = _config.escapeChar + _quoteChar;
542
+ }
543
+
544
+ if (typeof _config.escapeFormulae === 'boolean' || _config.escapeFormulae instanceof RegExp) {
545
+ _escapeFormulae = _config.escapeFormulae instanceof RegExp ? _config.escapeFormulae : /^[=+\-@\t\r].*$/;
546
+ }
547
+ }
548
+
549
+ /** The double for loop that iterates the data and writes out a CSV string including header row */
550
+ function serialize(fields, data, skipEmptyLines)
551
+ {
552
+ var csv = '';
553
+
554
+ if (typeof fields === 'string')
555
+ fields = JSON.parse(fields);
556
+ if (typeof data === 'string')
557
+ data = JSON.parse(data);
558
+
559
+ var hasHeader = Array.isArray(fields) && fields.length > 0;
560
+ var dataKeyedByField = !(Array.isArray(data[0]));
561
+
562
+ // If there a header row, write it first
563
+ if (hasHeader && _writeHeader)
564
+ {
565
+ for (var i = 0; i < fields.length; i++)
566
+ {
567
+ if (i > 0)
568
+ csv += _delimiter;
569
+ csv += safe(fields[i], i);
570
+ }
571
+ if (data.length > 0)
572
+ csv += _newline;
573
+ }
574
+
575
+ // Then write out the data
576
+ for (var row = 0; row < data.length; row++)
577
+ {
578
+ var maxCol = hasHeader ? fields.length : data[row].length;
579
+
580
+ var emptyLine = false;
581
+ var nullLine = hasHeader ? Object.keys(data[row]).length === 0 : data[row].length === 0;
582
+ if (skipEmptyLines && !hasHeader)
583
+ {
584
+ emptyLine = skipEmptyLines === 'greedy' ? data[row].join('').trim() === '' : data[row].length === 1 && data[row][0].length === 0;
585
+ }
586
+ if (skipEmptyLines === 'greedy' && hasHeader) {
587
+ var line = [];
588
+ for (var c = 0; c < maxCol; c++) {
589
+ var cx = dataKeyedByField ? fields[c] : c;
590
+ line.push(data[row][cx]);
591
+ }
592
+ emptyLine = line.join('').trim() === '';
593
+ }
594
+ if (!emptyLine)
595
+ {
596
+ for (var col = 0; col < maxCol; col++)
597
+ {
598
+ if (col > 0 && !nullLine)
599
+ csv += _delimiter;
600
+ var colIdx = hasHeader && dataKeyedByField ? fields[col] : col;
601
+ csv += safe(data[row][colIdx], col);
602
+ }
603
+ if (row < data.length - 1 && (!skipEmptyLines || (maxCol > 0 && !nullLine)))
604
+ {
605
+ csv += _newline;
606
+ }
607
+ }
608
+ }
609
+ return csv;
610
+ }
611
+
612
+ /** Encloses a value around quotes if needed (makes a value safe for CSV insertion) */
613
+ function safe(str, col)
614
+ {
615
+ if (typeof str === 'undefined' || str === null)
616
+ return '';
617
+
618
+ if (str.constructor === Date)
619
+ return JSON.stringify(str).slice(1, 25);
620
+
621
+ var needsQuotes = false;
622
+
623
+ if (_escapeFormulae && typeof str === "string" && _escapeFormulae.test(str)) {
624
+ str = "'" + str;
625
+ needsQuotes = true;
626
+ }
627
+
628
+ var escapedQuoteStr = str.toString().replace(quoteCharRegex, _escapedQuote);
629
+
630
+ needsQuotes = needsQuotes
631
+ || _quotes === true
632
+ || (typeof _quotes === 'function' && _quotes(str, col))
633
+ || (Array.isArray(_quotes) && _quotes[col])
634
+ || hasAny(escapedQuoteStr, Papa.BAD_DELIMITERS)
635
+ || escapedQuoteStr.indexOf(_delimiter) > -1
636
+ || escapedQuoteStr.charAt(0) === ' '
637
+ || escapedQuoteStr.charAt(escapedQuoteStr.length - 1) === ' ';
638
+
639
+ return needsQuotes ? _quoteChar + escapedQuoteStr + _quoteChar : escapedQuoteStr;
640
+ }
641
+
642
+ function hasAny(str, substrings)
643
+ {
644
+ for (var i = 0; i < substrings.length; i++)
645
+ if (str.indexOf(substrings[i]) > -1)
646
+ return true;
647
+ return false;
648
+ }
649
+ }
650
+
651
+ /** ChunkStreamer is the base prototype for various streamer implementations. */
652
+ function ChunkStreamer(config)
653
+ {
654
+ this._handle = null;
655
+ this._finished = false;
656
+ this._completed = false;
657
+ this._halted = false;
658
+ this._input = null;
659
+ this._baseIndex = 0;
660
+ this._partialLine = '';
661
+ this._rowCount = 0;
662
+ this._start = 0;
663
+ this._nextChunk = null;
664
+ this.isFirstChunk = true;
665
+ this._completeResults = {
666
+ data: [],
667
+ errors: [],
668
+ meta: {}
669
+ };
670
+ replaceConfig.call(this, config);
671
+
672
+ this.parseChunk = function(chunk, isFakeChunk)
673
+ {
674
+ // First chunk pre-processing
675
+ if (this.isFirstChunk && isFunction(this._config.beforeFirstChunk))
676
+ {
677
+ var modifiedChunk = this._config.beforeFirstChunk(chunk);
678
+ if (modifiedChunk !== undefined)
679
+ chunk = modifiedChunk;
680
+ }
681
+ this.isFirstChunk = false;
682
+ this._halted = false;
683
+
684
+ // Rejoin the line we likely just split in two by chunking the file
685
+ var aggregate = this._partialLine + chunk;
686
+ this._partialLine = '';
687
+
688
+ var results = this._handle.parse(aggregate, this._baseIndex, !this._finished);
689
+
690
+ if (this._handle.paused() || this._handle.aborted()) {
691
+ this._halted = true;
692
+ return;
693
+ }
694
+
695
+ var lastIndex = results.meta.cursor;
696
+
697
+ if (!this._finished)
698
+ {
699
+ this._partialLine = aggregate.substring(lastIndex - this._baseIndex);
700
+ this._baseIndex = lastIndex;
701
+ }
702
+
703
+ if (results && results.data)
704
+ this._rowCount += results.data.length;
705
+
706
+ var finishedIncludingPreview = this._finished || (this._config.preview && this._rowCount >= this._config.preview);
707
+
708
+ if (IS_PAPA_WORKER)
709
+ {
710
+ global.postMessage({
711
+ results: results,
712
+ workerId: Papa.WORKER_ID,
713
+ finished: finishedIncludingPreview
714
+ });
715
+ }
716
+ else if (isFunction(this._config.chunk) && !isFakeChunk)
717
+ {
718
+ this._config.chunk(results, this._handle);
719
+ if (this._handle.paused() || this._handle.aborted()) {
720
+ this._halted = true;
721
+ return;
722
+ }
723
+ results = undefined;
724
+ this._completeResults = undefined;
725
+ }
726
+
727
+ if (!this._config.step && !this._config.chunk) {
728
+ this._completeResults.data = this._completeResults.data.concat(results.data);
729
+ this._completeResults.errors = this._completeResults.errors.concat(results.errors);
730
+ this._completeResults.meta = results.meta;
731
+ }
732
+
733
+ if (!this._completed && finishedIncludingPreview && isFunction(this._config.complete) && (!results || !results.meta.aborted)) {
734
+ this._config.complete(this._completeResults, this._input);
735
+ this._completed = true;
736
+ }
737
+
738
+ if (!finishedIncludingPreview && (!results || !results.meta.paused))
739
+ this._nextChunk();
740
+
741
+ return results;
742
+ };
743
+
744
+ this._sendError = function(error)
745
+ {
746
+ if (isFunction(this._config.error))
747
+ this._config.error(error);
748
+ else if (IS_PAPA_WORKER && this._config.error)
749
+ {
750
+ global.postMessage({
751
+ workerId: Papa.WORKER_ID,
752
+ error: error,
753
+ finished: false
754
+ });
755
+ }
756
+ };
757
+
758
+ function replaceConfig(config)
759
+ {
760
+ // Deep-copy the config so we can edit it
761
+ var configCopy = copy(config);
762
+ configCopy.chunkSize = parseInt(configCopy.chunkSize); // parseInt VERY important so we don't concatenate strings!
763
+ if (!config.step && !config.chunk)
764
+ configCopy.chunkSize = null; // disable Range header if not streaming; bad values break IIS - see issue #196
765
+ this._handle = new ParserHandle(configCopy);
766
+ this._handle.streamer = this;
767
+ this._config = configCopy; // persist the copy to the caller
768
+ }
769
+ }
770
+
771
+
772
+ function NetworkStreamer(config)
773
+ {
774
+ config = config || {};
775
+ if (!config.chunkSize)
776
+ config.chunkSize = Papa.RemoteChunkSize;
777
+ ChunkStreamer.call(this, config);
778
+
779
+ var xhr;
780
+
781
+ if (IS_WORKER)
782
+ {
783
+ this._nextChunk = function()
784
+ {
785
+ this._readChunk();
786
+ this._chunkLoaded();
787
+ };
788
+ }
789
+ else
790
+ {
791
+ this._nextChunk = function()
792
+ {
793
+ this._readChunk();
794
+ };
795
+ }
796
+
797
+ this.stream = function(url)
798
+ {
799
+ this._input = url;
800
+ this._nextChunk(); // Starts streaming
801
+ };
802
+
803
+ this._readChunk = function()
804
+ {
805
+ if (this._finished)
806
+ {
807
+ this._chunkLoaded();
808
+ return;
809
+ }
810
+
811
+ xhr = new XMLHttpRequest();
812
+
813
+ if (this._config.withCredentials)
814
+ {
815
+ xhr.withCredentials = this._config.withCredentials;
816
+ }
817
+
818
+ if (!IS_WORKER)
819
+ {
820
+ xhr.onload = bindFunction(this._chunkLoaded, this);
821
+ xhr.onerror = bindFunction(this._chunkError, this);
822
+ }
823
+
824
+ xhr.open(this._config.downloadRequestBody ? 'POST' : 'GET', this._input, !IS_WORKER);
825
+ // Headers can only be set when once the request state is OPENED
826
+ if (this._config.downloadRequestHeaders)
827
+ {
828
+ var headers = this._config.downloadRequestHeaders;
829
+
830
+ for (var headerName in headers)
831
+ {
832
+ xhr.setRequestHeader(headerName, headers[headerName]);
833
+ }
834
+ }
835
+
836
+ if (this._config.chunkSize)
837
+ {
838
+ var end = this._start + this._config.chunkSize - 1; // minus one because byte range is inclusive
839
+ xhr.setRequestHeader('Range', 'bytes=' + this._start + '-' + end);
840
+ }
841
+
842
+ try {
843
+ xhr.send(this._config.downloadRequestBody);
844
+ }
845
+ catch (err) {
846
+ this._chunkError(err.message);
847
+ }
848
+
849
+ if (IS_WORKER && xhr.status === 0)
850
+ this._chunkError();
851
+ };
852
+
853
+ this._chunkLoaded = function()
854
+ {
855
+ if (xhr.readyState !== 4)
856
+ return;
857
+
858
+ if (xhr.status < 200 || xhr.status >= 400)
859
+ {
860
+ this._chunkError();
861
+ return;
862
+ }
863
+
864
+ // Use chunckSize as it may be a diference on reponse lentgh due to characters with more than 1 byte
865
+ this._start += this._config.chunkSize ? this._config.chunkSize : xhr.responseText.length;
866
+ this._finished = !this._config.chunkSize || this._start >= getFileSize(xhr);
867
+ this.parseChunk(xhr.responseText);
868
+ };
869
+
870
+ this._chunkError = function(errorMessage)
871
+ {
872
+ var errorText = xhr.statusText || errorMessage;
873
+ this._sendError(new Error(errorText));
874
+ };
875
+
876
+ function getFileSize(xhr)
877
+ {
878
+ var contentRange = xhr.getResponseHeader('Content-Range');
879
+ if (contentRange === null) { // no content range, then finish!
880
+ return -1;
881
+ }
882
+ return parseInt(contentRange.substring(contentRange.lastIndexOf('/') + 1));
883
+ }
884
+ }
885
+ NetworkStreamer.prototype = Object.create(ChunkStreamer.prototype);
886
+ NetworkStreamer.prototype.constructor = NetworkStreamer;
887
+
888
+
889
+ function FileStreamer(config)
890
+ {
891
+ config = config || {};
892
+ if (!config.chunkSize)
893
+ config.chunkSize = Papa.LocalChunkSize;
894
+ ChunkStreamer.call(this, config);
895
+
896
+ var reader, slice;
897
+
898
+ // FileReader is better than FileReaderSync (even in worker) - see http://stackoverflow.com/q/24708649/1048862
899
+ // But Firefox is a pill, too - see issue #76: https://github.com/mholt/PapaParse/issues/76
900
+ var usingAsyncReader = typeof FileReader !== 'undefined'; // Safari doesn't consider it a function - see issue #105
901
+
902
+ this.stream = function(file)
903
+ {
904
+ this._input = file;
905
+ slice = file.slice || file.webkitSlice || file.mozSlice;
906
+
907
+ if (usingAsyncReader)
908
+ {
909
+ reader = new FileReader(); // Preferred method of reading files, even in workers
910
+ reader.onload = bindFunction(this._chunkLoaded, this);
911
+ reader.onerror = bindFunction(this._chunkError, this);
912
+ }
913
+ else
914
+ reader = new FileReaderSync(); // Hack for running in a web worker in Firefox
915
+
916
+ this._nextChunk(); // Starts streaming
917
+ };
918
+
919
+ this._nextChunk = function()
920
+ {
921
+ if (!this._finished && (!this._config.preview || this._rowCount < this._config.preview))
922
+ this._readChunk();
923
+ };
924
+
925
+ this._readChunk = function()
926
+ {
927
+ var input = this._input;
928
+ if (this._config.chunkSize)
929
+ {
930
+ var end = Math.min(this._start + this._config.chunkSize, this._input.size);
931
+ input = slice.call(input, this._start, end);
932
+ }
933
+ var txt = reader.readAsText(input, this._config.encoding);
934
+ if (!usingAsyncReader)
935
+ this._chunkLoaded({ target: { result: txt } }); // mimic the async signature
936
+ };
937
+
938
+ this._chunkLoaded = function(event)
939
+ {
940
+ // Very important to increment start each time before handling results
941
+ this._start += this._config.chunkSize;
942
+ this._finished = !this._config.chunkSize || this._start >= this._input.size;
943
+ this.parseChunk(event.target.result);
944
+ };
945
+
946
+ this._chunkError = function()
947
+ {
948
+ this._sendError(reader.error);
949
+ };
950
+
951
+ }
952
+ FileStreamer.prototype = Object.create(ChunkStreamer.prototype);
953
+ FileStreamer.prototype.constructor = FileStreamer;
954
+
955
+
956
+ function StringStreamer(config)
957
+ {
958
+ config = config || {};
959
+ ChunkStreamer.call(this, config);
960
+
961
+ var remaining;
962
+ this.stream = function(s)
963
+ {
964
+ remaining = s;
965
+ return this._nextChunk();
966
+ };
967
+ this._nextChunk = function()
968
+ {
969
+ if (this._finished) return;
970
+ var size = this._config.chunkSize;
971
+ var chunk;
972
+ if(size) {
973
+ chunk = remaining.substring(0, size);
974
+ remaining = remaining.substring(size);
975
+ } else {
976
+ chunk = remaining;
977
+ remaining = '';
978
+ }
979
+ this._finished = !remaining;
980
+ return this.parseChunk(chunk);
981
+ };
982
+ }
983
+ StringStreamer.prototype = Object.create(StringStreamer.prototype);
984
+ StringStreamer.prototype.constructor = StringStreamer;
985
+
986
+
987
+ function ReadableStreamStreamer(config)
988
+ {
989
+ config = config || {};
990
+
991
+ ChunkStreamer.call(this, config);
992
+
993
+ var queue = [];
994
+ var parseOnData = true;
995
+ var streamHasEnded = false;
996
+
997
+ this.pause = function()
998
+ {
999
+ ChunkStreamer.prototype.pause.apply(this, arguments);
1000
+ this._input.pause();
1001
+ };
1002
+
1003
+ this.resume = function()
1004
+ {
1005
+ ChunkStreamer.prototype.resume.apply(this, arguments);
1006
+ this._input.resume();
1007
+ };
1008
+
1009
+ this.stream = function(stream)
1010
+ {
1011
+ this._input = stream;
1012
+
1013
+ this._input.on('data', this._streamData);
1014
+ this._input.on('end', this._streamEnd);
1015
+ this._input.on('error', this._streamError);
1016
+ };
1017
+
1018
+ this._checkIsFinished = function()
1019
+ {
1020
+ if (streamHasEnded && queue.length === 1) {
1021
+ this._finished = true;
1022
+ }
1023
+ };
1024
+
1025
+ this._nextChunk = function()
1026
+ {
1027
+ this._checkIsFinished();
1028
+ if (queue.length)
1029
+ {
1030
+ this.parseChunk(queue.shift());
1031
+ }
1032
+ else
1033
+ {
1034
+ parseOnData = true;
1035
+ }
1036
+ };
1037
+
1038
+ this._streamData = bindFunction(function(chunk)
1039
+ {
1040
+ try
1041
+ {
1042
+ queue.push(typeof chunk === 'string' ? chunk : chunk.toString(this._config.encoding));
1043
+
1044
+ if (parseOnData)
1045
+ {
1046
+ parseOnData = false;
1047
+ this._checkIsFinished();
1048
+ this.parseChunk(queue.shift());
1049
+ }
1050
+ }
1051
+ catch (error)
1052
+ {
1053
+ this._streamError(error);
1054
+ }
1055
+ }, this);
1056
+
1057
+ this._streamError = bindFunction(function(error)
1058
+ {
1059
+ this._streamCleanUp();
1060
+ this._sendError(error);
1061
+ }, this);
1062
+
1063
+ this._streamEnd = bindFunction(function()
1064
+ {
1065
+ this._streamCleanUp();
1066
+ streamHasEnded = true;
1067
+ this._streamData('');
1068
+ }, this);
1069
+
1070
+ this._streamCleanUp = bindFunction(function()
1071
+ {
1072
+ this._input.removeListener('data', this._streamData);
1073
+ this._input.removeListener('end', this._streamEnd);
1074
+ this._input.removeListener('error', this._streamError);
1075
+ }, this);
1076
+ }
1077
+ ReadableStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
1078
+ ReadableStreamStreamer.prototype.constructor = ReadableStreamStreamer;
1079
+
1080
+
1081
+ function DuplexStreamStreamer(_config) {
1082
+ var Duplex = require$$0__default["default"].Duplex;
1083
+ var config = copy(_config);
1084
+ var parseOnWrite = true;
1085
+ var writeStreamHasFinished = false;
1086
+ var parseCallbackQueue = [];
1087
+ var stream = null;
1088
+
1089
+ this._onCsvData = function(results)
1090
+ {
1091
+ var data = results.data;
1092
+ if (!stream.push(data) && !this._handle.paused()) {
1093
+ // the writeable consumer buffer has filled up
1094
+ // so we need to pause until more items
1095
+ // can be processed
1096
+ this._handle.pause();
1097
+ }
1098
+ };
1099
+
1100
+ this._onCsvComplete = function()
1101
+ {
1102
+ // node will finish the read stream when
1103
+ // null is pushed
1104
+ stream.push(null);
1105
+ };
1106
+
1107
+ config.step = bindFunction(this._onCsvData, this);
1108
+ config.complete = bindFunction(this._onCsvComplete, this);
1109
+ ChunkStreamer.call(this, config);
1110
+
1111
+ this._nextChunk = function()
1112
+ {
1113
+ if (writeStreamHasFinished && parseCallbackQueue.length === 1) {
1114
+ this._finished = true;
1115
+ }
1116
+ if (parseCallbackQueue.length) {
1117
+ parseCallbackQueue.shift()();
1118
+ } else {
1119
+ parseOnWrite = true;
1120
+ }
1121
+ };
1122
+
1123
+ this._addToParseQueue = function(chunk, callback)
1124
+ {
1125
+ // add to queue so that we can indicate
1126
+ // completion via callback
1127
+ // node will automatically pause the incoming stream
1128
+ // when too many items have been added without their
1129
+ // callback being invoked
1130
+ parseCallbackQueue.push(bindFunction(function() {
1131
+ this.parseChunk(typeof chunk === 'string' ? chunk : chunk.toString(config.encoding));
1132
+ if (isFunction(callback)) {
1133
+ return callback();
1134
+ }
1135
+ }, this));
1136
+ if (parseOnWrite) {
1137
+ parseOnWrite = false;
1138
+ this._nextChunk();
1139
+ }
1140
+ };
1141
+
1142
+ this._onRead = function()
1143
+ {
1144
+ if (this._handle.paused()) {
1145
+ // the writeable consumer can handle more data
1146
+ // so resume the chunk parsing
1147
+ this._handle.resume();
1148
+ }
1149
+ };
1150
+
1151
+ this._onWrite = function(chunk, encoding, callback)
1152
+ {
1153
+ this._addToParseQueue(chunk, callback);
1154
+ };
1155
+
1156
+ this._onWriteComplete = function()
1157
+ {
1158
+ writeStreamHasFinished = true;
1159
+ // have to write empty string
1160
+ // so parser knows its done
1161
+ this._addToParseQueue('');
1162
+ };
1163
+
1164
+ this.getStream = function()
1165
+ {
1166
+ return stream;
1167
+ };
1168
+ stream = new Duplex({
1169
+ readableObjectMode: true,
1170
+ decodeStrings: false,
1171
+ read: bindFunction(this._onRead, this),
1172
+ write: bindFunction(this._onWrite, this)
1173
+ });
1174
+ stream.once('finish', bindFunction(this._onWriteComplete, this));
1175
+ }
1176
+ if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
1177
+ DuplexStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
1178
+ DuplexStreamStreamer.prototype.constructor = DuplexStreamStreamer;
1179
+ }
1180
+
1181
+
1182
+ // Use one ParserHandle per entire CSV file or string
1183
+ function ParserHandle(_config)
1184
+ {
1185
+ // One goal is to minimize the use of regular expressions...
1186
+ var MAX_FLOAT = Math.pow(2, 53);
1187
+ var MIN_FLOAT = -MAX_FLOAT;
1188
+ var FLOAT = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/;
1189
+ var ISO_DATE = /^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/;
1190
+ var self = this;
1191
+ var _stepCounter = 0; // Number of times step was called (number of rows parsed)
1192
+ var _rowCounter = 0; // Number of rows that have been parsed so far
1193
+ var _input; // The input being parsed
1194
+ var _parser; // The core parser being used
1195
+ var _paused = false; // Whether we are paused or not
1196
+ var _aborted = false; // Whether the parser has aborted or not
1197
+ var _delimiterError; // Temporary state between delimiter detection and processing results
1198
+ var _fields = []; // Fields are from the header row of the input, if there is one
1199
+ var _results = { // The last results returned from the parser
1200
+ data: [],
1201
+ errors: [],
1202
+ meta: {}
1203
+ };
1204
+
1205
+ if (isFunction(_config.step))
1206
+ {
1207
+ var userStep = _config.step;
1208
+ _config.step = function(results)
1209
+ {
1210
+ _results = results;
1211
+
1212
+ if (needsHeaderRow())
1213
+ processResults();
1214
+ else // only call user's step function after header row
1215
+ {
1216
+ processResults();
1217
+
1218
+ // It's possbile that this line was empty and there's no row here after all
1219
+ if (_results.data.length === 0)
1220
+ return;
1221
+
1222
+ _stepCounter += results.data.length;
1223
+ if (_config.preview && _stepCounter > _config.preview)
1224
+ _parser.abort();
1225
+ else {
1226
+ _results.data = _results.data[0];
1227
+ userStep(_results, self);
1228
+ }
1229
+ }
1230
+ };
1231
+ }
1232
+
1233
+ /**
1234
+ * Parses input. Most users won't need, and shouldn't mess with, the baseIndex
1235
+ * and ignoreLastRow parameters. They are used by streamers (wrapper functions)
1236
+ * when an input comes in multiple chunks, like from a file.
1237
+ */
1238
+ this.parse = function(input, baseIndex, ignoreLastRow)
1239
+ {
1240
+ var quoteChar = _config.quoteChar || '"';
1241
+ if (!_config.newline)
1242
+ _config.newline = guessLineEndings(input, quoteChar);
1243
+
1244
+ _delimiterError = false;
1245
+ if (!_config.delimiter)
1246
+ {
1247
+ var delimGuess = guessDelimiter(input, _config.newline, _config.skipEmptyLines, _config.comments, _config.delimitersToGuess);
1248
+ if (delimGuess.successful)
1249
+ _config.delimiter = delimGuess.bestDelimiter;
1250
+ else
1251
+ {
1252
+ _delimiterError = true; // add error after parsing (otherwise it would be overwritten)
1253
+ _config.delimiter = Papa.DefaultDelimiter;
1254
+ }
1255
+ _results.meta.delimiter = _config.delimiter;
1256
+ }
1257
+ else if(isFunction(_config.delimiter))
1258
+ {
1259
+ _config.delimiter = _config.delimiter(input);
1260
+ _results.meta.delimiter = _config.delimiter;
1261
+ }
1262
+
1263
+ var parserConfig = copy(_config);
1264
+ if (_config.preview && _config.header)
1265
+ parserConfig.preview++; // to compensate for header row
1266
+
1267
+ _input = input;
1268
+ _parser = new Parser(parserConfig);
1269
+ _results = _parser.parse(_input, baseIndex, ignoreLastRow);
1270
+ processResults();
1271
+ return _paused ? { meta: { paused: true } } : (_results || { meta: { paused: false } });
1272
+ };
1273
+
1274
+ this.paused = function()
1275
+ {
1276
+ return _paused;
1277
+ };
1278
+
1279
+ this.pause = function()
1280
+ {
1281
+ _paused = true;
1282
+ _parser.abort();
1283
+
1284
+ // If it is streaming via "chunking", the reader will start appending correctly already so no need to substring,
1285
+ // otherwise we can get duplicate content within a row
1286
+ _input = isFunction(_config.chunk) ? "" : _input.substring(_parser.getCharIndex());
1287
+ };
1288
+
1289
+ this.resume = function()
1290
+ {
1291
+ if(self.streamer._halted) {
1292
+ _paused = false;
1293
+ self.streamer.parseChunk(_input, true);
1294
+ } else {
1295
+ // Bugfix: #636 In case the processing hasn't halted yet
1296
+ // wait for it to halt in order to resume
1297
+ setTimeout(self.resume, 3);
1298
+ }
1299
+ };
1300
+
1301
+ this.aborted = function()
1302
+ {
1303
+ return _aborted;
1304
+ };
1305
+
1306
+ this.abort = function()
1307
+ {
1308
+ _aborted = true;
1309
+ _parser.abort();
1310
+ _results.meta.aborted = true;
1311
+ if (isFunction(_config.complete))
1312
+ _config.complete(_results);
1313
+ _input = '';
1314
+ };
1315
+
1316
+ function testEmptyLine(s) {
1317
+ return _config.skipEmptyLines === 'greedy' ? s.join('').trim() === '' : s.length === 1 && s[0].length === 0;
1318
+ }
1319
+
1320
+ function testFloat(s) {
1321
+ if (FLOAT.test(s)) {
1322
+ var floatValue = parseFloat(s);
1323
+ if (floatValue > MIN_FLOAT && floatValue < MAX_FLOAT) {
1324
+ return true;
1325
+ }
1326
+ }
1327
+ return false;
1328
+ }
1329
+
1330
+ function processResults()
1331
+ {
1332
+ if (_results && _delimiterError)
1333
+ {
1334
+ addError('Delimiter', 'UndetectableDelimiter', 'Unable to auto-detect delimiting character; defaulted to \'' + Papa.DefaultDelimiter + '\'');
1335
+ _delimiterError = false;
1336
+ }
1337
+
1338
+ if (_config.skipEmptyLines)
1339
+ {
1340
+ _results.data = _results.data.filter(function(d) {
1341
+ return !testEmptyLine(d);
1342
+ });
1343
+ }
1344
+
1345
+ if (needsHeaderRow())
1346
+ fillHeaderFields();
1347
+
1348
+ return applyHeaderAndDynamicTypingAndTransformation();
1349
+ }
1350
+
1351
+ function needsHeaderRow()
1352
+ {
1353
+ return _config.header && _fields.length === 0;
1354
+ }
1355
+
1356
+ function fillHeaderFields()
1357
+ {
1358
+ if (!_results)
1359
+ return;
1360
+
1361
+ function addHeader(header, i)
1362
+ {
1363
+ if (isFunction(_config.transformHeader))
1364
+ header = _config.transformHeader(header, i);
1365
+
1366
+ _fields.push(header);
1367
+ }
1368
+
1369
+ if (Array.isArray(_results.data[0]))
1370
+ {
1371
+ for (var i = 0; needsHeaderRow() && i < _results.data.length; i++)
1372
+ _results.data[i].forEach(addHeader);
1373
+
1374
+ _results.data.splice(0, 1);
1375
+ }
1376
+ // if _results.data[0] is not an array, we are in a step where _results.data is the row.
1377
+ else
1378
+ _results.data.forEach(addHeader);
1379
+ }
1380
+
1381
+ function shouldApplyDynamicTyping(field) {
1382
+ // Cache function values to avoid calling it for each row
1383
+ if (_config.dynamicTypingFunction && _config.dynamicTyping[field] === undefined) {
1384
+ _config.dynamicTyping[field] = _config.dynamicTypingFunction(field);
1385
+ }
1386
+ return (_config.dynamicTyping[field] || _config.dynamicTyping) === true;
1387
+ }
1388
+
1389
+ function parseDynamic(field, value)
1390
+ {
1391
+ if (shouldApplyDynamicTyping(field))
1392
+ {
1393
+ if (value === 'true' || value === 'TRUE')
1394
+ return true;
1395
+ else if (value === 'false' || value === 'FALSE')
1396
+ return false;
1397
+ else if (testFloat(value))
1398
+ return parseFloat(value);
1399
+ else if (ISO_DATE.test(value))
1400
+ return new Date(value);
1401
+ else
1402
+ return (value === '' ? null : value);
1403
+ }
1404
+ return value;
1405
+ }
1406
+
1407
+ function applyHeaderAndDynamicTypingAndTransformation()
1408
+ {
1409
+ if (!_results || (!_config.header && !_config.dynamicTyping && !_config.transform))
1410
+ return _results;
1411
+
1412
+ function processRow(rowSource, i)
1413
+ {
1414
+ var row = _config.header ? {} : [];
1415
+
1416
+ var j;
1417
+ for (j = 0; j < rowSource.length; j++)
1418
+ {
1419
+ var field = j;
1420
+ var value = rowSource[j];
1421
+
1422
+ if (_config.header)
1423
+ field = j >= _fields.length ? '__parsed_extra' : _fields[j];
1424
+
1425
+ if (_config.transform)
1426
+ value = _config.transform(value,field);
1427
+
1428
+ value = parseDynamic(field, value);
1429
+
1430
+ if (field === '__parsed_extra')
1431
+ {
1432
+ row[field] = row[field] || [];
1433
+ row[field].push(value);
1434
+ }
1435
+ else
1436
+ row[field] = value;
1437
+ }
1438
+
1439
+
1440
+ if (_config.header)
1441
+ {
1442
+ if (j > _fields.length)
1443
+ addError('FieldMismatch', 'TooManyFields', 'Too many fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1444
+ else if (j < _fields.length)
1445
+ addError('FieldMismatch', 'TooFewFields', 'Too few fields: expected ' + _fields.length + ' fields but parsed ' + j, _rowCounter + i);
1446
+ }
1447
+
1448
+ return row;
1449
+ }
1450
+
1451
+ var incrementBy = 1;
1452
+ if (!_results.data.length || Array.isArray(_results.data[0]))
1453
+ {
1454
+ _results.data = _results.data.map(processRow);
1455
+ incrementBy = _results.data.length;
1456
+ }
1457
+ else
1458
+ _results.data = processRow(_results.data, 0);
1459
+
1460
+
1461
+ if (_config.header && _results.meta)
1462
+ _results.meta.fields = _fields;
1463
+
1464
+ _rowCounter += incrementBy;
1465
+ return _results;
1466
+ }
1467
+
1468
+ function guessDelimiter(input, newline, skipEmptyLines, comments, delimitersToGuess) {
1469
+ var bestDelim, bestDelta, fieldCountPrevRow, maxFieldCount;
1470
+
1471
+ delimitersToGuess = delimitersToGuess || [',', '\t', '|', ';', Papa.RECORD_SEP, Papa.UNIT_SEP];
1472
+
1473
+ for (var i = 0; i < delimitersToGuess.length; i++) {
1474
+ var delim = delimitersToGuess[i];
1475
+ var delta = 0, avgFieldCount = 0, emptyLinesCount = 0;
1476
+ fieldCountPrevRow = undefined;
1477
+
1478
+ var preview = new Parser({
1479
+ comments: comments,
1480
+ delimiter: delim,
1481
+ newline: newline,
1482
+ preview: 10
1483
+ }).parse(input);
1484
+
1485
+ for (var j = 0; j < preview.data.length; j++) {
1486
+ if (skipEmptyLines && testEmptyLine(preview.data[j])) {
1487
+ emptyLinesCount++;
1488
+ continue;
1489
+ }
1490
+ var fieldCount = preview.data[j].length;
1491
+ avgFieldCount += fieldCount;
1492
+
1493
+ if (typeof fieldCountPrevRow === 'undefined') {
1494
+ fieldCountPrevRow = fieldCount;
1495
+ continue;
1496
+ }
1497
+ else if (fieldCount > 0) {
1498
+ delta += Math.abs(fieldCount - fieldCountPrevRow);
1499
+ fieldCountPrevRow = fieldCount;
1500
+ }
1501
+ }
1502
+
1503
+ if (preview.data.length > 0)
1504
+ avgFieldCount /= (preview.data.length - emptyLinesCount);
1505
+
1506
+ if ((typeof bestDelta === 'undefined' || delta <= bestDelta)
1507
+ && (typeof maxFieldCount === 'undefined' || avgFieldCount > maxFieldCount) && avgFieldCount > 1.99) {
1508
+ bestDelta = delta;
1509
+ bestDelim = delim;
1510
+ maxFieldCount = avgFieldCount;
1511
+ }
1512
+ }
1513
+
1514
+ _config.delimiter = bestDelim;
1515
+
1516
+ return {
1517
+ successful: !!bestDelim,
1518
+ bestDelimiter: bestDelim
1519
+ };
1520
+ }
1521
+
1522
+ function guessLineEndings(input, quoteChar)
1523
+ {
1524
+ input = input.substring(0, 1024 * 1024); // max length 1 MB
1525
+ // Replace all the text inside quotes
1526
+ var re = new RegExp(escapeRegExp(quoteChar) + '([^]*?)' + escapeRegExp(quoteChar), 'gm');
1527
+ input = input.replace(re, '');
1528
+
1529
+ var r = input.split('\r');
1530
+
1531
+ var n = input.split('\n');
1532
+
1533
+ var nAppearsFirst = (n.length > 1 && n[0].length < r[0].length);
1534
+
1535
+ if (r.length === 1 || nAppearsFirst)
1536
+ return '\n';
1537
+
1538
+ var numWithN = 0;
1539
+ for (var i = 0; i < r.length; i++)
1540
+ {
1541
+ if (r[i][0] === '\n')
1542
+ numWithN++;
1543
+ }
1544
+
1545
+ return numWithN >= r.length / 2 ? '\r\n' : '\r';
1546
+ }
1547
+
1548
+ function addError(type, code, msg, row)
1549
+ {
1550
+ var error = {
1551
+ type: type,
1552
+ code: code,
1553
+ message: msg
1554
+ };
1555
+ if(row !== undefined) {
1556
+ error.row = row;
1557
+ }
1558
+ _results.errors.push(error);
1559
+ }
1560
+ }
1561
+
1562
+ /** https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions */
1563
+ function escapeRegExp(string)
1564
+ {
1565
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
1566
+ }
1567
+
1568
+ /** The core parser implements speedy and correct CSV parsing */
1569
+ function Parser(config)
1570
+ {
1571
+ // Unpack the config object
1572
+ config = config || {};
1573
+ var delim = config.delimiter;
1574
+ var newline = config.newline;
1575
+ var comments = config.comments;
1576
+ var step = config.step;
1577
+ var preview = config.preview;
1578
+ var fastMode = config.fastMode;
1579
+ var quoteChar;
1580
+ if (config.quoteChar === undefined || config.quoteChar === null) {
1581
+ quoteChar = '"';
1582
+ } else {
1583
+ quoteChar = config.quoteChar;
1584
+ }
1585
+ var escapeChar = quoteChar;
1586
+ if (config.escapeChar !== undefined) {
1587
+ escapeChar = config.escapeChar;
1588
+ }
1589
+
1590
+ // Delimiter must be valid
1591
+ if (typeof delim !== 'string'
1592
+ || Papa.BAD_DELIMITERS.indexOf(delim) > -1)
1593
+ delim = ',';
1594
+
1595
+ // Comment character must be valid
1596
+ if (comments === delim)
1597
+ throw new Error('Comment character same as delimiter');
1598
+ else if (comments === true)
1599
+ comments = '#';
1600
+ else if (typeof comments !== 'string'
1601
+ || Papa.BAD_DELIMITERS.indexOf(comments) > -1)
1602
+ comments = false;
1603
+
1604
+ // Newline must be valid: \r, \n, or \r\n
1605
+ if (newline !== '\n' && newline !== '\r' && newline !== '\r\n')
1606
+ newline = '\n';
1607
+
1608
+ // We're gonna need these at the Parser scope
1609
+ var cursor = 0;
1610
+ var aborted = false;
1611
+
1612
+ this.parse = function(input, baseIndex, ignoreLastRow)
1613
+ {
1614
+ // For some reason, in Chrome, this speeds things up (!?)
1615
+ if (typeof input !== 'string')
1616
+ throw new Error('Input must be a string');
1617
+
1618
+ // We don't need to compute some of these every time parse() is called,
1619
+ // but having them in a more local scope seems to perform better
1620
+ var inputLen = input.length,
1621
+ delimLen = delim.length,
1622
+ newlineLen = newline.length,
1623
+ commentsLen = comments.length;
1624
+ var stepIsFunction = isFunction(step);
1625
+
1626
+ // Establish starting state
1627
+ cursor = 0;
1628
+ var data = [], errors = [], row = [], lastCursor = 0;
1629
+
1630
+ if (!input)
1631
+ return returnable();
1632
+
1633
+ // Rename headers if there are duplicates
1634
+ if (config.header && !baseIndex)
1635
+ {
1636
+ var firstLine = input.split(newline)[0];
1637
+ var headers = firstLine.split(delim);
1638
+ var separator = '_';
1639
+ var headerMap = [];
1640
+ var headerCount = {};
1641
+ var duplicateHeaders = false;
1642
+
1643
+ for (var j in headers) {
1644
+ var header = headers[j];
1645
+ if (isFunction(config.transformHeader))
1646
+ header = config.transformHeader(header, j);
1647
+ var headerName = header;
1648
+
1649
+ var count = headerCount[header] || 0;
1650
+ if (count > 0) {
1651
+ duplicateHeaders = true;
1652
+ headerName = header + separator + count;
1653
+ }
1654
+ headerCount[header] = count + 1;
1655
+ // In case it already exists, we add more separtors
1656
+ while (headerMap.includes(headerName)) {
1657
+ headerName = headerName + separator + count;
1658
+ }
1659
+ headerMap.push(headerName);
1660
+ }
1661
+ if (duplicateHeaders) {
1662
+ var editedInput = input.split(newline);
1663
+ editedInput[0] = headerMap.join(delim);
1664
+ input = editedInput.join(newline);
1665
+ }
1666
+ }
1667
+ if (fastMode || (fastMode !== false && input.indexOf(quoteChar) === -1))
1668
+ {
1669
+ var rows = input.split(newline);
1670
+ for (var i = 0; i < rows.length; i++)
1671
+ {
1672
+ row = rows[i];
1673
+ cursor += row.length;
1674
+ if (i !== rows.length - 1)
1675
+ cursor += newline.length;
1676
+ else if (ignoreLastRow)
1677
+ return returnable();
1678
+ if (comments && row.substring(0, commentsLen) === comments)
1679
+ continue;
1680
+ if (stepIsFunction)
1681
+ {
1682
+ data = [];
1683
+ pushRow(row.split(delim));
1684
+ doStep();
1685
+ if (aborted)
1686
+ return returnable();
1687
+ }
1688
+ else
1689
+ pushRow(row.split(delim));
1690
+ if (preview && i >= preview)
1691
+ {
1692
+ data = data.slice(0, preview);
1693
+ return returnable(true);
1694
+ }
1695
+ }
1696
+ return returnable();
1697
+ }
1698
+
1699
+ var nextDelim = input.indexOf(delim, cursor);
1700
+ var nextNewline = input.indexOf(newline, cursor);
1701
+ var quoteCharRegex = new RegExp(escapeRegExp(escapeChar) + escapeRegExp(quoteChar), 'g');
1702
+ var quoteSearch = input.indexOf(quoteChar, cursor);
1703
+
1704
+ // Parser loop
1705
+ for (;;)
1706
+ {
1707
+ // Field has opening quote
1708
+ if (input[cursor] === quoteChar)
1709
+ {
1710
+ // Start our search for the closing quote where the cursor is
1711
+ quoteSearch = cursor;
1712
+
1713
+ // Skip the opening quote
1714
+ cursor++;
1715
+
1716
+ for (;;)
1717
+ {
1718
+ // Find closing quote
1719
+ quoteSearch = input.indexOf(quoteChar, quoteSearch + 1);
1720
+
1721
+ //No other quotes are found - no other delimiters
1722
+ if (quoteSearch === -1)
1723
+ {
1724
+ if (!ignoreLastRow) {
1725
+ // No closing quote... what a pity
1726
+ errors.push({
1727
+ type: 'Quotes',
1728
+ code: 'MissingQuotes',
1729
+ message: 'Quoted field unterminated',
1730
+ row: data.length, // row has yet to be inserted
1731
+ index: cursor
1732
+ });
1733
+ }
1734
+ return finish();
1735
+ }
1736
+
1737
+ // Closing quote at EOF
1738
+ if (quoteSearch === inputLen - 1)
1739
+ {
1740
+ var value = input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar);
1741
+ return finish(value);
1742
+ }
1743
+
1744
+ // If this quote is escaped, it's part of the data; skip it
1745
+ // If the quote character is the escape character, then check if the next character is the escape character
1746
+ if (quoteChar === escapeChar && input[quoteSearch + 1] === escapeChar)
1747
+ {
1748
+ quoteSearch++;
1749
+ continue;
1750
+ }
1751
+
1752
+ // If the quote character is not the escape character, then check if the previous character was the escape character
1753
+ if (quoteChar !== escapeChar && quoteSearch !== 0 && input[quoteSearch - 1] === escapeChar)
1754
+ {
1755
+ continue;
1756
+ }
1757
+
1758
+ if(nextDelim !== -1 && nextDelim < (quoteSearch + 1)) {
1759
+ nextDelim = input.indexOf(delim, (quoteSearch + 1));
1760
+ }
1761
+ if(nextNewline !== -1 && nextNewline < (quoteSearch + 1)) {
1762
+ nextNewline = input.indexOf(newline, (quoteSearch + 1));
1763
+ }
1764
+ // Check up to nextDelim or nextNewline, whichever is closest
1765
+ var checkUpTo = nextNewline === -1 ? nextDelim : Math.min(nextDelim, nextNewline);
1766
+ var spacesBetweenQuoteAndDelimiter = extraSpaces(checkUpTo);
1767
+
1768
+ // Closing quote followed by delimiter or 'unnecessary spaces + delimiter'
1769
+ if (input.substr(quoteSearch + 1 + spacesBetweenQuoteAndDelimiter, delimLen) === delim)
1770
+ {
1771
+ row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
1772
+ cursor = quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen;
1773
+
1774
+ // If char after following delimiter is not quoteChar, we find next quote char position
1775
+ if (input[quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen] !== quoteChar)
1776
+ {
1777
+ quoteSearch = input.indexOf(quoteChar, cursor);
1778
+ }
1779
+ nextDelim = input.indexOf(delim, cursor);
1780
+ nextNewline = input.indexOf(newline, cursor);
1781
+ break;
1782
+ }
1783
+
1784
+ var spacesBetweenQuoteAndNewLine = extraSpaces(nextNewline);
1785
+
1786
+ // Closing quote followed by newline or 'unnecessary spaces + newLine'
1787
+ if (input.substring(quoteSearch + 1 + spacesBetweenQuoteAndNewLine, quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen) === newline)
1788
+ {
1789
+ row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
1790
+ saveRow(quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen);
1791
+ nextDelim = input.indexOf(delim, cursor); // because we may have skipped the nextDelim in the quoted field
1792
+ quoteSearch = input.indexOf(quoteChar, cursor); // we search for first quote in next line
1793
+
1794
+ if (stepIsFunction)
1795
+ {
1796
+ doStep();
1797
+ if (aborted)
1798
+ return returnable();
1799
+ }
1800
+
1801
+ if (preview && data.length >= preview)
1802
+ return returnable(true);
1803
+
1804
+ break;
1805
+ }
1806
+
1807
+
1808
+ // Checks for valid closing quotes are complete (escaped quotes or quote followed by EOF/delimiter/newline) -- assume these quotes are part of an invalid text string
1809
+ errors.push({
1810
+ type: 'Quotes',
1811
+ code: 'InvalidQuotes',
1812
+ message: 'Trailing quote on quoted field is malformed',
1813
+ row: data.length, // row has yet to be inserted
1814
+ index: cursor
1815
+ });
1816
+
1817
+ quoteSearch++;
1818
+ continue;
1819
+
1820
+ }
1821
+
1822
+ continue;
1823
+ }
1824
+
1825
+ // Comment found at start of new line
1826
+ if (comments && row.length === 0 && input.substring(cursor, cursor + commentsLen) === comments)
1827
+ {
1828
+ if (nextNewline === -1) // Comment ends at EOF
1829
+ return returnable();
1830
+ cursor = nextNewline + newlineLen;
1831
+ nextNewline = input.indexOf(newline, cursor);
1832
+ nextDelim = input.indexOf(delim, cursor);
1833
+ continue;
1834
+ }
1835
+
1836
+ // Next delimiter comes before next newline, so we've reached end of field
1837
+ if (nextDelim !== -1 && (nextDelim < nextNewline || nextNewline === -1))
1838
+ {
1839
+ row.push(input.substring(cursor, nextDelim));
1840
+ cursor = nextDelim + delimLen;
1841
+ // we look for next delimiter char
1842
+ nextDelim = input.indexOf(delim, cursor);
1843
+ continue;
1844
+ }
1845
+
1846
+ // End of row
1847
+ if (nextNewline !== -1)
1848
+ {
1849
+ row.push(input.substring(cursor, nextNewline));
1850
+ saveRow(nextNewline + newlineLen);
1851
+
1852
+ if (stepIsFunction)
1853
+ {
1854
+ doStep();
1855
+ if (aborted)
1856
+ return returnable();
1857
+ }
1858
+
1859
+ if (preview && data.length >= preview)
1860
+ return returnable(true);
1861
+
1862
+ continue;
1863
+ }
1864
+
1865
+ break;
1866
+ }
1867
+
1868
+
1869
+ return finish();
1870
+
1871
+
1872
+ function pushRow(row)
1873
+ {
1874
+ data.push(row);
1875
+ lastCursor = cursor;
1876
+ }
1877
+
1878
+ /**
1879
+ * checks if there are extra spaces after closing quote and given index without any text
1880
+ * if Yes, returns the number of spaces
1881
+ */
1882
+ function extraSpaces(index) {
1883
+ var spaceLength = 0;
1884
+ if (index !== -1) {
1885
+ var textBetweenClosingQuoteAndIndex = input.substring(quoteSearch + 1, index);
1886
+ if (textBetweenClosingQuoteAndIndex && textBetweenClosingQuoteAndIndex.trim() === '') {
1887
+ spaceLength = textBetweenClosingQuoteAndIndex.length;
1888
+ }
1889
+ }
1890
+ return spaceLength;
1891
+ }
1892
+
1893
+ /**
1894
+ * Appends the remaining input from cursor to the end into
1895
+ * row, saves the row, calls step, and returns the results.
1896
+ */
1897
+ function finish(value)
1898
+ {
1899
+ if (ignoreLastRow)
1900
+ return returnable();
1901
+ if (typeof value === 'undefined')
1902
+ value = input.substring(cursor);
1903
+ row.push(value);
1904
+ cursor = inputLen; // important in case parsing is paused
1905
+ pushRow(row);
1906
+ if (stepIsFunction)
1907
+ doStep();
1908
+ return returnable();
1909
+ }
1910
+
1911
+ /**
1912
+ * Appends the current row to the results. It sets the cursor
1913
+ * to newCursor and finds the nextNewline. The caller should
1914
+ * take care to execute user's step function and check for
1915
+ * preview and end parsing if necessary.
1916
+ */
1917
+ function saveRow(newCursor)
1918
+ {
1919
+ cursor = newCursor;
1920
+ pushRow(row);
1921
+ row = [];
1922
+ nextNewline = input.indexOf(newline, cursor);
1923
+ }
1924
+
1925
+ /** Returns an object with the results, errors, and meta. */
1926
+ function returnable(stopped)
1927
+ {
1928
+ return {
1929
+ data: data,
1930
+ errors: errors,
1931
+ meta: {
1932
+ delimiter: delim,
1933
+ linebreak: newline,
1934
+ aborted: aborted,
1935
+ truncated: !!stopped,
1936
+ cursor: lastCursor + (baseIndex || 0)
1937
+ }
1938
+ };
1939
+ }
1940
+
1941
+ /** Executes the user's step function and resets data & errors. */
1942
+ function doStep()
1943
+ {
1944
+ step(returnable());
1945
+ data = [];
1946
+ errors = [];
1947
+ }
1948
+ };
1949
+
1950
+ /** Sets the abort flag */
1951
+ this.abort = function()
1952
+ {
1953
+ aborted = true;
1954
+ };
1955
+
1956
+ /** Gets the cursor position */
1957
+ this.getCharIndex = function()
1958
+ {
1959
+ return cursor;
1960
+ };
1961
+ }
1962
+
1963
+
1964
+ function newWorker()
1965
+ {
1966
+ if (!Papa.WORKERS_SUPPORTED)
1967
+ return false;
1968
+
1969
+ var workerUrl = getWorkerBlob();
1970
+ var w = new global.Worker(workerUrl);
1971
+ w.onmessage = mainThreadReceivedMessage;
1972
+ w.id = workerIdCounter++;
1973
+ workers[w.id] = w;
1974
+ return w;
1975
+ }
1976
+
1977
+ /** Callback when main thread receives a message */
1978
+ function mainThreadReceivedMessage(e)
1979
+ {
1980
+ var msg = e.data;
1981
+ var worker = workers[msg.workerId];
1982
+ var aborted = false;
1983
+
1984
+ if (msg.error)
1985
+ worker.userError(msg.error, msg.file);
1986
+ else if (msg.results && msg.results.data)
1987
+ {
1988
+ var abort = function() {
1989
+ aborted = true;
1990
+ completeWorker(msg.workerId, { data: [], errors: [], meta: { aborted: true } });
1991
+ };
1992
+
1993
+ var handle = {
1994
+ abort: abort,
1995
+ pause: notImplemented,
1996
+ resume: notImplemented
1997
+ };
1998
+
1999
+ if (isFunction(worker.userStep))
2000
+ {
2001
+ for (var i = 0; i < msg.results.data.length; i++)
2002
+ {
2003
+ worker.userStep({
2004
+ data: msg.results.data[i],
2005
+ errors: msg.results.errors,
2006
+ meta: msg.results.meta
2007
+ }, handle);
2008
+ if (aborted)
2009
+ break;
2010
+ }
2011
+ delete msg.results; // free memory ASAP
2012
+ }
2013
+ else if (isFunction(worker.userChunk))
2014
+ {
2015
+ worker.userChunk(msg.results, handle, msg.file);
2016
+ delete msg.results;
2017
+ }
2018
+ }
2019
+
2020
+ if (msg.finished && !aborted)
2021
+ completeWorker(msg.workerId, msg.results);
2022
+ }
2023
+
2024
+ function completeWorker(workerId, results) {
2025
+ var worker = workers[workerId];
2026
+ if (isFunction(worker.userComplete))
2027
+ worker.userComplete(results);
2028
+ worker.terminate();
2029
+ delete workers[workerId];
2030
+ }
2031
+
2032
+ function notImplemented() {
2033
+ throw new Error('Not implemented.');
2034
+ }
2035
+
2036
+ /** Callback when worker thread receives a message */
2037
+ function workerThreadReceivedMessage(e)
2038
+ {
2039
+ var msg = e.data;
2040
+
2041
+ if (typeof Papa.WORKER_ID === 'undefined' && msg)
2042
+ Papa.WORKER_ID = msg.workerId;
2043
+
2044
+ if (typeof msg.input === 'string')
2045
+ {
2046
+ global.postMessage({
2047
+ workerId: Papa.WORKER_ID,
2048
+ results: Papa.parse(msg.input, msg.config),
2049
+ finished: true
2050
+ });
2051
+ }
2052
+ else if ((global.File && msg.input instanceof File) || msg.input instanceof Object) // thank you, Safari (see issue #106)
2053
+ {
2054
+ var results = Papa.parse(msg.input, msg.config);
2055
+ if (results)
2056
+ global.postMessage({
2057
+ workerId: Papa.WORKER_ID,
2058
+ results: results,
2059
+ finished: true
2060
+ });
2061
+ }
2062
+ }
2063
+
2064
+ /** Makes a deep copy of an array or object (mostly) */
2065
+ function copy(obj)
2066
+ {
2067
+ if (typeof obj !== 'object' || obj === null)
2068
+ return obj;
2069
+ var cpy = Array.isArray(obj) ? [] : {};
2070
+ for (var key in obj)
2071
+ cpy[key] = copy(obj[key]);
2072
+ return cpy;
2073
+ }
2074
+
2075
+ function bindFunction(f, self)
2076
+ {
2077
+ return function() { f.apply(self, arguments); };
2078
+ }
2079
+
2080
+ function isFunction(func)
2081
+ {
2082
+ return typeof func === 'function';
2083
+ }
2084
+
2085
+ return Papa;
2086
+ }));
2087
+ } (papaparse));
2088
+
2089
+ var Papa = papaparse.exports;
2090
+
173
2091
  var isValidEmail = function isValidEmail(email) {
174
2092
  return yup.string().email().isValidSync(email);
175
2093
  };
@@ -184,7 +2102,7 @@ var createEmailOptions = function createEmailOptions() {
184
2102
  });
185
2103
  };
186
2104
  var parseCsvEmails = function parseCsvEmails(file, onSuccess) {
187
- Papa__default["default"].parse(file, {
2105
+ Papa.parse(file, {
188
2106
  header: true,
189
2107
  skipEmptyLines: true,
190
2108
  transformHeader: function transformHeader(h) {