@loaders.gl/csv 4.0.0-alpha.22 → 4.0.0-alpha.24
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/dist/dist.min.js +28 -26
- package/dist/es5/csv-loader.js +33 -30
- package/dist/es5/csv-loader.js.map +1 -1
- package/dist/esm/csv-loader.js +28 -28
- package/dist/esm/csv-loader.js.map +1 -1
- package/dist/src/bundle.d.ts.map +1 -0
- package/dist/{csv-loader.d.ts → src/csv-loader.d.ts} +1 -1
- package/dist/src/csv-loader.d.ts.map +1 -0
- package/dist/src/csv-writer.d.ts.map +1 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/lib/encoders/encode-csv.d.ts.map +1 -0
- package/dist/src/papaparse/async-iterator-streamer.d.ts.map +1 -0
- package/dist/src/papaparse/papaparse.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +4 -4
- package/src/csv-loader.ts +44 -53
- package/dist/bundle.d.ts.map +0 -1
- package/dist/bundle.js +0 -5
- package/dist/csv-loader.d.ts.map +0 -1
- package/dist/csv-loader.js +0 -268
- package/dist/csv-writer.d.ts.map +0 -1
- package/dist/csv-writer.js +0 -23
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/lib/encoders/encode-csv.d.ts.map +0 -1
- package/dist/lib/encoders/encode-csv.js +0 -50
- package/dist/papaparse/async-iterator-streamer.d.ts.map +0 -1
- package/dist/papaparse/async-iterator-streamer.js +0 -63
- package/dist/papaparse/papaparse.d.ts.map +0 -1
- package/dist/papaparse/papaparse.js +0 -935
- /package/dist/{bundle.d.ts → src/bundle.d.ts} +0 -0
- /package/dist/{csv-writer.d.ts → src/csv-writer.d.ts} +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{lib → src/lib}/encoders/encode-csv.d.ts +0 -0
- /package/dist/{papaparse → src/papaparse}/async-iterator-streamer.d.ts +0 -0
- /package/dist/{papaparse → src/papaparse}/papaparse.d.ts +0 -0
package/dist/csv-writer.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.CSVWriter = void 0;
|
|
5
|
-
const encode_csv_1 = require("./lib/encoders/encode-csv");
|
|
6
|
-
const DEFAULT_WRITER_OPTIONS = {
|
|
7
|
-
csv: {
|
|
8
|
-
useDisplayNames: false
|
|
9
|
-
},
|
|
10
|
-
useDisplayNames: false
|
|
11
|
-
};
|
|
12
|
-
exports.CSVWriter = {
|
|
13
|
-
id: 'csv',
|
|
14
|
-
version: 'latest',
|
|
15
|
-
module: 'csv',
|
|
16
|
-
name: 'CSV',
|
|
17
|
-
extensions: ['csv'],
|
|
18
|
-
mimeTypes: ['text/csv'],
|
|
19
|
-
options: DEFAULT_WRITER_OPTIONS,
|
|
20
|
-
text: true,
|
|
21
|
-
encode: async (table, options) => new TextEncoder().encode((0, encode_csv_1.encodeTableAsCSV)(table, options)).buffer,
|
|
22
|
-
encodeText: (table, options) => (0, encode_csv_1.encodeTableAsCSV)(table, options)
|
|
23
|
-
};
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAEvC,YAAY,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.CSVWriter = exports.CSVLoader = void 0;
|
|
5
|
-
var csv_loader_1 = require("./csv-loader");
|
|
6
|
-
Object.defineProperty(exports, "CSVLoader", { enumerable: true, get: function () { return csv_loader_1.CSVLoader; } });
|
|
7
|
-
var csv_writer_1 = require("./csv-writer");
|
|
8
|
-
Object.defineProperty(exports, "CSVWriter", { enumerable: true, get: function () { return csv_writer_1.CSVWriter; } });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encode-csv.d.ts","sourceRoot":"","sources":["../../../src/lib/encoders/encode-csv.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,KAAK,EAAwC,MAAM,oBAAoB,CAAC;AAKhF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,CAAC,EAAE;QACJ,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B,CAAC;IACF,kBAAkB;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,EACZ,OAAO,GAAE,gBAAiD,GACzD,MAAM,CAsBR"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl, MIT license
|
|
3
|
-
// Copyright 2022 Foursquare Labs, Inc.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.encodeTableAsCSV = void 0;
|
|
6
|
-
const schema_1 = require("@loaders.gl/schema");
|
|
7
|
-
const d3_dsv_1 = require("d3-dsv");
|
|
8
|
-
/**
|
|
9
|
-
* Encode a Table object as CSV
|
|
10
|
-
*/
|
|
11
|
-
function encodeTableAsCSV(table, options = { csv: { useDisplayNames: true } }) {
|
|
12
|
-
const useDisplayNames = options.useDisplayNames || options.csv?.useDisplayNames;
|
|
13
|
-
const fields = table.schema?.fields || [];
|
|
14
|
-
const columnNames = fields.map((f) => {
|
|
15
|
-
// This is a leaky abstraction, assuming Kepler metadata
|
|
16
|
-
const displayName = f.metadata?.displayName;
|
|
17
|
-
return useDisplayNames && typeof displayName === 'string' ? displayName : f.name;
|
|
18
|
-
});
|
|
19
|
-
const formattedData = [columnNames];
|
|
20
|
-
for (const row of (0, schema_1.makeArrayRowIterator)(table)) {
|
|
21
|
-
const formattedRow = [];
|
|
22
|
-
for (let columnIndex = 0; columnIndex < (0, schema_1.getTableNumCols)(table); ++columnIndex) {
|
|
23
|
-
const value = row[columnIndex];
|
|
24
|
-
formattedRow[columnIndex] = preformatFieldValue(value);
|
|
25
|
-
}
|
|
26
|
-
formattedData.push(formattedRow);
|
|
27
|
-
}
|
|
28
|
-
return (0, d3_dsv_1.csvFormatRows)(formattedData);
|
|
29
|
-
}
|
|
30
|
-
exports.encodeTableAsCSV = encodeTableAsCSV;
|
|
31
|
-
/**
|
|
32
|
-
* Stringifies a value
|
|
33
|
-
* @todo Why is it called parse?
|
|
34
|
-
*/
|
|
35
|
-
const preformatFieldValue = (value) => {
|
|
36
|
-
if (value === null || value === undefined) {
|
|
37
|
-
// TODO: It would be nice to distinguish between missing values and the empty string
|
|
38
|
-
// https://github.com/d3/d3-dsv/issues/84
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
if (value instanceof Date) {
|
|
42
|
-
// d3-dsv formats dates without timezones if they don't have time info;
|
|
43
|
-
// this forces them to always use fully-qualified ISO time strings
|
|
44
|
-
return value.toISOString();
|
|
45
|
-
}
|
|
46
|
-
if (typeof value === 'object') {
|
|
47
|
-
return JSON.stringify(value);
|
|
48
|
-
}
|
|
49
|
-
return String(value);
|
|
50
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-iterator-streamer.d.ts","sourceRoot":"","sources":["../../src/papaparse/async-iterator-streamer.ts"],"names":[],"mappings":"AAWA,iBAAwB,qBAAqB,CAAC,MAAM,KAAA,QAwDnD;kBAxDuB,qBAAqB;;;eAArB,qBAAqB"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
// A custom papaparse `Streamer` for async iterators
|
|
4
|
-
// Ideally this can be contributed back to papaparse
|
|
5
|
-
// Or papaparse can expose Streamer API so we can extend without forking.
|
|
6
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
/* eslint-disable no-invalid-this */
|
|
11
|
-
// Note: papaparse is not an ES6 module
|
|
12
|
-
const papaparse_1 = __importDefault(require("./papaparse"));
|
|
13
|
-
const { ChunkStreamer } = papaparse_1.default;
|
|
14
|
-
function AsyncIteratorStreamer(config) {
|
|
15
|
-
config = config || {};
|
|
16
|
-
ChunkStreamer.call(this, config);
|
|
17
|
-
this.textDecoder = new TextDecoder(this._config.encoding);
|
|
18
|
-
// Implement ChunkStreamer base class methods
|
|
19
|
-
// this.pause = function() {
|
|
20
|
-
// ChunkStreamer.prototype.pause.apply(this, arguments);
|
|
21
|
-
// };
|
|
22
|
-
// this.resume = function() {
|
|
23
|
-
// ChunkStreamer.prototype.resume.apply(this, arguments);
|
|
24
|
-
// this._input.resume();
|
|
25
|
-
// };
|
|
26
|
-
this.stream = async function (asyncIterator) {
|
|
27
|
-
this._input = asyncIterator;
|
|
28
|
-
try {
|
|
29
|
-
// ES2018 version
|
|
30
|
-
// TODO - check for pause and abort flags?
|
|
31
|
-
for await (const chunk of asyncIterator) {
|
|
32
|
-
this.parseChunk(this.getStringChunk(chunk));
|
|
33
|
-
}
|
|
34
|
-
// ES5 VERSION
|
|
35
|
-
// while (true) {
|
|
36
|
-
// asyncIterator.next().then(function(value) {
|
|
37
|
-
// if (value.done) {
|
|
38
|
-
// // finalize iterator?
|
|
39
|
-
// }
|
|
40
|
-
// }
|
|
41
|
-
// const = await ;
|
|
42
|
-
// if (done) return total;
|
|
43
|
-
// total += value.length;
|
|
44
|
-
// }
|
|
45
|
-
this._finished = true;
|
|
46
|
-
this.parseChunk('');
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
// Inform ChunkStreamer base class of error
|
|
50
|
-
this._sendError(error);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
this._nextChunk = function nextChunk() {
|
|
54
|
-
// Left empty, as async iterator automatically pulls next chunk
|
|
55
|
-
};
|
|
56
|
-
// HELPER METHODS
|
|
57
|
-
this.getStringChunk = function (chunk) {
|
|
58
|
-
return typeof chunk === 'string' ? chunk : this.textDecoder.decode(chunk, { stream: true });
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
exports.default = AsyncIteratorStreamer;
|
|
62
|
-
AsyncIteratorStreamer.prototype = Object.create(ChunkStreamer.prototype);
|
|
63
|
-
AsyncIteratorStreamer.prototype.constructor = AsyncIteratorStreamer;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"papaparse.d.ts","sourceRoot":"","sources":["../../src/papaparse/papaparse.ts"],"names":[],"mappings":"AAmBA,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;CAuBT,CAAC;AACF,eAAe,IAAI,CAAC;AAepB,iBAAS,SAAS,CAChB,MAAM,KAAA,EACN,OAAO,KAAA,EACP,mBAAmB,CAAC,KAAA,OAiErB;AAED,iBAAS,SAAS,CAAC,MAAM,KAAA,EAAE,OAAO,KAAA,UA+KjC;AAED,gFAAgF;AAChF,iBAAS,aAAa,CAAC,MAAM,KAAA,QAuF5B;AACD,iBAAS,cAAc,CAAC,MAAM,KAAA,QAiB7B;kBAjBQ,cAAc;;;AAsBvB,iBAAS,YAAY,CAAC,OAAO,KAAA,QA8T5B;AAOD,gEAAgE;AAChE,iBAAS,MAAM,CAAC,MAAM,KAAA,QA8TrB"}
|