convert-buddy-js 0.2.0 → 0.4.0
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.
- package/README.md +26 -2
- package/dist/{chunk-B44HYXEP.js → chunk-27H3T556.js} +11 -3
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -2
- package/package.json +7 -1
- package/dist/chunk-VUNV25KB.js +0 -16
- package/dist/fxp-TCYZYIHZ.js +0 -1701
- package/dist/papaparse-4KNMW7KX.js +0 -1324
- package/dist/src-YEKAFGYK.js +0 -3001
- package/dist/sync-FQGEFK5M.js +0 -1492
|
@@ -1,1324 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__commonJS,
|
|
3
|
-
__require
|
|
4
|
-
} from "./chunk-VUNV25KB.js";
|
|
5
|
-
|
|
6
|
-
// ../../node_modules/papaparse/papaparse.js
|
|
7
|
-
var require_papaparse = __commonJS({
|
|
8
|
-
"../../node_modules/papaparse/papaparse.js"(exports, module) {
|
|
9
|
-
(function(root, factory) {
|
|
10
|
-
if (typeof define === "function" && define.amd) {
|
|
11
|
-
define([], factory);
|
|
12
|
-
} else if (typeof module === "object" && typeof exports !== "undefined") {
|
|
13
|
-
module.exports = factory();
|
|
14
|
-
} else {
|
|
15
|
-
root.Papa = factory();
|
|
16
|
-
}
|
|
17
|
-
})(exports, function moduleFactory() {
|
|
18
|
-
"use strict";
|
|
19
|
-
var global = (function() {
|
|
20
|
-
if (typeof self !== "undefined") {
|
|
21
|
-
return self;
|
|
22
|
-
}
|
|
23
|
-
if (typeof window !== "undefined") {
|
|
24
|
-
return window;
|
|
25
|
-
}
|
|
26
|
-
if (typeof global !== "undefined") {
|
|
27
|
-
return global;
|
|
28
|
-
}
|
|
29
|
-
return {};
|
|
30
|
-
})();
|
|
31
|
-
function getWorkerBlob() {
|
|
32
|
-
var URL = global.URL || global.webkitURL || null;
|
|
33
|
-
var code = moduleFactory.toString();
|
|
34
|
-
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" })));
|
|
35
|
-
}
|
|
36
|
-
var IS_WORKER = !global.document && !!global.postMessage, IS_PAPA_WORKER = global.IS_PAPA_WORKER || false;
|
|
37
|
-
var workers = {}, workerIdCounter = 0;
|
|
38
|
-
var Papa = {};
|
|
39
|
-
Papa.parse = CsvToJson;
|
|
40
|
-
Papa.unparse = JsonToCsv;
|
|
41
|
-
Papa.RECORD_SEP = String.fromCharCode(30);
|
|
42
|
-
Papa.UNIT_SEP = String.fromCharCode(31);
|
|
43
|
-
Papa.BYTE_ORDER_MARK = "\uFEFF";
|
|
44
|
-
Papa.BAD_DELIMITERS = ["\r", "\n", '"', Papa.BYTE_ORDER_MARK];
|
|
45
|
-
Papa.WORKERS_SUPPORTED = !IS_WORKER && !!global.Worker;
|
|
46
|
-
Papa.NODE_STREAM_INPUT = 1;
|
|
47
|
-
Papa.LocalChunkSize = 1024 * 1024 * 10;
|
|
48
|
-
Papa.RemoteChunkSize = 1024 * 1024 * 5;
|
|
49
|
-
Papa.DefaultDelimiter = ",";
|
|
50
|
-
Papa.Parser = Parser;
|
|
51
|
-
Papa.ParserHandle = ParserHandle;
|
|
52
|
-
Papa.NetworkStreamer = NetworkStreamer;
|
|
53
|
-
Papa.FileStreamer = FileStreamer;
|
|
54
|
-
Papa.StringStreamer = StringStreamer;
|
|
55
|
-
Papa.ReadableStreamStreamer = ReadableStreamStreamer;
|
|
56
|
-
if (typeof PAPA_BROWSER_CONTEXT === "undefined") {
|
|
57
|
-
Papa.DuplexStreamStreamer = DuplexStreamStreamer;
|
|
58
|
-
}
|
|
59
|
-
if (global.jQuery) {
|
|
60
|
-
var $ = global.jQuery;
|
|
61
|
-
$.fn.parse = function(options) {
|
|
62
|
-
var config = options.config || {};
|
|
63
|
-
var queue = [];
|
|
64
|
-
this.each(function(idx) {
|
|
65
|
-
var supported = $(this).prop("tagName").toUpperCase() === "INPUT" && $(this).attr("type").toLowerCase() === "file" && global.FileReader;
|
|
66
|
-
if (!supported || !this.files || this.files.length === 0)
|
|
67
|
-
return true;
|
|
68
|
-
for (var i = 0; i < this.files.length; i++) {
|
|
69
|
-
queue.push({
|
|
70
|
-
file: this.files[i],
|
|
71
|
-
inputElem: this,
|
|
72
|
-
instanceConfig: $.extend({}, config)
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
parseNextFile();
|
|
77
|
-
return this;
|
|
78
|
-
function parseNextFile() {
|
|
79
|
-
if (queue.length === 0) {
|
|
80
|
-
if (isFunction(options.complete))
|
|
81
|
-
options.complete();
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
var f = queue[0];
|
|
85
|
-
if (isFunction(options.before)) {
|
|
86
|
-
var returned = options.before(f.file, f.inputElem);
|
|
87
|
-
if (typeof returned === "object") {
|
|
88
|
-
if (returned.action === "abort") {
|
|
89
|
-
error("AbortError", f.file, f.inputElem, returned.reason);
|
|
90
|
-
return;
|
|
91
|
-
} else if (returned.action === "skip") {
|
|
92
|
-
fileComplete();
|
|
93
|
-
return;
|
|
94
|
-
} else if (typeof returned.config === "object")
|
|
95
|
-
f.instanceConfig = $.extend(f.instanceConfig, returned.config);
|
|
96
|
-
} else if (returned === "skip") {
|
|
97
|
-
fileComplete();
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
var userCompleteFunc = f.instanceConfig.complete;
|
|
102
|
-
f.instanceConfig.complete = function(results) {
|
|
103
|
-
if (isFunction(userCompleteFunc))
|
|
104
|
-
userCompleteFunc(results, f.file, f.inputElem);
|
|
105
|
-
fileComplete();
|
|
106
|
-
};
|
|
107
|
-
Papa.parse(f.file, f.instanceConfig);
|
|
108
|
-
}
|
|
109
|
-
function error(name, file, elem, reason) {
|
|
110
|
-
if (isFunction(options.error))
|
|
111
|
-
options.error({ name }, file, elem, reason);
|
|
112
|
-
}
|
|
113
|
-
function fileComplete() {
|
|
114
|
-
queue.splice(0, 1);
|
|
115
|
-
parseNextFile();
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
if (IS_PAPA_WORKER) {
|
|
120
|
-
global.onmessage = workerThreadReceivedMessage;
|
|
121
|
-
}
|
|
122
|
-
function CsvToJson(_input, _config) {
|
|
123
|
-
_config = _config || {};
|
|
124
|
-
var dynamicTyping = _config.dynamicTyping || false;
|
|
125
|
-
if (isFunction(dynamicTyping)) {
|
|
126
|
-
_config.dynamicTypingFunction = dynamicTyping;
|
|
127
|
-
dynamicTyping = {};
|
|
128
|
-
}
|
|
129
|
-
_config.dynamicTyping = dynamicTyping;
|
|
130
|
-
_config.transform = isFunction(_config.transform) ? _config.transform : false;
|
|
131
|
-
if (_config.worker && Papa.WORKERS_SUPPORTED) {
|
|
132
|
-
var w = newWorker();
|
|
133
|
-
w.userStep = _config.step;
|
|
134
|
-
w.userChunk = _config.chunk;
|
|
135
|
-
w.userComplete = _config.complete;
|
|
136
|
-
w.userError = _config.error;
|
|
137
|
-
_config.step = isFunction(_config.step);
|
|
138
|
-
_config.chunk = isFunction(_config.chunk);
|
|
139
|
-
_config.complete = isFunction(_config.complete);
|
|
140
|
-
_config.error = isFunction(_config.error);
|
|
141
|
-
delete _config.worker;
|
|
142
|
-
w.postMessage({
|
|
143
|
-
input: _input,
|
|
144
|
-
config: _config,
|
|
145
|
-
workerId: w.id
|
|
146
|
-
});
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
var streamer = null;
|
|
150
|
-
if (_input === Papa.NODE_STREAM_INPUT && typeof PAPA_BROWSER_CONTEXT === "undefined") {
|
|
151
|
-
streamer = new DuplexStreamStreamer(_config);
|
|
152
|
-
return streamer.getStream();
|
|
153
|
-
} else if (typeof _input === "string") {
|
|
154
|
-
_input = stripBom(_input);
|
|
155
|
-
if (_config.download)
|
|
156
|
-
streamer = new NetworkStreamer(_config);
|
|
157
|
-
else
|
|
158
|
-
streamer = new StringStreamer(_config);
|
|
159
|
-
} else if (_input.readable === true && isFunction(_input.read) && isFunction(_input.on)) {
|
|
160
|
-
streamer = new ReadableStreamStreamer(_config);
|
|
161
|
-
} else if (global.File && _input instanceof File || _input instanceof Object)
|
|
162
|
-
streamer = new FileStreamer(_config);
|
|
163
|
-
return streamer.stream(_input);
|
|
164
|
-
function stripBom(string) {
|
|
165
|
-
if (string.charCodeAt(0) === 65279) {
|
|
166
|
-
return string.slice(1);
|
|
167
|
-
}
|
|
168
|
-
return string;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function JsonToCsv(_input, _config) {
|
|
172
|
-
var _quotes = false;
|
|
173
|
-
var _writeHeader = true;
|
|
174
|
-
var _delimiter = ",";
|
|
175
|
-
var _newline = "\r\n";
|
|
176
|
-
var _quoteChar = '"';
|
|
177
|
-
var _escapedQuote = _quoteChar + _quoteChar;
|
|
178
|
-
var _skipEmptyLines = false;
|
|
179
|
-
var _columns = null;
|
|
180
|
-
var _escapeFormulae = false;
|
|
181
|
-
unpackConfig();
|
|
182
|
-
var quoteCharRegex = new RegExp(escapeRegExp(_quoteChar), "g");
|
|
183
|
-
if (typeof _input === "string")
|
|
184
|
-
_input = JSON.parse(_input);
|
|
185
|
-
if (Array.isArray(_input)) {
|
|
186
|
-
if (!_input.length || Array.isArray(_input[0]))
|
|
187
|
-
return serialize(null, _input, _skipEmptyLines);
|
|
188
|
-
else if (typeof _input[0] === "object")
|
|
189
|
-
return serialize(_columns || Object.keys(_input[0]), _input, _skipEmptyLines);
|
|
190
|
-
} else if (typeof _input === "object") {
|
|
191
|
-
if (typeof _input.data === "string")
|
|
192
|
-
_input.data = JSON.parse(_input.data);
|
|
193
|
-
if (Array.isArray(_input.data)) {
|
|
194
|
-
if (!_input.fields)
|
|
195
|
-
_input.fields = _input.meta && _input.meta.fields || _columns;
|
|
196
|
-
if (!_input.fields)
|
|
197
|
-
_input.fields = Array.isArray(_input.data[0]) ? _input.fields : typeof _input.data[0] === "object" ? Object.keys(_input.data[0]) : [];
|
|
198
|
-
if (!Array.isArray(_input.data[0]) && typeof _input.data[0] !== "object")
|
|
199
|
-
_input.data = [_input.data];
|
|
200
|
-
}
|
|
201
|
-
return serialize(_input.fields || [], _input.data || [], _skipEmptyLines);
|
|
202
|
-
}
|
|
203
|
-
throw new Error("Unable to serialize unrecognized input");
|
|
204
|
-
function unpackConfig() {
|
|
205
|
-
if (typeof _config !== "object")
|
|
206
|
-
return;
|
|
207
|
-
if (typeof _config.delimiter === "string" && !Papa.BAD_DELIMITERS.filter(function(value) {
|
|
208
|
-
return _config.delimiter.indexOf(value) !== -1;
|
|
209
|
-
}).length) {
|
|
210
|
-
_delimiter = _config.delimiter;
|
|
211
|
-
}
|
|
212
|
-
if (typeof _config.quotes === "boolean" || typeof _config.quotes === "function" || Array.isArray(_config.quotes))
|
|
213
|
-
_quotes = _config.quotes;
|
|
214
|
-
if (typeof _config.skipEmptyLines === "boolean" || typeof _config.skipEmptyLines === "string")
|
|
215
|
-
_skipEmptyLines = _config.skipEmptyLines;
|
|
216
|
-
if (typeof _config.newline === "string")
|
|
217
|
-
_newline = _config.newline;
|
|
218
|
-
if (typeof _config.quoteChar === "string")
|
|
219
|
-
_quoteChar = _config.quoteChar;
|
|
220
|
-
if (typeof _config.header === "boolean")
|
|
221
|
-
_writeHeader = _config.header;
|
|
222
|
-
if (Array.isArray(_config.columns)) {
|
|
223
|
-
if (_config.columns.length === 0) throw new Error("Option columns is empty");
|
|
224
|
-
_columns = _config.columns;
|
|
225
|
-
}
|
|
226
|
-
if (_config.escapeChar !== void 0) {
|
|
227
|
-
_escapedQuote = _config.escapeChar + _quoteChar;
|
|
228
|
-
}
|
|
229
|
-
if (_config.escapeFormulae instanceof RegExp) {
|
|
230
|
-
_escapeFormulae = _config.escapeFormulae;
|
|
231
|
-
} else if (typeof _config.escapeFormulae === "boolean" && _config.escapeFormulae) {
|
|
232
|
-
_escapeFormulae = /^[=+\-@\t\r].*$/;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function serialize(fields, data, skipEmptyLines) {
|
|
236
|
-
var csv = "";
|
|
237
|
-
if (typeof fields === "string")
|
|
238
|
-
fields = JSON.parse(fields);
|
|
239
|
-
if (typeof data === "string")
|
|
240
|
-
data = JSON.parse(data);
|
|
241
|
-
var hasHeader = Array.isArray(fields) && fields.length > 0;
|
|
242
|
-
var dataKeyedByField = !Array.isArray(data[0]);
|
|
243
|
-
if (hasHeader && _writeHeader) {
|
|
244
|
-
for (var i = 0; i < fields.length; i++) {
|
|
245
|
-
if (i > 0)
|
|
246
|
-
csv += _delimiter;
|
|
247
|
-
csv += safe(fields[i], i);
|
|
248
|
-
}
|
|
249
|
-
if (data.length > 0)
|
|
250
|
-
csv += _newline;
|
|
251
|
-
}
|
|
252
|
-
for (var row = 0; row < data.length; row++) {
|
|
253
|
-
var maxCol = hasHeader ? fields.length : data[row].length;
|
|
254
|
-
var emptyLine = false;
|
|
255
|
-
var nullLine = hasHeader ? Object.keys(data[row]).length === 0 : data[row].length === 0;
|
|
256
|
-
if (skipEmptyLines && !hasHeader) {
|
|
257
|
-
emptyLine = skipEmptyLines === "greedy" ? data[row].join("").trim() === "" : data[row].length === 1 && data[row][0].length === 0;
|
|
258
|
-
}
|
|
259
|
-
if (skipEmptyLines === "greedy" && hasHeader) {
|
|
260
|
-
var line = [];
|
|
261
|
-
for (var c = 0; c < maxCol; c++) {
|
|
262
|
-
var cx = dataKeyedByField ? fields[c] : c;
|
|
263
|
-
line.push(data[row][cx]);
|
|
264
|
-
}
|
|
265
|
-
emptyLine = line.join("").trim() === "";
|
|
266
|
-
}
|
|
267
|
-
if (!emptyLine) {
|
|
268
|
-
for (var col = 0; col < maxCol; col++) {
|
|
269
|
-
if (col > 0 && !nullLine)
|
|
270
|
-
csv += _delimiter;
|
|
271
|
-
var colIdx = hasHeader && dataKeyedByField ? fields[col] : col;
|
|
272
|
-
csv += safe(data[row][colIdx], col);
|
|
273
|
-
}
|
|
274
|
-
if (row < data.length - 1 && (!skipEmptyLines || maxCol > 0 && !nullLine)) {
|
|
275
|
-
csv += _newline;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return csv;
|
|
280
|
-
}
|
|
281
|
-
function safe(str, col) {
|
|
282
|
-
if (typeof str === "undefined" || str === null)
|
|
283
|
-
return "";
|
|
284
|
-
if (str.constructor === Date)
|
|
285
|
-
return JSON.stringify(str).slice(1, 25);
|
|
286
|
-
var needsQuotes = false;
|
|
287
|
-
if (_escapeFormulae && typeof str === "string" && _escapeFormulae.test(str)) {
|
|
288
|
-
str = "'" + str;
|
|
289
|
-
needsQuotes = true;
|
|
290
|
-
}
|
|
291
|
-
var escapedQuoteStr = str.toString().replace(quoteCharRegex, _escapedQuote);
|
|
292
|
-
needsQuotes = needsQuotes || _quotes === true || typeof _quotes === "function" && _quotes(str, col) || Array.isArray(_quotes) && _quotes[col] || hasAny(escapedQuoteStr, Papa.BAD_DELIMITERS) || escapedQuoteStr.indexOf(_delimiter) > -1 || escapedQuoteStr.charAt(0) === " " || escapedQuoteStr.charAt(escapedQuoteStr.length - 1) === " ";
|
|
293
|
-
return needsQuotes ? _quoteChar + escapedQuoteStr + _quoteChar : escapedQuoteStr;
|
|
294
|
-
}
|
|
295
|
-
function hasAny(str, substrings) {
|
|
296
|
-
for (var i = 0; i < substrings.length; i++)
|
|
297
|
-
if (str.indexOf(substrings[i]) > -1)
|
|
298
|
-
return true;
|
|
299
|
-
return false;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
function ChunkStreamer(config) {
|
|
303
|
-
this._handle = null;
|
|
304
|
-
this._finished = false;
|
|
305
|
-
this._completed = false;
|
|
306
|
-
this._halted = false;
|
|
307
|
-
this._input = null;
|
|
308
|
-
this._baseIndex = 0;
|
|
309
|
-
this._partialLine = "";
|
|
310
|
-
this._rowCount = 0;
|
|
311
|
-
this._start = 0;
|
|
312
|
-
this._nextChunk = null;
|
|
313
|
-
this.isFirstChunk = true;
|
|
314
|
-
this._completeResults = {
|
|
315
|
-
data: [],
|
|
316
|
-
errors: [],
|
|
317
|
-
meta: {}
|
|
318
|
-
};
|
|
319
|
-
replaceConfig.call(this, config);
|
|
320
|
-
this.parseChunk = function(chunk, isFakeChunk) {
|
|
321
|
-
const skipFirstNLines = parseInt(this._config.skipFirstNLines) || 0;
|
|
322
|
-
if (this.isFirstChunk && skipFirstNLines > 0) {
|
|
323
|
-
let _newline = this._config.newline;
|
|
324
|
-
if (!_newline) {
|
|
325
|
-
const quoteChar = this._config.quoteChar || '"';
|
|
326
|
-
_newline = this._handle.guessLineEndings(chunk, quoteChar);
|
|
327
|
-
}
|
|
328
|
-
const splitChunk = chunk.split(_newline);
|
|
329
|
-
chunk = [...splitChunk.slice(skipFirstNLines)].join(_newline);
|
|
330
|
-
}
|
|
331
|
-
if (this.isFirstChunk && isFunction(this._config.beforeFirstChunk)) {
|
|
332
|
-
var modifiedChunk = this._config.beforeFirstChunk(chunk);
|
|
333
|
-
if (modifiedChunk !== void 0)
|
|
334
|
-
chunk = modifiedChunk;
|
|
335
|
-
}
|
|
336
|
-
this.isFirstChunk = false;
|
|
337
|
-
this._halted = false;
|
|
338
|
-
var aggregate = this._partialLine + chunk;
|
|
339
|
-
this._partialLine = "";
|
|
340
|
-
var results = this._handle.parse(aggregate, this._baseIndex, !this._finished);
|
|
341
|
-
if (this._handle.paused() || this._handle.aborted()) {
|
|
342
|
-
this._halted = true;
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
var lastIndex = results.meta.cursor;
|
|
346
|
-
if (!this._finished) {
|
|
347
|
-
this._partialLine = aggregate.substring(lastIndex - this._baseIndex);
|
|
348
|
-
this._baseIndex = lastIndex;
|
|
349
|
-
}
|
|
350
|
-
if (results && results.data)
|
|
351
|
-
this._rowCount += results.data.length;
|
|
352
|
-
var finishedIncludingPreview = this._finished || this._config.preview && this._rowCount >= this._config.preview;
|
|
353
|
-
if (IS_PAPA_WORKER) {
|
|
354
|
-
global.postMessage({
|
|
355
|
-
results,
|
|
356
|
-
workerId: Papa.WORKER_ID,
|
|
357
|
-
finished: finishedIncludingPreview
|
|
358
|
-
});
|
|
359
|
-
} else if (isFunction(this._config.chunk) && !isFakeChunk) {
|
|
360
|
-
this._config.chunk(results, this._handle);
|
|
361
|
-
if (this._handle.paused() || this._handle.aborted()) {
|
|
362
|
-
this._halted = true;
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
results = void 0;
|
|
366
|
-
this._completeResults = void 0;
|
|
367
|
-
}
|
|
368
|
-
if (!this._config.step && !this._config.chunk) {
|
|
369
|
-
this._completeResults.data = this._completeResults.data.concat(results.data);
|
|
370
|
-
this._completeResults.errors = this._completeResults.errors.concat(results.errors);
|
|
371
|
-
this._completeResults.meta = results.meta;
|
|
372
|
-
}
|
|
373
|
-
if (!this._completed && finishedIncludingPreview && isFunction(this._config.complete) && (!results || !results.meta.aborted)) {
|
|
374
|
-
this._config.complete(this._completeResults, this._input);
|
|
375
|
-
this._completed = true;
|
|
376
|
-
}
|
|
377
|
-
if (!finishedIncludingPreview && (!results || !results.meta.paused))
|
|
378
|
-
this._nextChunk();
|
|
379
|
-
return results;
|
|
380
|
-
};
|
|
381
|
-
this._sendError = function(error) {
|
|
382
|
-
if (isFunction(this._config.error))
|
|
383
|
-
this._config.error(error);
|
|
384
|
-
else if (IS_PAPA_WORKER && this._config.error) {
|
|
385
|
-
global.postMessage({
|
|
386
|
-
workerId: Papa.WORKER_ID,
|
|
387
|
-
error,
|
|
388
|
-
finished: false
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
function replaceConfig(config2) {
|
|
393
|
-
var configCopy = copy(config2);
|
|
394
|
-
configCopy.chunkSize = parseInt(configCopy.chunkSize);
|
|
395
|
-
if (!config2.step && !config2.chunk)
|
|
396
|
-
configCopy.chunkSize = null;
|
|
397
|
-
this._handle = new ParserHandle(configCopy);
|
|
398
|
-
this._handle.streamer = this;
|
|
399
|
-
this._config = configCopy;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
function NetworkStreamer(config) {
|
|
403
|
-
config = config || {};
|
|
404
|
-
if (!config.chunkSize)
|
|
405
|
-
config.chunkSize = Papa.RemoteChunkSize;
|
|
406
|
-
ChunkStreamer.call(this, config);
|
|
407
|
-
var xhr;
|
|
408
|
-
if (IS_WORKER) {
|
|
409
|
-
this._nextChunk = function() {
|
|
410
|
-
this._readChunk();
|
|
411
|
-
this._chunkLoaded();
|
|
412
|
-
};
|
|
413
|
-
} else {
|
|
414
|
-
this._nextChunk = function() {
|
|
415
|
-
this._readChunk();
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
this.stream = function(url) {
|
|
419
|
-
this._input = url;
|
|
420
|
-
this._nextChunk();
|
|
421
|
-
};
|
|
422
|
-
this._readChunk = function() {
|
|
423
|
-
if (this._finished) {
|
|
424
|
-
this._chunkLoaded();
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
xhr = new XMLHttpRequest();
|
|
428
|
-
if (this._config.withCredentials) {
|
|
429
|
-
xhr.withCredentials = this._config.withCredentials;
|
|
430
|
-
}
|
|
431
|
-
if (!IS_WORKER) {
|
|
432
|
-
xhr.onload = bindFunction(this._chunkLoaded, this);
|
|
433
|
-
xhr.onerror = bindFunction(this._chunkError, this);
|
|
434
|
-
}
|
|
435
|
-
xhr.open(this._config.downloadRequestBody ? "POST" : "GET", this._input, !IS_WORKER);
|
|
436
|
-
if (this._config.downloadRequestHeaders) {
|
|
437
|
-
var headers = this._config.downloadRequestHeaders;
|
|
438
|
-
for (var headerName in headers) {
|
|
439
|
-
xhr.setRequestHeader(headerName, headers[headerName]);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
if (this._config.chunkSize) {
|
|
443
|
-
var end = this._start + this._config.chunkSize - 1;
|
|
444
|
-
xhr.setRequestHeader("Range", "bytes=" + this._start + "-" + end);
|
|
445
|
-
}
|
|
446
|
-
try {
|
|
447
|
-
xhr.send(this._config.downloadRequestBody);
|
|
448
|
-
} catch (err) {
|
|
449
|
-
this._chunkError(err.message);
|
|
450
|
-
}
|
|
451
|
-
if (IS_WORKER && xhr.status === 0)
|
|
452
|
-
this._chunkError();
|
|
453
|
-
};
|
|
454
|
-
this._chunkLoaded = function() {
|
|
455
|
-
if (xhr.readyState !== 4)
|
|
456
|
-
return;
|
|
457
|
-
if (xhr.status < 200 || xhr.status >= 400) {
|
|
458
|
-
this._chunkError();
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
this._start += this._config.chunkSize ? this._config.chunkSize : xhr.responseText.length;
|
|
462
|
-
this._finished = !this._config.chunkSize || this._start >= getFileSize(xhr);
|
|
463
|
-
this.parseChunk(xhr.responseText);
|
|
464
|
-
};
|
|
465
|
-
this._chunkError = function(errorMessage) {
|
|
466
|
-
var errorText = xhr.statusText || errorMessage;
|
|
467
|
-
this._sendError(new Error(errorText));
|
|
468
|
-
};
|
|
469
|
-
function getFileSize(xhr2) {
|
|
470
|
-
var contentRange = xhr2.getResponseHeader("Content-Range");
|
|
471
|
-
if (contentRange === null) {
|
|
472
|
-
return -1;
|
|
473
|
-
}
|
|
474
|
-
return parseInt(contentRange.substring(contentRange.lastIndexOf("/") + 1));
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
NetworkStreamer.prototype = Object.create(ChunkStreamer.prototype);
|
|
478
|
-
NetworkStreamer.prototype.constructor = NetworkStreamer;
|
|
479
|
-
function FileStreamer(config) {
|
|
480
|
-
config = config || {};
|
|
481
|
-
if (!config.chunkSize)
|
|
482
|
-
config.chunkSize = Papa.LocalChunkSize;
|
|
483
|
-
ChunkStreamer.call(this, config);
|
|
484
|
-
var reader, slice;
|
|
485
|
-
var usingAsyncReader = typeof FileReader !== "undefined";
|
|
486
|
-
this.stream = function(file) {
|
|
487
|
-
this._input = file;
|
|
488
|
-
slice = file.slice || file.webkitSlice || file.mozSlice;
|
|
489
|
-
if (usingAsyncReader) {
|
|
490
|
-
reader = new FileReader();
|
|
491
|
-
reader.onload = bindFunction(this._chunkLoaded, this);
|
|
492
|
-
reader.onerror = bindFunction(this._chunkError, this);
|
|
493
|
-
} else
|
|
494
|
-
reader = new FileReaderSync();
|
|
495
|
-
this._nextChunk();
|
|
496
|
-
};
|
|
497
|
-
this._nextChunk = function() {
|
|
498
|
-
if (!this._finished && (!this._config.preview || this._rowCount < this._config.preview))
|
|
499
|
-
this._readChunk();
|
|
500
|
-
};
|
|
501
|
-
this._readChunk = function() {
|
|
502
|
-
var input = this._input;
|
|
503
|
-
if (this._config.chunkSize) {
|
|
504
|
-
var end = Math.min(this._start + this._config.chunkSize, this._input.size);
|
|
505
|
-
input = slice.call(input, this._start, end);
|
|
506
|
-
}
|
|
507
|
-
var txt = reader.readAsText(input, this._config.encoding);
|
|
508
|
-
if (!usingAsyncReader)
|
|
509
|
-
this._chunkLoaded({ target: { result: txt } });
|
|
510
|
-
};
|
|
511
|
-
this._chunkLoaded = function(event) {
|
|
512
|
-
this._start += this._config.chunkSize;
|
|
513
|
-
this._finished = !this._config.chunkSize || this._start >= this._input.size;
|
|
514
|
-
this.parseChunk(event.target.result);
|
|
515
|
-
};
|
|
516
|
-
this._chunkError = function() {
|
|
517
|
-
this._sendError(reader.error);
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
|
-
FileStreamer.prototype = Object.create(ChunkStreamer.prototype);
|
|
521
|
-
FileStreamer.prototype.constructor = FileStreamer;
|
|
522
|
-
function StringStreamer(config) {
|
|
523
|
-
config = config || {};
|
|
524
|
-
ChunkStreamer.call(this, config);
|
|
525
|
-
var remaining;
|
|
526
|
-
this.stream = function(s) {
|
|
527
|
-
remaining = s;
|
|
528
|
-
return this._nextChunk();
|
|
529
|
-
};
|
|
530
|
-
this._nextChunk = function() {
|
|
531
|
-
if (this._finished) return;
|
|
532
|
-
var size = this._config.chunkSize;
|
|
533
|
-
var chunk;
|
|
534
|
-
if (size) {
|
|
535
|
-
chunk = remaining.substring(0, size);
|
|
536
|
-
remaining = remaining.substring(size);
|
|
537
|
-
} else {
|
|
538
|
-
chunk = remaining;
|
|
539
|
-
remaining = "";
|
|
540
|
-
}
|
|
541
|
-
this._finished = !remaining;
|
|
542
|
-
return this.parseChunk(chunk);
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
StringStreamer.prototype = Object.create(StringStreamer.prototype);
|
|
546
|
-
StringStreamer.prototype.constructor = StringStreamer;
|
|
547
|
-
function ReadableStreamStreamer(config) {
|
|
548
|
-
config = config || {};
|
|
549
|
-
ChunkStreamer.call(this, config);
|
|
550
|
-
var queue = [];
|
|
551
|
-
var parseOnData = true;
|
|
552
|
-
var streamHasEnded = false;
|
|
553
|
-
this.pause = function() {
|
|
554
|
-
ChunkStreamer.prototype.pause.apply(this, arguments);
|
|
555
|
-
this._input.pause();
|
|
556
|
-
};
|
|
557
|
-
this.resume = function() {
|
|
558
|
-
ChunkStreamer.prototype.resume.apply(this, arguments);
|
|
559
|
-
this._input.resume();
|
|
560
|
-
};
|
|
561
|
-
this.stream = function(stream) {
|
|
562
|
-
this._input = stream;
|
|
563
|
-
this._input.on("data", this._streamData);
|
|
564
|
-
this._input.on("end", this._streamEnd);
|
|
565
|
-
this._input.on("error", this._streamError);
|
|
566
|
-
};
|
|
567
|
-
this._checkIsFinished = function() {
|
|
568
|
-
if (streamHasEnded && queue.length === 1) {
|
|
569
|
-
this._finished = true;
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
this._nextChunk = function() {
|
|
573
|
-
this._checkIsFinished();
|
|
574
|
-
if (queue.length) {
|
|
575
|
-
this.parseChunk(queue.shift());
|
|
576
|
-
} else {
|
|
577
|
-
parseOnData = true;
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
|
-
this._streamData = bindFunction(function(chunk) {
|
|
581
|
-
try {
|
|
582
|
-
queue.push(typeof chunk === "string" ? chunk : chunk.toString(this._config.encoding));
|
|
583
|
-
if (parseOnData) {
|
|
584
|
-
parseOnData = false;
|
|
585
|
-
this._checkIsFinished();
|
|
586
|
-
this.parseChunk(queue.shift());
|
|
587
|
-
}
|
|
588
|
-
} catch (error) {
|
|
589
|
-
this._streamError(error);
|
|
590
|
-
}
|
|
591
|
-
}, this);
|
|
592
|
-
this._streamError = bindFunction(function(error) {
|
|
593
|
-
this._streamCleanUp();
|
|
594
|
-
this._sendError(error);
|
|
595
|
-
}, this);
|
|
596
|
-
this._streamEnd = bindFunction(function() {
|
|
597
|
-
this._streamCleanUp();
|
|
598
|
-
streamHasEnded = true;
|
|
599
|
-
this._streamData("");
|
|
600
|
-
}, this);
|
|
601
|
-
this._streamCleanUp = bindFunction(function() {
|
|
602
|
-
this._input.removeListener("data", this._streamData);
|
|
603
|
-
this._input.removeListener("end", this._streamEnd);
|
|
604
|
-
this._input.removeListener("error", this._streamError);
|
|
605
|
-
}, this);
|
|
606
|
-
}
|
|
607
|
-
ReadableStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
|
|
608
|
-
ReadableStreamStreamer.prototype.constructor = ReadableStreamStreamer;
|
|
609
|
-
function DuplexStreamStreamer(_config) {
|
|
610
|
-
var Duplex = __require("stream").Duplex;
|
|
611
|
-
var config = copy(_config);
|
|
612
|
-
var parseOnWrite = true;
|
|
613
|
-
var writeStreamHasFinished = false;
|
|
614
|
-
var parseCallbackQueue = [];
|
|
615
|
-
var stream = null;
|
|
616
|
-
this._onCsvData = function(results) {
|
|
617
|
-
var data = results.data;
|
|
618
|
-
if (!stream.push(data) && !this._handle.paused()) {
|
|
619
|
-
this._handle.pause();
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
this._onCsvComplete = function() {
|
|
623
|
-
stream.push(null);
|
|
624
|
-
};
|
|
625
|
-
config.step = bindFunction(this._onCsvData, this);
|
|
626
|
-
config.complete = bindFunction(this._onCsvComplete, this);
|
|
627
|
-
ChunkStreamer.call(this, config);
|
|
628
|
-
this._nextChunk = function() {
|
|
629
|
-
if (writeStreamHasFinished && parseCallbackQueue.length === 1) {
|
|
630
|
-
this._finished = true;
|
|
631
|
-
}
|
|
632
|
-
if (parseCallbackQueue.length) {
|
|
633
|
-
parseCallbackQueue.shift()();
|
|
634
|
-
} else {
|
|
635
|
-
parseOnWrite = true;
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
this._addToParseQueue = function(chunk, callback) {
|
|
639
|
-
parseCallbackQueue.push(bindFunction(function() {
|
|
640
|
-
this.parseChunk(typeof chunk === "string" ? chunk : chunk.toString(config.encoding));
|
|
641
|
-
if (isFunction(callback)) {
|
|
642
|
-
return callback();
|
|
643
|
-
}
|
|
644
|
-
}, this));
|
|
645
|
-
if (parseOnWrite) {
|
|
646
|
-
parseOnWrite = false;
|
|
647
|
-
this._nextChunk();
|
|
648
|
-
}
|
|
649
|
-
};
|
|
650
|
-
this._onRead = function() {
|
|
651
|
-
if (this._handle.paused()) {
|
|
652
|
-
this._handle.resume();
|
|
653
|
-
}
|
|
654
|
-
};
|
|
655
|
-
this._onWrite = function(chunk, encoding, callback) {
|
|
656
|
-
this._addToParseQueue(chunk, callback);
|
|
657
|
-
};
|
|
658
|
-
this._onWriteComplete = function() {
|
|
659
|
-
writeStreamHasFinished = true;
|
|
660
|
-
this._addToParseQueue("");
|
|
661
|
-
};
|
|
662
|
-
this.getStream = function() {
|
|
663
|
-
return stream;
|
|
664
|
-
};
|
|
665
|
-
stream = new Duplex({
|
|
666
|
-
readableObjectMode: true,
|
|
667
|
-
decodeStrings: false,
|
|
668
|
-
read: bindFunction(this._onRead, this),
|
|
669
|
-
write: bindFunction(this._onWrite, this)
|
|
670
|
-
});
|
|
671
|
-
stream.once("finish", bindFunction(this._onWriteComplete, this));
|
|
672
|
-
}
|
|
673
|
-
if (typeof PAPA_BROWSER_CONTEXT === "undefined") {
|
|
674
|
-
DuplexStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
|
|
675
|
-
DuplexStreamStreamer.prototype.constructor = DuplexStreamStreamer;
|
|
676
|
-
}
|
|
677
|
-
function ParserHandle(_config) {
|
|
678
|
-
var MAX_FLOAT = Math.pow(2, 53);
|
|
679
|
-
var MIN_FLOAT = -MAX_FLOAT;
|
|
680
|
-
var FLOAT = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/;
|
|
681
|
-
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)))$/;
|
|
682
|
-
var self2 = this;
|
|
683
|
-
var _stepCounter = 0;
|
|
684
|
-
var _rowCounter = 0;
|
|
685
|
-
var _input;
|
|
686
|
-
var _parser;
|
|
687
|
-
var _paused = false;
|
|
688
|
-
var _aborted = false;
|
|
689
|
-
var _delimiterError;
|
|
690
|
-
var _fields = [];
|
|
691
|
-
var _results = {
|
|
692
|
-
// The last results returned from the parser
|
|
693
|
-
data: [],
|
|
694
|
-
errors: [],
|
|
695
|
-
meta: {}
|
|
696
|
-
};
|
|
697
|
-
if (isFunction(_config.step)) {
|
|
698
|
-
var userStep = _config.step;
|
|
699
|
-
_config.step = function(results) {
|
|
700
|
-
_results = results;
|
|
701
|
-
if (needsHeaderRow())
|
|
702
|
-
processResults();
|
|
703
|
-
else {
|
|
704
|
-
processResults();
|
|
705
|
-
if (_results.data.length === 0)
|
|
706
|
-
return;
|
|
707
|
-
_stepCounter += results.data.length;
|
|
708
|
-
if (_config.preview && _stepCounter > _config.preview)
|
|
709
|
-
_parser.abort();
|
|
710
|
-
else {
|
|
711
|
-
_results.data = _results.data[0];
|
|
712
|
-
userStep(_results, self2);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
};
|
|
716
|
-
}
|
|
717
|
-
this.parse = function(input, baseIndex, ignoreLastRow) {
|
|
718
|
-
var quoteChar = _config.quoteChar || '"';
|
|
719
|
-
if (!_config.newline)
|
|
720
|
-
_config.newline = this.guessLineEndings(input, quoteChar);
|
|
721
|
-
_delimiterError = false;
|
|
722
|
-
if (!_config.delimiter) {
|
|
723
|
-
var delimGuess = guessDelimiter(input, _config.newline, _config.skipEmptyLines, _config.comments, _config.delimitersToGuess);
|
|
724
|
-
if (delimGuess.successful)
|
|
725
|
-
_config.delimiter = delimGuess.bestDelimiter;
|
|
726
|
-
else {
|
|
727
|
-
_delimiterError = true;
|
|
728
|
-
_config.delimiter = Papa.DefaultDelimiter;
|
|
729
|
-
}
|
|
730
|
-
_results.meta.delimiter = _config.delimiter;
|
|
731
|
-
} else if (isFunction(_config.delimiter)) {
|
|
732
|
-
_config.delimiter = _config.delimiter(input);
|
|
733
|
-
_results.meta.delimiter = _config.delimiter;
|
|
734
|
-
}
|
|
735
|
-
var parserConfig = copy(_config);
|
|
736
|
-
if (_config.preview && _config.header)
|
|
737
|
-
parserConfig.preview++;
|
|
738
|
-
_input = input;
|
|
739
|
-
_parser = new Parser(parserConfig);
|
|
740
|
-
_results = _parser.parse(_input, baseIndex, ignoreLastRow);
|
|
741
|
-
processResults();
|
|
742
|
-
return _paused ? { meta: { paused: true } } : _results || { meta: { paused: false } };
|
|
743
|
-
};
|
|
744
|
-
this.paused = function() {
|
|
745
|
-
return _paused;
|
|
746
|
-
};
|
|
747
|
-
this.pause = function() {
|
|
748
|
-
_paused = true;
|
|
749
|
-
_parser.abort();
|
|
750
|
-
_input = isFunction(_config.chunk) ? "" : _input.substring(_parser.getCharIndex());
|
|
751
|
-
};
|
|
752
|
-
this.resume = function() {
|
|
753
|
-
if (self2.streamer._halted) {
|
|
754
|
-
_paused = false;
|
|
755
|
-
self2.streamer.parseChunk(_input, true);
|
|
756
|
-
} else {
|
|
757
|
-
setTimeout(self2.resume, 3);
|
|
758
|
-
}
|
|
759
|
-
};
|
|
760
|
-
this.aborted = function() {
|
|
761
|
-
return _aborted;
|
|
762
|
-
};
|
|
763
|
-
this.abort = function() {
|
|
764
|
-
_aborted = true;
|
|
765
|
-
_parser.abort();
|
|
766
|
-
_results.meta.aborted = true;
|
|
767
|
-
if (isFunction(_config.complete))
|
|
768
|
-
_config.complete(_results);
|
|
769
|
-
_input = "";
|
|
770
|
-
};
|
|
771
|
-
this.guessLineEndings = function(input, quoteChar) {
|
|
772
|
-
input = input.substring(0, 1024 * 1024);
|
|
773
|
-
var re = new RegExp(escapeRegExp(quoteChar) + "([^]*?)" + escapeRegExp(quoteChar), "gm");
|
|
774
|
-
input = input.replace(re, "");
|
|
775
|
-
var r = input.split("\r");
|
|
776
|
-
var n = input.split("\n");
|
|
777
|
-
var nAppearsFirst = n.length > 1 && n[0].length < r[0].length;
|
|
778
|
-
if (r.length === 1 || nAppearsFirst)
|
|
779
|
-
return "\n";
|
|
780
|
-
var numWithN = 0;
|
|
781
|
-
for (var i = 0; i < r.length; i++) {
|
|
782
|
-
if (r[i][0] === "\n")
|
|
783
|
-
numWithN++;
|
|
784
|
-
}
|
|
785
|
-
return numWithN >= r.length / 2 ? "\r\n" : "\r";
|
|
786
|
-
};
|
|
787
|
-
function testEmptyLine(s) {
|
|
788
|
-
return _config.skipEmptyLines === "greedy" ? s.join("").trim() === "" : s.length === 1 && s[0].length === 0;
|
|
789
|
-
}
|
|
790
|
-
function testFloat(s) {
|
|
791
|
-
if (FLOAT.test(s)) {
|
|
792
|
-
var floatValue = parseFloat(s);
|
|
793
|
-
if (floatValue > MIN_FLOAT && floatValue < MAX_FLOAT) {
|
|
794
|
-
return true;
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
return false;
|
|
798
|
-
}
|
|
799
|
-
function processResults() {
|
|
800
|
-
if (_results && _delimiterError) {
|
|
801
|
-
addError("Delimiter", "UndetectableDelimiter", "Unable to auto-detect delimiting character; defaulted to '" + Papa.DefaultDelimiter + "'");
|
|
802
|
-
_delimiterError = false;
|
|
803
|
-
}
|
|
804
|
-
if (_config.skipEmptyLines) {
|
|
805
|
-
_results.data = _results.data.filter(function(d) {
|
|
806
|
-
return !testEmptyLine(d);
|
|
807
|
-
});
|
|
808
|
-
}
|
|
809
|
-
if (needsHeaderRow())
|
|
810
|
-
fillHeaderFields();
|
|
811
|
-
return applyHeaderAndDynamicTypingAndTransformation();
|
|
812
|
-
}
|
|
813
|
-
function needsHeaderRow() {
|
|
814
|
-
return _config.header && _fields.length === 0;
|
|
815
|
-
}
|
|
816
|
-
function fillHeaderFields() {
|
|
817
|
-
if (!_results)
|
|
818
|
-
return;
|
|
819
|
-
function addHeader(header, i2) {
|
|
820
|
-
if (isFunction(_config.transformHeader))
|
|
821
|
-
header = _config.transformHeader(header, i2);
|
|
822
|
-
_fields.push(header);
|
|
823
|
-
}
|
|
824
|
-
if (Array.isArray(_results.data[0])) {
|
|
825
|
-
for (var i = 0; needsHeaderRow() && i < _results.data.length; i++)
|
|
826
|
-
_results.data[i].forEach(addHeader);
|
|
827
|
-
_results.data.splice(0, 1);
|
|
828
|
-
} else
|
|
829
|
-
_results.data.forEach(addHeader);
|
|
830
|
-
}
|
|
831
|
-
function shouldApplyDynamicTyping(field) {
|
|
832
|
-
if (_config.dynamicTypingFunction && _config.dynamicTyping[field] === void 0) {
|
|
833
|
-
_config.dynamicTyping[field] = _config.dynamicTypingFunction(field);
|
|
834
|
-
}
|
|
835
|
-
return (_config.dynamicTyping[field] || _config.dynamicTyping) === true;
|
|
836
|
-
}
|
|
837
|
-
function parseDynamic(field, value) {
|
|
838
|
-
if (shouldApplyDynamicTyping(field)) {
|
|
839
|
-
if (value === "true" || value === "TRUE")
|
|
840
|
-
return true;
|
|
841
|
-
else if (value === "false" || value === "FALSE")
|
|
842
|
-
return false;
|
|
843
|
-
else if (testFloat(value))
|
|
844
|
-
return parseFloat(value);
|
|
845
|
-
else if (ISO_DATE.test(value))
|
|
846
|
-
return new Date(value);
|
|
847
|
-
else
|
|
848
|
-
return value === "" ? null : value;
|
|
849
|
-
}
|
|
850
|
-
return value;
|
|
851
|
-
}
|
|
852
|
-
function applyHeaderAndDynamicTypingAndTransformation() {
|
|
853
|
-
if (!_results || !_config.header && !_config.dynamicTyping && !_config.transform)
|
|
854
|
-
return _results;
|
|
855
|
-
function processRow(rowSource, i) {
|
|
856
|
-
var row = _config.header ? {} : [];
|
|
857
|
-
var j;
|
|
858
|
-
for (j = 0; j < rowSource.length; j++) {
|
|
859
|
-
var field = j;
|
|
860
|
-
var value = rowSource[j];
|
|
861
|
-
if (_config.header)
|
|
862
|
-
field = j >= _fields.length ? "__parsed_extra" : _fields[j];
|
|
863
|
-
if (_config.transform)
|
|
864
|
-
value = _config.transform(value, field);
|
|
865
|
-
value = parseDynamic(field, value);
|
|
866
|
-
if (field === "__parsed_extra") {
|
|
867
|
-
row[field] = row[field] || [];
|
|
868
|
-
row[field].push(value);
|
|
869
|
-
} else
|
|
870
|
-
row[field] = value;
|
|
871
|
-
}
|
|
872
|
-
if (_config.header) {
|
|
873
|
-
if (j > _fields.length)
|
|
874
|
-
addError("FieldMismatch", "TooManyFields", "Too many fields: expected " + _fields.length + " fields but parsed " + j, _rowCounter + i);
|
|
875
|
-
else if (j < _fields.length)
|
|
876
|
-
addError("FieldMismatch", "TooFewFields", "Too few fields: expected " + _fields.length + " fields but parsed " + j, _rowCounter + i);
|
|
877
|
-
}
|
|
878
|
-
return row;
|
|
879
|
-
}
|
|
880
|
-
var incrementBy = 1;
|
|
881
|
-
if (!_results.data.length || Array.isArray(_results.data[0])) {
|
|
882
|
-
_results.data = _results.data.map(processRow);
|
|
883
|
-
incrementBy = _results.data.length;
|
|
884
|
-
} else
|
|
885
|
-
_results.data = processRow(_results.data, 0);
|
|
886
|
-
if (_config.header && _results.meta)
|
|
887
|
-
_results.meta.fields = _fields;
|
|
888
|
-
_rowCounter += incrementBy;
|
|
889
|
-
return _results;
|
|
890
|
-
}
|
|
891
|
-
function guessDelimiter(input, newline, skipEmptyLines, comments, delimitersToGuess) {
|
|
892
|
-
var bestDelim, bestDelta, fieldCountPrevRow, maxFieldCount;
|
|
893
|
-
delimitersToGuess = delimitersToGuess || [",", " ", "|", ";", Papa.RECORD_SEP, Papa.UNIT_SEP];
|
|
894
|
-
for (var i = 0; i < delimitersToGuess.length; i++) {
|
|
895
|
-
var delim = delimitersToGuess[i];
|
|
896
|
-
var delta = 0, avgFieldCount = 0, emptyLinesCount = 0;
|
|
897
|
-
fieldCountPrevRow = void 0;
|
|
898
|
-
var preview = new Parser({
|
|
899
|
-
comments,
|
|
900
|
-
delimiter: delim,
|
|
901
|
-
newline,
|
|
902
|
-
preview: 10
|
|
903
|
-
}).parse(input);
|
|
904
|
-
for (var j = 0; j < preview.data.length; j++) {
|
|
905
|
-
if (skipEmptyLines && testEmptyLine(preview.data[j])) {
|
|
906
|
-
emptyLinesCount++;
|
|
907
|
-
continue;
|
|
908
|
-
}
|
|
909
|
-
var fieldCount = preview.data[j].length;
|
|
910
|
-
avgFieldCount += fieldCount;
|
|
911
|
-
if (typeof fieldCountPrevRow === "undefined") {
|
|
912
|
-
fieldCountPrevRow = fieldCount;
|
|
913
|
-
continue;
|
|
914
|
-
} else if (fieldCount > 0) {
|
|
915
|
-
delta += Math.abs(fieldCount - fieldCountPrevRow);
|
|
916
|
-
fieldCountPrevRow = fieldCount;
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
if (preview.data.length > 0)
|
|
920
|
-
avgFieldCount /= preview.data.length - emptyLinesCount;
|
|
921
|
-
if ((typeof bestDelta === "undefined" || delta <= bestDelta) && (typeof maxFieldCount === "undefined" || avgFieldCount > maxFieldCount) && avgFieldCount > 1.99) {
|
|
922
|
-
bestDelta = delta;
|
|
923
|
-
bestDelim = delim;
|
|
924
|
-
maxFieldCount = avgFieldCount;
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
_config.delimiter = bestDelim;
|
|
928
|
-
return {
|
|
929
|
-
successful: !!bestDelim,
|
|
930
|
-
bestDelimiter: bestDelim
|
|
931
|
-
};
|
|
932
|
-
}
|
|
933
|
-
function addError(type, code, msg, row) {
|
|
934
|
-
var error = {
|
|
935
|
-
type,
|
|
936
|
-
code,
|
|
937
|
-
message: msg
|
|
938
|
-
};
|
|
939
|
-
if (row !== void 0) {
|
|
940
|
-
error.row = row;
|
|
941
|
-
}
|
|
942
|
-
_results.errors.push(error);
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
function escapeRegExp(string) {
|
|
946
|
-
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
947
|
-
}
|
|
948
|
-
function Parser(config) {
|
|
949
|
-
config = config || {};
|
|
950
|
-
var delim = config.delimiter;
|
|
951
|
-
var newline = config.newline;
|
|
952
|
-
var comments = config.comments;
|
|
953
|
-
var step = config.step;
|
|
954
|
-
var preview = config.preview;
|
|
955
|
-
var fastMode = config.fastMode;
|
|
956
|
-
var quoteChar;
|
|
957
|
-
var renamedHeaders = null;
|
|
958
|
-
var headerParsed = false;
|
|
959
|
-
if (config.quoteChar === void 0 || config.quoteChar === null) {
|
|
960
|
-
quoteChar = '"';
|
|
961
|
-
} else {
|
|
962
|
-
quoteChar = config.quoteChar;
|
|
963
|
-
}
|
|
964
|
-
var escapeChar = quoteChar;
|
|
965
|
-
if (config.escapeChar !== void 0) {
|
|
966
|
-
escapeChar = config.escapeChar;
|
|
967
|
-
}
|
|
968
|
-
if (typeof delim !== "string" || Papa.BAD_DELIMITERS.indexOf(delim) > -1)
|
|
969
|
-
delim = ",";
|
|
970
|
-
if (comments === delim)
|
|
971
|
-
throw new Error("Comment character same as delimiter");
|
|
972
|
-
else if (comments === true)
|
|
973
|
-
comments = "#";
|
|
974
|
-
else if (typeof comments !== "string" || Papa.BAD_DELIMITERS.indexOf(comments) > -1)
|
|
975
|
-
comments = false;
|
|
976
|
-
if (newline !== "\n" && newline !== "\r" && newline !== "\r\n")
|
|
977
|
-
newline = "\n";
|
|
978
|
-
var cursor = 0;
|
|
979
|
-
var aborted = false;
|
|
980
|
-
this.parse = function(input, baseIndex, ignoreLastRow) {
|
|
981
|
-
if (typeof input !== "string")
|
|
982
|
-
throw new Error("Input must be a string");
|
|
983
|
-
var inputLen = input.length, delimLen = delim.length, newlineLen = newline.length, commentsLen = comments.length;
|
|
984
|
-
var stepIsFunction = isFunction(step);
|
|
985
|
-
cursor = 0;
|
|
986
|
-
var data = [], errors = [], row = [], lastCursor = 0;
|
|
987
|
-
if (!input)
|
|
988
|
-
return returnable();
|
|
989
|
-
if (fastMode || fastMode !== false && input.indexOf(quoteChar) === -1) {
|
|
990
|
-
var rows = input.split(newline);
|
|
991
|
-
for (var i = 0; i < rows.length; i++) {
|
|
992
|
-
row = rows[i];
|
|
993
|
-
cursor += row.length;
|
|
994
|
-
if (i !== rows.length - 1)
|
|
995
|
-
cursor += newline.length;
|
|
996
|
-
else if (ignoreLastRow)
|
|
997
|
-
return returnable();
|
|
998
|
-
if (comments && row.substring(0, commentsLen) === comments)
|
|
999
|
-
continue;
|
|
1000
|
-
if (stepIsFunction) {
|
|
1001
|
-
data = [];
|
|
1002
|
-
pushRow(row.split(delim));
|
|
1003
|
-
doStep();
|
|
1004
|
-
if (aborted)
|
|
1005
|
-
return returnable();
|
|
1006
|
-
} else
|
|
1007
|
-
pushRow(row.split(delim));
|
|
1008
|
-
if (preview && i >= preview) {
|
|
1009
|
-
data = data.slice(0, preview);
|
|
1010
|
-
return returnable(true);
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
return returnable();
|
|
1014
|
-
}
|
|
1015
|
-
var nextDelim = input.indexOf(delim, cursor);
|
|
1016
|
-
var nextNewline = input.indexOf(newline, cursor);
|
|
1017
|
-
var quoteCharRegex = new RegExp(escapeRegExp(escapeChar) + escapeRegExp(quoteChar), "g");
|
|
1018
|
-
var quoteSearch = input.indexOf(quoteChar, cursor);
|
|
1019
|
-
for (; ; ) {
|
|
1020
|
-
if (input[cursor] === quoteChar) {
|
|
1021
|
-
quoteSearch = cursor;
|
|
1022
|
-
cursor++;
|
|
1023
|
-
for (; ; ) {
|
|
1024
|
-
quoteSearch = input.indexOf(quoteChar, quoteSearch + 1);
|
|
1025
|
-
if (quoteSearch === -1) {
|
|
1026
|
-
if (!ignoreLastRow) {
|
|
1027
|
-
errors.push({
|
|
1028
|
-
type: "Quotes",
|
|
1029
|
-
code: "MissingQuotes",
|
|
1030
|
-
message: "Quoted field unterminated",
|
|
1031
|
-
row: data.length,
|
|
1032
|
-
// row has yet to be inserted
|
|
1033
|
-
index: cursor
|
|
1034
|
-
});
|
|
1035
|
-
}
|
|
1036
|
-
return finish();
|
|
1037
|
-
}
|
|
1038
|
-
if (quoteSearch === inputLen - 1) {
|
|
1039
|
-
var value = input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar);
|
|
1040
|
-
return finish(value);
|
|
1041
|
-
}
|
|
1042
|
-
if (quoteChar === escapeChar && input[quoteSearch + 1] === escapeChar) {
|
|
1043
|
-
quoteSearch++;
|
|
1044
|
-
continue;
|
|
1045
|
-
}
|
|
1046
|
-
if (quoteChar !== escapeChar && quoteSearch !== 0 && input[quoteSearch - 1] === escapeChar) {
|
|
1047
|
-
continue;
|
|
1048
|
-
}
|
|
1049
|
-
if (nextDelim !== -1 && nextDelim < quoteSearch + 1) {
|
|
1050
|
-
nextDelim = input.indexOf(delim, quoteSearch + 1);
|
|
1051
|
-
}
|
|
1052
|
-
if (nextNewline !== -1 && nextNewline < quoteSearch + 1) {
|
|
1053
|
-
nextNewline = input.indexOf(newline, quoteSearch + 1);
|
|
1054
|
-
}
|
|
1055
|
-
var checkUpTo = nextNewline === -1 ? nextDelim : Math.min(nextDelim, nextNewline);
|
|
1056
|
-
var spacesBetweenQuoteAndDelimiter = extraSpaces(checkUpTo);
|
|
1057
|
-
if (input.substr(quoteSearch + 1 + spacesBetweenQuoteAndDelimiter, delimLen) === delim) {
|
|
1058
|
-
row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
|
|
1059
|
-
cursor = quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen;
|
|
1060
|
-
if (input[quoteSearch + 1 + spacesBetweenQuoteAndDelimiter + delimLen] !== quoteChar) {
|
|
1061
|
-
quoteSearch = input.indexOf(quoteChar, cursor);
|
|
1062
|
-
}
|
|
1063
|
-
nextDelim = input.indexOf(delim, cursor);
|
|
1064
|
-
nextNewline = input.indexOf(newline, cursor);
|
|
1065
|
-
break;
|
|
1066
|
-
}
|
|
1067
|
-
var spacesBetweenQuoteAndNewLine = extraSpaces(nextNewline);
|
|
1068
|
-
if (input.substring(quoteSearch + 1 + spacesBetweenQuoteAndNewLine, quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen) === newline) {
|
|
1069
|
-
row.push(input.substring(cursor, quoteSearch).replace(quoteCharRegex, quoteChar));
|
|
1070
|
-
saveRow(quoteSearch + 1 + spacesBetweenQuoteAndNewLine + newlineLen);
|
|
1071
|
-
nextDelim = input.indexOf(delim, cursor);
|
|
1072
|
-
quoteSearch = input.indexOf(quoteChar, cursor);
|
|
1073
|
-
if (stepIsFunction) {
|
|
1074
|
-
doStep();
|
|
1075
|
-
if (aborted)
|
|
1076
|
-
return returnable();
|
|
1077
|
-
}
|
|
1078
|
-
if (preview && data.length >= preview)
|
|
1079
|
-
return returnable(true);
|
|
1080
|
-
break;
|
|
1081
|
-
}
|
|
1082
|
-
errors.push({
|
|
1083
|
-
type: "Quotes",
|
|
1084
|
-
code: "InvalidQuotes",
|
|
1085
|
-
message: "Trailing quote on quoted field is malformed",
|
|
1086
|
-
row: data.length,
|
|
1087
|
-
// row has yet to be inserted
|
|
1088
|
-
index: cursor
|
|
1089
|
-
});
|
|
1090
|
-
quoteSearch++;
|
|
1091
|
-
continue;
|
|
1092
|
-
}
|
|
1093
|
-
continue;
|
|
1094
|
-
}
|
|
1095
|
-
if (comments && row.length === 0 && input.substring(cursor, cursor + commentsLen) === comments) {
|
|
1096
|
-
if (nextNewline === -1)
|
|
1097
|
-
return returnable();
|
|
1098
|
-
cursor = nextNewline + newlineLen;
|
|
1099
|
-
nextNewline = input.indexOf(newline, cursor);
|
|
1100
|
-
nextDelim = input.indexOf(delim, cursor);
|
|
1101
|
-
continue;
|
|
1102
|
-
}
|
|
1103
|
-
if (nextDelim !== -1 && (nextDelim < nextNewline || nextNewline === -1)) {
|
|
1104
|
-
row.push(input.substring(cursor, nextDelim));
|
|
1105
|
-
cursor = nextDelim + delimLen;
|
|
1106
|
-
nextDelim = input.indexOf(delim, cursor);
|
|
1107
|
-
continue;
|
|
1108
|
-
}
|
|
1109
|
-
if (nextNewline !== -1) {
|
|
1110
|
-
row.push(input.substring(cursor, nextNewline));
|
|
1111
|
-
saveRow(nextNewline + newlineLen);
|
|
1112
|
-
if (stepIsFunction) {
|
|
1113
|
-
doStep();
|
|
1114
|
-
if (aborted)
|
|
1115
|
-
return returnable();
|
|
1116
|
-
}
|
|
1117
|
-
if (preview && data.length >= preview)
|
|
1118
|
-
return returnable(true);
|
|
1119
|
-
continue;
|
|
1120
|
-
}
|
|
1121
|
-
break;
|
|
1122
|
-
}
|
|
1123
|
-
return finish();
|
|
1124
|
-
function pushRow(row2) {
|
|
1125
|
-
data.push(row2);
|
|
1126
|
-
lastCursor = cursor;
|
|
1127
|
-
}
|
|
1128
|
-
function extraSpaces(index) {
|
|
1129
|
-
var spaceLength = 0;
|
|
1130
|
-
if (index !== -1) {
|
|
1131
|
-
var textBetweenClosingQuoteAndIndex = input.substring(quoteSearch + 1, index);
|
|
1132
|
-
if (textBetweenClosingQuoteAndIndex && textBetweenClosingQuoteAndIndex.trim() === "") {
|
|
1133
|
-
spaceLength = textBetweenClosingQuoteAndIndex.length;
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
return spaceLength;
|
|
1137
|
-
}
|
|
1138
|
-
function finish(value2) {
|
|
1139
|
-
if (ignoreLastRow)
|
|
1140
|
-
return returnable();
|
|
1141
|
-
if (typeof value2 === "undefined")
|
|
1142
|
-
value2 = input.substring(cursor);
|
|
1143
|
-
row.push(value2);
|
|
1144
|
-
cursor = inputLen;
|
|
1145
|
-
pushRow(row);
|
|
1146
|
-
if (stepIsFunction)
|
|
1147
|
-
doStep();
|
|
1148
|
-
return returnable();
|
|
1149
|
-
}
|
|
1150
|
-
function saveRow(newCursor) {
|
|
1151
|
-
cursor = newCursor;
|
|
1152
|
-
pushRow(row);
|
|
1153
|
-
row = [];
|
|
1154
|
-
nextNewline = input.indexOf(newline, cursor);
|
|
1155
|
-
}
|
|
1156
|
-
function returnable(stopped) {
|
|
1157
|
-
if (config.header && !baseIndex && data.length && !headerParsed) {
|
|
1158
|
-
const result = data[0];
|
|
1159
|
-
const headerCount = /* @__PURE__ */ Object.create(null);
|
|
1160
|
-
const usedHeaders = new Set(result);
|
|
1161
|
-
let duplicateHeaders = false;
|
|
1162
|
-
for (let i2 = 0; i2 < result.length; i2++) {
|
|
1163
|
-
let header = result[i2];
|
|
1164
|
-
if (isFunction(config.transformHeader))
|
|
1165
|
-
header = config.transformHeader(header, i2);
|
|
1166
|
-
if (!headerCount[header]) {
|
|
1167
|
-
headerCount[header] = 1;
|
|
1168
|
-
result[i2] = header;
|
|
1169
|
-
} else {
|
|
1170
|
-
let newHeader;
|
|
1171
|
-
let suffixCount = headerCount[header];
|
|
1172
|
-
do {
|
|
1173
|
-
newHeader = `${header}_${suffixCount}`;
|
|
1174
|
-
suffixCount++;
|
|
1175
|
-
} while (usedHeaders.has(newHeader));
|
|
1176
|
-
usedHeaders.add(newHeader);
|
|
1177
|
-
result[i2] = newHeader;
|
|
1178
|
-
headerCount[header]++;
|
|
1179
|
-
duplicateHeaders = true;
|
|
1180
|
-
if (renamedHeaders === null) {
|
|
1181
|
-
renamedHeaders = {};
|
|
1182
|
-
}
|
|
1183
|
-
renamedHeaders[newHeader] = header;
|
|
1184
|
-
}
|
|
1185
|
-
usedHeaders.add(header);
|
|
1186
|
-
}
|
|
1187
|
-
if (duplicateHeaders) {
|
|
1188
|
-
console.warn("Duplicate headers found and renamed.");
|
|
1189
|
-
}
|
|
1190
|
-
headerParsed = true;
|
|
1191
|
-
}
|
|
1192
|
-
return {
|
|
1193
|
-
data,
|
|
1194
|
-
errors,
|
|
1195
|
-
meta: {
|
|
1196
|
-
delimiter: delim,
|
|
1197
|
-
linebreak: newline,
|
|
1198
|
-
aborted,
|
|
1199
|
-
truncated: !!stopped,
|
|
1200
|
-
cursor: lastCursor + (baseIndex || 0),
|
|
1201
|
-
renamedHeaders
|
|
1202
|
-
}
|
|
1203
|
-
};
|
|
1204
|
-
}
|
|
1205
|
-
function doStep() {
|
|
1206
|
-
step(returnable());
|
|
1207
|
-
data = [];
|
|
1208
|
-
errors = [];
|
|
1209
|
-
}
|
|
1210
|
-
};
|
|
1211
|
-
this.abort = function() {
|
|
1212
|
-
aborted = true;
|
|
1213
|
-
};
|
|
1214
|
-
this.getCharIndex = function() {
|
|
1215
|
-
return cursor;
|
|
1216
|
-
};
|
|
1217
|
-
}
|
|
1218
|
-
function newWorker() {
|
|
1219
|
-
if (!Papa.WORKERS_SUPPORTED)
|
|
1220
|
-
return false;
|
|
1221
|
-
var workerUrl = getWorkerBlob();
|
|
1222
|
-
var w = new global.Worker(workerUrl);
|
|
1223
|
-
w.onmessage = mainThreadReceivedMessage;
|
|
1224
|
-
w.id = workerIdCounter++;
|
|
1225
|
-
workers[w.id] = w;
|
|
1226
|
-
return w;
|
|
1227
|
-
}
|
|
1228
|
-
function mainThreadReceivedMessage(e) {
|
|
1229
|
-
var msg = e.data;
|
|
1230
|
-
var worker = workers[msg.workerId];
|
|
1231
|
-
var aborted = false;
|
|
1232
|
-
if (msg.error)
|
|
1233
|
-
worker.userError(msg.error, msg.file);
|
|
1234
|
-
else if (msg.results && msg.results.data) {
|
|
1235
|
-
var abort = function() {
|
|
1236
|
-
aborted = true;
|
|
1237
|
-
completeWorker(msg.workerId, { data: [], errors: [], meta: { aborted: true } });
|
|
1238
|
-
};
|
|
1239
|
-
var handle = {
|
|
1240
|
-
abort,
|
|
1241
|
-
pause: notImplemented,
|
|
1242
|
-
resume: notImplemented
|
|
1243
|
-
};
|
|
1244
|
-
if (isFunction(worker.userStep)) {
|
|
1245
|
-
for (var i = 0; i < msg.results.data.length; i++) {
|
|
1246
|
-
worker.userStep({
|
|
1247
|
-
data: msg.results.data[i],
|
|
1248
|
-
errors: msg.results.errors,
|
|
1249
|
-
meta: msg.results.meta
|
|
1250
|
-
}, handle);
|
|
1251
|
-
if (aborted)
|
|
1252
|
-
break;
|
|
1253
|
-
}
|
|
1254
|
-
delete msg.results;
|
|
1255
|
-
} else if (isFunction(worker.userChunk)) {
|
|
1256
|
-
worker.userChunk(msg.results, handle, msg.file);
|
|
1257
|
-
delete msg.results;
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
if (msg.finished && !aborted)
|
|
1261
|
-
completeWorker(msg.workerId, msg.results);
|
|
1262
|
-
}
|
|
1263
|
-
function completeWorker(workerId, results) {
|
|
1264
|
-
var worker = workers[workerId];
|
|
1265
|
-
if (isFunction(worker.userComplete))
|
|
1266
|
-
worker.userComplete(results);
|
|
1267
|
-
worker.terminate();
|
|
1268
|
-
delete workers[workerId];
|
|
1269
|
-
}
|
|
1270
|
-
function notImplemented() {
|
|
1271
|
-
throw new Error("Not implemented.");
|
|
1272
|
-
}
|
|
1273
|
-
function workerThreadReceivedMessage(e) {
|
|
1274
|
-
var msg = e.data;
|
|
1275
|
-
if (typeof Papa.WORKER_ID === "undefined" && msg)
|
|
1276
|
-
Papa.WORKER_ID = msg.workerId;
|
|
1277
|
-
if (typeof msg.input === "string") {
|
|
1278
|
-
global.postMessage({
|
|
1279
|
-
workerId: Papa.WORKER_ID,
|
|
1280
|
-
results: Papa.parse(msg.input, msg.config),
|
|
1281
|
-
finished: true
|
|
1282
|
-
});
|
|
1283
|
-
} else if (global.File && msg.input instanceof File || msg.input instanceof Object) {
|
|
1284
|
-
var results = Papa.parse(msg.input, msg.config);
|
|
1285
|
-
if (results)
|
|
1286
|
-
global.postMessage({
|
|
1287
|
-
workerId: Papa.WORKER_ID,
|
|
1288
|
-
results,
|
|
1289
|
-
finished: true
|
|
1290
|
-
});
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
function copy(obj) {
|
|
1294
|
-
if (typeof obj !== "object" || obj === null)
|
|
1295
|
-
return obj;
|
|
1296
|
-
var cpy = Array.isArray(obj) ? [] : {};
|
|
1297
|
-
for (var key in obj)
|
|
1298
|
-
cpy[key] = copy(obj[key]);
|
|
1299
|
-
return cpy;
|
|
1300
|
-
}
|
|
1301
|
-
function bindFunction(f, self2) {
|
|
1302
|
-
return function() {
|
|
1303
|
-
f.apply(self2, arguments);
|
|
1304
|
-
};
|
|
1305
|
-
}
|
|
1306
|
-
function isFunction(func) {
|
|
1307
|
-
return typeof func === "function";
|
|
1308
|
-
}
|
|
1309
|
-
return Papa;
|
|
1310
|
-
});
|
|
1311
|
-
}
|
|
1312
|
-
});
|
|
1313
|
-
export default require_papaparse();
|
|
1314
|
-
/*! Bundled license information:
|
|
1315
|
-
|
|
1316
|
-
papaparse/papaparse.js:
|
|
1317
|
-
(* @license
|
|
1318
|
-
Papa Parse
|
|
1319
|
-
v5.5.3
|
|
1320
|
-
https://github.com/mholt/PapaParse
|
|
1321
|
-
License: MIT
|
|
1322
|
-
*)
|
|
1323
|
-
*/
|
|
1324
|
-
//# sourceMappingURL=papaparse-4KNMW7KX.js.map
|