@loaders.gl/csv 4.0.0-beta.3 → 4.0.0-beta.5

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 (2) hide show
  1. package/dist/dist.dev.js +4 -55
  2. package/package.json +4 -4
package/dist/dist.dev.js CHANGED
@@ -233,7 +233,6 @@ var __exports__ = (() => {
233
233
  };
234
234
  return batch;
235
235
  }
236
- // HELPERS
237
236
  _reallocateColumns() {
238
237
  if (this.length < this.allocated) {
239
238
  return;
@@ -297,7 +296,6 @@ var __exports__ = (() => {
297
296
  }
298
297
  return false;
299
298
  }
300
- /** @deprecated Use addArrayRow or addObjectRow */
301
299
  addRow(row) {
302
300
  if (this.limitReached()) {
303
301
  return;
@@ -311,7 +309,6 @@ var __exports__ = (() => {
311
309
  this.addObjectRow(row);
312
310
  }
313
311
  }
314
- /** Add one row to the batch */
315
312
  addArrayRow(row) {
316
313
  if (!this.aggregator) {
317
314
  const TableBatchType = this._getTableBatchType();
@@ -319,7 +316,6 @@ var __exports__ = (() => {
319
316
  }
320
317
  this.aggregator.addArrayRow(row);
321
318
  }
322
- /** Add one row to the batch */
323
319
  addObjectRow(row) {
324
320
  if (!this.aggregator) {
325
321
  const TableBatchType = this._getTableBatchType();
@@ -327,7 +323,6 @@ var __exports__ = (() => {
327
323
  }
328
324
  this.aggregator.addObjectRow(row);
329
325
  }
330
- /** Mark an incoming raw memory chunk has completed */
331
326
  chunkComplete(chunk) {
332
327
  if (chunk instanceof ArrayBuffer) {
333
328
  this.bytesUsed += chunk.byteLength;
@@ -343,7 +338,6 @@ var __exports__ = (() => {
343
338
  getFinalBatch(options) {
344
339
  return this._getBatch(options);
345
340
  }
346
- // INTERNAL
347
341
  _estimateRowMB(row) {
348
342
  return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
349
343
  }
@@ -365,9 +359,6 @@ var __exports__ = (() => {
365
359
  this.lastBatchEmittedMs = Date.now();
366
360
  return true;
367
361
  }
368
- /**
369
- * bytesUsed can be set via chunkComplete or via getBatch*
370
- */
371
362
  _getBatch(options) {
372
363
  if (!this.aggregator) {
373
364
  return null;
@@ -550,9 +541,6 @@ var __exports__ = (() => {
550
541
  this._values.enqueue(value);
551
542
  }
552
543
  }
553
- /**
554
- * @returns a Promise for an IteratorResult
555
- */
556
544
  next() {
557
545
  if (this._values.length > 0) {
558
546
  const value = this._values.dequeue();
@@ -590,19 +578,12 @@ var __exports__ = (() => {
590
578
  BYTE_ORDER_MARK,
591
579
  BAD_DELIMITERS: ["\r", "\n", '"', BYTE_ORDER_MARK],
592
580
  WORKERS_SUPPORTED: false,
593
- // !IS_WORKER && !!globalThis.Worker
594
581
  NODE_STREAM_INPUT: 1,
595
- // Configurable chunk sizes for local and remote files, respectively
596
582
  LocalChunkSize: 1024 * 1024 * 10,
597
- // 10 M,
598
583
  RemoteChunkSize: 1024 * 1024 * 5,
599
- // 5 M,
600
584
  DefaultDelimiter: ",",
601
- // Used if not specified and detection fail,
602
- // Exposed for testing and development only
603
585
  Parser,
604
586
  ParserHandle,
605
- // BEGIN FORK
606
587
  ChunkStreamer,
607
588
  StringStreamer
608
589
  };
@@ -876,7 +857,6 @@ var __exports__ = (() => {
876
857
  var _delimiterError;
877
858
  var _fields = [];
878
859
  var _results = {
879
- // The last results returned from the parser
880
860
  data: [],
881
861
  errors: [],
882
862
  meta: {}
@@ -1203,7 +1183,6 @@ var __exports__ = (() => {
1203
1183
  code: "MissingQuotes",
1204
1184
  message: "Quoted field unterminated",
1205
1185
  row: data.length,
1206
- // row has yet to be inserted
1207
1186
  index: cursor
1208
1187
  });
1209
1188
  }
@@ -1255,7 +1234,6 @@ var __exports__ = (() => {
1255
1234
  code: "InvalidQuotes",
1256
1235
  message: "Trailing quote on quoted field is malformed",
1257
1236
  row: data.length,
1258
- // row has yet to be inserted
1259
1237
  index: cursor
1260
1238
  });
1261
1239
  quoteSearch++;
@@ -1415,26 +1393,18 @@ var __exports__ = (() => {
1415
1393
  parse: async (arrayBuffer, options) => parseCSV(new TextDecoder().decode(arrayBuffer), options),
1416
1394
  parseText: (text, options) => parseCSV(text, options),
1417
1395
  parseInBatches: parseCSVInBatches,
1418
- // @ts-ignore
1419
- // testText: null,
1420
1396
  options: {
1421
1397
  csv: {
1422
1398
  shape: DEFAULT_CSV_SHAPE,
1423
- // 'object-row-table'
1424
1399
  optimizeMemoryUsage: false,
1425
- // CSV options
1426
1400
  header: "auto",
1427
1401
  columnPrefix: "column",
1428
- // delimiter: auto
1429
- // newline: auto
1430
1402
  quoteChar: '"',
1431
1403
  escapeChar: '"',
1432
1404
  dynamicTyping: true,
1433
1405
  comments: false,
1434
1406
  skipEmptyLines: true,
1435
- // transform: null?
1436
1407
  delimitersToGuess: [",", " ", "|", ";"]
1437
- // fastMode: auto
1438
1408
  }
1439
1409
  }
1440
1410
  };
@@ -1447,11 +1417,9 @@ var __exports__ = (() => {
1447
1417
  const header = csvOptions.header === "auto" ? isHeaderRow(firstRow) : Boolean(csvOptions.header);
1448
1418
  const parseWithHeader = header;
1449
1419
  const papaparseConfig = {
1450
- // dynamicTyping: true,
1451
1420
  ...csvOptions,
1452
1421
  header: parseWithHeader,
1453
1422
  download: false,
1454
- // We handle loading, no need for papaparse to do it for us
1455
1423
  transformHeader: parseWithHeader ? duplicateColumnTransformer() : void 0,
1456
1424
  error: (e) => {
1457
1425
  throw new Error(e);
@@ -1493,24 +1461,11 @@ var __exports__ = (() => {
1493
1461
  let tableBatchBuilder = null;
1494
1462
  let schema = null;
1495
1463
  const config = {
1496
- // dynamicTyping: true, // Convert numbers and boolean values in rows from strings,
1497
1464
  ...csvOptions,
1498
1465
  header: false,
1499
- // Unfortunately, header detection is not automatic and does not infer shapes
1500
1466
  download: false,
1501
- // We handle loading, no need for papaparse to do it for us
1502
- // chunkSize is set to 5MB explicitly (same as Papaparse default) due to a bug where the
1503
- // streaming parser gets stuck if skipEmptyLines and a step callback are both supplied.
1504
- // See https://github.com/mholt/PapaParse/issues/465
1505
1467
  chunkSize: 1024 * 1024 * 5,
1506
- // skipEmptyLines is set to a boolean value if supplied. Greedy is set to true
1507
- // skipEmptyLines is handled manually given two bugs where the streaming parser gets stuck if
1508
- // both of the skipEmptyLines and step callback options are provided:
1509
- // - true doesn't work unless chunkSize is set: https://github.com/mholt/PapaParse/issues/465
1510
- // - greedy doesn't work: https://github.com/mholt/PapaParse/issues/825
1511
1468
  skipEmptyLines: false,
1512
- // step is called on every row
1513
- // eslint-disable-next-line complexity, max-statements
1514
1469
  step(results) {
1515
1470
  let row = results.data;
1516
1471
  if (csvOptions.skipEmptyLines) {
@@ -1538,14 +1493,10 @@ var __exports__ = (() => {
1538
1493
  row = JSON.parse(JSON.stringify(row));
1539
1494
  }
1540
1495
  const shape = csvOptions.shape || DEFAULT_CSV_SHAPE;
1541
- tableBatchBuilder = tableBatchBuilder || new TableBatchBuilder(
1542
- // @ts-expect-error TODO this is not a proper schema
1543
- schema,
1544
- {
1545
- shape,
1546
- ...options
1547
- }
1548
- );
1496
+ tableBatchBuilder = tableBatchBuilder || new TableBatchBuilder(schema, {
1497
+ shape,
1498
+ ...options
1499
+ });
1549
1500
  try {
1550
1501
  tableBatchBuilder.addRow(row);
1551
1502
  const batch = tableBatchBuilder && tableBatchBuilder.getFullBatch({
@@ -1558,7 +1509,6 @@ var __exports__ = (() => {
1558
1509
  asyncQueue.enqueue(error);
1559
1510
  }
1560
1511
  },
1561
- // complete is called when all rows have been read
1562
1512
  complete(results) {
1563
1513
  try {
1564
1514
  const bytesUsed = results.meta.cursor;
@@ -1828,7 +1778,6 @@ var __exports__ = (() => {
1828
1778
  csv: {
1829
1779
  useDisplayNames: false
1830
1780
  },
1831
- /** @deprecated use csv.displayNames */
1832
1781
  useDisplayNames: false
1833
1782
  },
1834
1783
  text: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/csv",
3
- "version": "4.0.0-beta.3",
3
+ "version": "4.0.0-beta.5",
4
4
  "description": "Framework-independent loader for CSV and DSV table formats",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -38,11 +38,11 @@
38
38
  "build-bundle": "ocular-bundle ./src/index.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@loaders.gl/loader-utils": "4.0.0-beta.3",
42
- "@loaders.gl/schema": "4.0.0-beta.3"
41
+ "@loaders.gl/loader-utils": "4.0.0-beta.5",
42
+ "@loaders.gl/schema": "4.0.0-beta.5"
43
43
  },
44
44
  "devDependencies": {
45
45
  "d3-dsv": "^1.2.0"
46
46
  },
47
- "gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af"
47
+ "gitHead": "a6f5a0d1a316cc22396e5a4d480c14329d1ef146"
48
48
  }