read-excel-file 6.0.2 → 7.0.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/CHANGELOG.md +13 -0
- package/README.md +22 -11
- package/browser/index.cjs +7 -0
- package/{index.d.ts → browser/index.d.ts} +2 -2
- package/browser/index.js +6 -0
- package/browser/package.json +17 -0
- package/bundle/read-excel-file.min.js +1 -1
- package/bundle/read-excel-file.min.js.map +1 -1
- package/commonjs/export/convertInputToNodeStream.js +45 -0
- package/commonjs/export/convertInputToNodeStream.js.map +1 -0
- package/commonjs/export/convertValuesFromUint8ArraysToStrings.js +20 -0
- package/commonjs/export/convertValuesFromUint8ArraysToStrings.js.map +1 -0
- package/commonjs/export/filterZipArchiveEntry.js +18 -0
- package/commonjs/export/filterZipArchiveEntry.js.map +1 -0
- package/commonjs/{read → export}/readSheetNamesBrowser.js +4 -4
- package/commonjs/export/readSheetNamesBrowser.js.map +1 -0
- package/commonjs/export/readSheetNamesNode.js.map +1 -0
- package/commonjs/export/readSheetNamesUniversal.js +23 -0
- package/commonjs/export/readSheetNamesUniversal.js.map +1 -0
- package/commonjs/{read → export}/readSheetNamesWebWorker.js +2 -2
- package/commonjs/export/readSheetNamesWebWorker.js.map +1 -0
- package/commonjs/{read → export}/readXlsxFileBrowser.js +6 -6
- package/commonjs/export/readXlsxFileBrowser.js.map +1 -0
- package/commonjs/{read → export}/readXlsxFileNode.js +5 -5
- package/commonjs/export/readXlsxFileNode.js.map +1 -0
- package/commonjs/export/readXlsxFileUniversal.js +24 -0
- package/commonjs/export/readXlsxFileUniversal.js.map +1 -0
- package/commonjs/{read → export}/readXlsxFileWebWorker.js +5 -5
- package/commonjs/export/readXlsxFileWebWorker.js.map +1 -0
- package/commonjs/export/unpackXlsxFileBrowser.js +38 -0
- package/commonjs/export/unpackXlsxFileBrowser.js.map +1 -0
- package/commonjs/export/unpackXlsxFileNode.js +23 -0
- package/commonjs/export/unpackXlsxFileNode.js.map +1 -0
- package/commonjs/export/unpackXlsxFileUniversal.js +23 -0
- package/commonjs/export/unpackXlsxFileUniversal.js.map +1 -0
- package/commonjs/types/Date.js +1 -1
- package/commonjs/types/Date.js.map +1 -1
- package/commonjs/{read → xlsx}/coordinates.js.map +1 -1
- package/commonjs/{read → xlsx}/dropEmptyColumns.js.map +1 -1
- package/commonjs/{read → xlsx}/dropEmptyColumns.test.js.map +1 -1
- package/commonjs/{read → xlsx}/dropEmptyRows.js.map +1 -1
- package/commonjs/{read → xlsx}/dropEmptyRows.test.js.map +1 -1
- package/commonjs/{read → xlsx}/getData.js.map +1 -1
- package/commonjs/{read → xlsx}/isDateTimestamp.js.map +1 -1
- package/commonjs/{read → xlsx}/parseCell.js.map +1 -1
- package/commonjs/{read → xlsx}/parseCellValue.js.map +1 -1
- package/commonjs/{read → xlsx}/parseCells.js.map +1 -1
- package/commonjs/{read → xlsx}/parseDate.js.map +1 -1
- package/commonjs/{read → xlsx}/parseDate.test.js.map +1 -1
- package/commonjs/{read → xlsx}/parseDimensions.js.map +1 -1
- package/commonjs/{read → xlsx}/parseFilePaths.js.map +1 -1
- package/commonjs/{read → xlsx}/parseProperties.js.map +1 -1
- package/commonjs/{read → xlsx}/parseSharedStrings.js.map +1 -1
- package/commonjs/{read → xlsx}/parseSheet.js.map +1 -1
- package/commonjs/{read → xlsx}/parseStyles.js.map +1 -1
- package/commonjs/{read/readXlsx.js → xlsx/parseXlsxFileContents.js} +10 -9
- package/commonjs/xlsx/parseXlsxFileContents.js.map +1 -0
- package/commonjs/{read/readXlsxFileContents.js → xlsx/parseXlsxFileContentsWithOptionalSchema.js} +13 -6
- package/commonjs/xlsx/parseXlsxFileContentsWithOptionalSchema.js.map +1 -0
- package/commonjs/{read → xlsx}/schema/mapToObjects.js +0 -4
- package/commonjs/xlsx/schema/mapToObjects.js.map +1 -0
- package/commonjs/{read → xlsx}/schema/mapToObjects.test.js.map +1 -1
- package/commonjs/xml/dom.js +10 -0
- package/commonjs/xml/dom.js.map +1 -1
- package/commonjs/xml/xlsx.js +10 -2
- package/commonjs/xml/xlsx.js.map +1 -1
- package/commonjs/zip/unzipFromArrayBuffer.js +74 -0
- package/commonjs/zip/unzipFromArrayBuffer.js.map +1 -0
- package/commonjs/zip/unzipFromArrayBufferSync.js +33 -0
- package/commonjs/zip/unzipFromArrayBufferSync.js.map +1 -0
- package/commonjs/zip/unzipFromStream.js +123 -0
- package/commonjs/zip/unzipFromStream.js.map +1 -0
- package/modules/export/convertInputToNodeStream.js +36 -0
- package/modules/export/convertInputToNodeStream.js.map +1 -0
- package/modules/export/convertValuesFromUint8ArraysToStrings.js +15 -0
- package/modules/export/convertValuesFromUint8ArraysToStrings.js.map +1 -0
- package/modules/export/filterZipArchiveEntry.js +12 -0
- package/modules/export/filterZipArchiveEntry.js.map +1 -0
- package/modules/{read → export}/readSheetNamesBrowser.js +4 -4
- package/modules/export/readSheetNamesBrowser.js.map +1 -0
- package/modules/export/readSheetNamesNode.js.map +1 -0
- package/modules/export/readSheetNamesUniversal.js +17 -0
- package/modules/export/readSheetNamesUniversal.js.map +1 -0
- package/modules/{read → export}/readSheetNamesWebWorker.js +2 -2
- package/modules/export/readSheetNamesWebWorker.js.map +1 -0
- package/modules/{read → export}/readXlsxFileBrowser.js +6 -6
- package/modules/export/readXlsxFileBrowser.js.map +1 -0
- package/modules/{read → export}/readXlsxFileNode.js +5 -5
- package/modules/export/readXlsxFileNode.js.map +1 -0
- package/modules/export/readXlsxFileUniversal.js +18 -0
- package/modules/export/readXlsxFileUniversal.js.map +1 -0
- package/modules/{read → export}/readXlsxFileWebWorker.js +5 -5
- package/modules/export/readXlsxFileWebWorker.js.map +1 -0
- package/modules/export/unpackXlsxFileBrowser.js +30 -0
- package/modules/export/unpackXlsxFileBrowser.js.map +1 -0
- package/modules/export/unpackXlsxFileNode.js +17 -0
- package/modules/export/unpackXlsxFileNode.js.map +1 -0
- package/modules/export/unpackXlsxFileUniversal.js +17 -0
- package/modules/export/unpackXlsxFileUniversal.js.map +1 -0
- package/modules/types/Date.js +1 -1
- package/modules/types/Date.js.map +1 -1
- package/modules/{read → xlsx}/coordinates.js.map +1 -1
- package/modules/{read → xlsx}/dropEmptyColumns.js.map +1 -1
- package/modules/{read → xlsx}/dropEmptyColumns.test.js.map +1 -1
- package/modules/{read → xlsx}/dropEmptyRows.js.map +1 -1
- package/modules/{read → xlsx}/dropEmptyRows.test.js.map +1 -1
- package/modules/{read → xlsx}/getData.js.map +1 -1
- package/modules/{read → xlsx}/isDateTimestamp.js.map +1 -1
- package/modules/{read → xlsx}/parseCell.js.map +1 -1
- package/modules/{read → xlsx}/parseCellValue.js.map +1 -1
- package/modules/{read → xlsx}/parseCells.js.map +1 -1
- package/modules/{read → xlsx}/parseDate.js.map +1 -1
- package/modules/{read → xlsx}/parseDate.test.js.map +1 -1
- package/modules/{read → xlsx}/parseDimensions.js.map +1 -1
- package/modules/{read → xlsx}/parseFilePaths.js.map +1 -1
- package/modules/{read → xlsx}/parseProperties.js.map +1 -1
- package/modules/{read → xlsx}/parseSharedStrings.js.map +1 -1
- package/modules/{read → xlsx}/parseSheet.js.map +1 -1
- package/modules/{read → xlsx}/parseStyles.js.map +1 -1
- package/modules/{read/readXlsx.js → xlsx/parseXlsxFileContents.js} +9 -8
- package/modules/xlsx/parseXlsxFileContents.js.map +1 -0
- package/modules/{read/readXlsxFileContents.js → xlsx/parseXlsxFileContentsWithOptionalSchema.js} +13 -5
- package/modules/xlsx/parseXlsxFileContentsWithOptionalSchema.js.map +1 -0
- package/modules/{read → xlsx}/schema/mapToObjects.js +0 -4
- package/modules/xlsx/schema/mapToObjects.js.map +1 -0
- package/modules/{read → xlsx}/schema/mapToObjects.test.js.map +1 -1
- package/modules/xml/dom.js +9 -0
- package/modules/xml/dom.js.map +1 -1
- package/modules/xml/xlsx.js +11 -3
- package/modules/xml/xlsx.js.map +1 -1
- package/modules/zip/unzipFromArrayBuffer.js +67 -0
- package/modules/zip/unzipFromArrayBuffer.js.map +1 -0
- package/modules/zip/unzipFromArrayBufferSync.js +27 -0
- package/modules/zip/unzipFromArrayBufferSync.js.map +1 -0
- package/modules/zip/unzipFromStream.js +119 -0
- package/modules/zip/unzipFromStream.js.map +1 -0
- package/node/index.cjs +4 -4
- package/node/index.d.ts +2 -1
- package/node/index.js +3 -3
- package/package.json +14 -9
- package/rollup.config.mjs +1 -1
- package/universal/index.cjs +7 -0
- package/universal/index.d.ts +28 -0
- package/universal/index.js +6 -0
- package/universal/package.json +17 -0
- package/web-worker/index.cjs +4 -4
- package/web-worker/index.js +3 -3
- package/commonjs/read/readSheetNamesBrowser.js.map +0 -1
- package/commonjs/read/readSheetNamesNode.js.map +0 -1
- package/commonjs/read/readSheetNamesNode.test.js.map +0 -1
- package/commonjs/read/readSheetNamesWebWorker.js.map +0 -1
- package/commonjs/read/readXlsx.js.map +0 -1
- package/commonjs/read/readXlsxFileBrowser.js.map +0 -1
- package/commonjs/read/readXlsxFileContents.js.map +0 -1
- package/commonjs/read/readXlsxFileNode.js.map +0 -1
- package/commonjs/read/readXlsxFileNode.test.js.map +0 -1
- package/commonjs/read/readXlsxFileWebWorker.js.map +0 -1
- package/commonjs/read/schema/mapToObjects.js.map +0 -1
- package/commonjs/read/unpackXlsxFileBrowser.js +0 -50
- package/commonjs/read/unpackXlsxFileBrowser.js.map +0 -1
- package/commonjs/read/unpackXlsxFileNode.js +0 -86
- package/commonjs/read/unpackXlsxFileNode.js.map +0 -1
- package/index.cjs +0 -7
- package/index.cjs.js +0 -12
- package/index.js +0 -6
- package/modules/read/readSheetNamesBrowser.js.map +0 -1
- package/modules/read/readSheetNamesNode.js.map +0 -1
- package/modules/read/readSheetNamesNode.test.js.map +0 -1
- package/modules/read/readSheetNamesWebWorker.js.map +0 -1
- package/modules/read/readXlsx.js.map +0 -1
- package/modules/read/readXlsxFileBrowser.js.map +0 -1
- package/modules/read/readXlsxFileContents.js.map +0 -1
- package/modules/read/readXlsxFileNode.js.map +0 -1
- package/modules/read/readXlsxFileNode.test.js.map +0 -1
- package/modules/read/readXlsxFileWebWorker.js.map +0 -1
- package/modules/read/schema/mapToObjects.js.map +0 -1
- package/modules/read/unpackXlsxFileBrowser.js +0 -45
- package/modules/read/unpackXlsxFileBrowser.js.map +0 -1
- package/modules/read/unpackXlsxFileNode.js +0 -78
- package/modules/read/unpackXlsxFileNode.js.map +0 -1
- package/node/index.cjs.js +0 -12
- package/web-worker/index.cjs.js +0 -12
- /package/commonjs/{read → export}/readSheetNamesNode.js +0 -0
- /package/commonjs/{read → xlsx}/coordinates.js +0 -0
- /package/commonjs/{read → xlsx}/dropEmptyColumns.js +0 -0
- /package/commonjs/{read → xlsx}/dropEmptyRows.js +0 -0
- /package/commonjs/{read → xlsx}/getData.js +0 -0
- /package/commonjs/{read → xlsx}/isDateTimestamp.js +0 -0
- /package/commonjs/{read → xlsx}/parseCell.js +0 -0
- /package/commonjs/{read → xlsx}/parseCellValue.js +0 -0
- /package/commonjs/{read → xlsx}/parseCells.js +0 -0
- /package/commonjs/{read → xlsx}/parseDate.js +0 -0
- /package/commonjs/{read → xlsx}/parseDimensions.js +0 -0
- /package/commonjs/{read → xlsx}/parseFilePaths.js +0 -0
- /package/commonjs/{read → xlsx}/parseProperties.js +0 -0
- /package/commonjs/{read → xlsx}/parseSharedStrings.js +0 -0
- /package/commonjs/{read → xlsx}/parseSheet.js +0 -0
- /package/commonjs/{read → xlsx}/parseStyles.js +0 -0
- /package/modules/{read → export}/readSheetNamesNode.js +0 -0
- /package/modules/{read → xlsx}/coordinates.js +0 -0
- /package/modules/{read → xlsx}/dropEmptyColumns.js +0 -0
- /package/modules/{read → xlsx}/dropEmptyRows.js +0 -0
- /package/modules/{read → xlsx}/getData.js +0 -0
- /package/modules/{read → xlsx}/isDateTimestamp.js +0 -0
- /package/modules/{read → xlsx}/parseCell.js +0 -0
- /package/modules/{read → xlsx}/parseCellValue.js +0 -0
- /package/modules/{read → xlsx}/parseCells.js +0 -0
- /package/modules/{read → xlsx}/parseDate.js +0 -0
- /package/modules/{read → xlsx}/parseDimensions.js +0 -0
- /package/modules/{read → xlsx}/parseFilePaths.js +0 -0
- /package/modules/{read → xlsx}/parseProperties.js +0 -0
- /package/modules/{read → xlsx}/parseSharedStrings.js +0 -0
- /package/modules/{read → xlsx}/parseSheet.js +0 -0
- /package/modules/{read → xlsx}/parseStyles.js +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
|
|
3
|
+
// `unzipper` has a bug when it doesn't include "@aws-sdk/client-s3" package in the `dependencies`
|
|
4
|
+
// which causes some "bundlers" throw an error.
|
|
5
|
+
// https://github.com/ZJONSSON/node-unzipper/issues/330
|
|
6
|
+
//
|
|
7
|
+
// One workaround is to install "@aws-sdk/client-s3" package manually, which would still lead to increased bundle size.
|
|
8
|
+
// If the code is bundled for server-side-use only, that is will not be used in a web browser,
|
|
9
|
+
// then the increased bundle size would not be an issue.
|
|
10
|
+
//
|
|
11
|
+
// Another workaround could be to "alias" "@aws-sdk/client-s3" package in a "bundler" configuration file
|
|
12
|
+
// with a path to a `*.js` file containing just "export default null". But that kind of a workaround would also
|
|
13
|
+
// result in errors when using other packages that `import` anything from "@aws-sdk/client-s3" package,
|
|
14
|
+
// so it's not really a workaround but more of a ticking bomb.
|
|
15
|
+
//
|
|
16
|
+
import unzip from 'unzipper';
|
|
17
|
+
|
|
18
|
+
// Althernatively, it could use `fflate` if someone writes an example of handling a Node.js stream.
|
|
19
|
+
// https://github.com/101arrowz/fflate/issues/251
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Reads `*.zip` file contents.
|
|
23
|
+
* @param {Stream} stream
|
|
24
|
+
* @return {Promise<Record<string,Buffer>>} Resolves to an object holding `*.zip` file entries. P.S. `Buffer` is a `Uint8Array`.
|
|
25
|
+
*/
|
|
26
|
+
export default function unzipFromStream(stream) {
|
|
27
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
28
|
+
filter = _ref.filter;
|
|
29
|
+
// The `files` object stores the files and their contents.
|
|
30
|
+
var files = {};
|
|
31
|
+
return new Promise(function (resolve, reject) {
|
|
32
|
+
var promises = [];
|
|
33
|
+
var errored = false;
|
|
34
|
+
var onError = function onError(error) {
|
|
35
|
+
if (!errored) {
|
|
36
|
+
errored = true;
|
|
37
|
+
reject(error);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
stream
|
|
41
|
+
// This first "error" listener catches the original stream errors.
|
|
42
|
+
//
|
|
43
|
+
// That's because the .pipe() method does not automatically propagate errors
|
|
44
|
+
// from a source (input) stream to the destination stream or the end of the pipeline.
|
|
45
|
+
// You would need to attach an 'error' event handler to each stream in the chain.
|
|
46
|
+
//
|
|
47
|
+
// A more convenient alternative would be to use `stream.pipeline()` function:
|
|
48
|
+
// `pipeline(stream1, stream2, (error) => { ... })`
|
|
49
|
+
//
|
|
50
|
+
.on('error', onError)
|
|
51
|
+
// Pipe the input stream through the unzipper stream.
|
|
52
|
+
.pipe(unzip.Parse())
|
|
53
|
+
// This second "error" listener catches the unzipper stream errors.
|
|
54
|
+
//
|
|
55
|
+
// That's because the .pipe() method does not automatically propagate errors
|
|
56
|
+
// from a source (input) stream to the destination stream or the end of the pipeline.
|
|
57
|
+
// You would need to attach an 'error' event handler to each stream in the chain.
|
|
58
|
+
//
|
|
59
|
+
// A more convenient alternative would be to use `stream.pipeline()` function:
|
|
60
|
+
// `pipeline(stream1, stream2, (error) => { ... })`
|
|
61
|
+
//
|
|
62
|
+
.on('error', onError)
|
|
63
|
+
// The unzipper stream is closed when all `entries` have been reported.
|
|
64
|
+
.on('finish', function () {
|
|
65
|
+
if (!errored) {
|
|
66
|
+
// Wait for all `entries` to be read.
|
|
67
|
+
// The second argument of `.then()` function is not required
|
|
68
|
+
// but I didn't remove it just to potentially prevent any potential silly bugs
|
|
69
|
+
// in case of some potential changes in some potential future.
|
|
70
|
+
Promise.all(promises).then(function () {
|
|
71
|
+
resolve(files);
|
|
72
|
+
}, onError);
|
|
73
|
+
}
|
|
74
|
+
}).on('entry', function (entry) {
|
|
75
|
+
// See if this file should be ignored.
|
|
76
|
+
var ignore = false;
|
|
77
|
+
// `entry.type` could be 'Directory' or 'File'.
|
|
78
|
+
// Ignore anything except files.
|
|
79
|
+
if (entry.type === 'Directory') {
|
|
80
|
+
ignore = true;
|
|
81
|
+
}
|
|
82
|
+
if (errored) {
|
|
83
|
+
ignore = true;
|
|
84
|
+
}
|
|
85
|
+
if (filter) {
|
|
86
|
+
if (!filter({
|
|
87
|
+
path: entry.path
|
|
88
|
+
})) {
|
|
89
|
+
ignore = true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// If this file should be ignored.
|
|
94
|
+
if (ignore) {
|
|
95
|
+
// Call `entry.autodrain()` when you do not intend to process a specific `entry`'s raw data.
|
|
96
|
+
// Otherwise, if an `entry` is not consumed (via .pipe(), .buffer(), or .autodrain()),
|
|
97
|
+
// the stream will halt, preventing further file processing.
|
|
98
|
+
entry.autodrain().on('error', onError);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
var chunks = [];
|
|
102
|
+
promises.push(new Promise(function (resolve) {
|
|
103
|
+
// `entry` seems to be a generic Node.js stream.
|
|
104
|
+
// `entry.pipe()` pipes the file contents to a stream.
|
|
105
|
+
// `entry.stream()` returns a readable stream.
|
|
106
|
+
// `entry.buffer()` returns a promise that resolves to a `Buffer` with the file contents.
|
|
107
|
+
entry.on('data', function (data) {
|
|
108
|
+
chunks.push(data);
|
|
109
|
+
}).on('error', function (error) {
|
|
110
|
+
onError(error);
|
|
111
|
+
}).on('finish', function () {
|
|
112
|
+
files[entry.path] = Buffer.concat(chunks);
|
|
113
|
+
resolve();
|
|
114
|
+
});
|
|
115
|
+
}));
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=unzipFromStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unzipFromStream.js","names":["Buffer","unzip","unzipFromStream","stream","_ref","arguments","length","undefined","filter","files","Promise","resolve","reject","promises","errored","onError","error","on","pipe","Parse","all","then","entry","ignore","type","path","autodrain","chunks","push","data","concat"],"sources":["../../source/zip/unzipFromStream.js"],"sourcesContent":["import { Buffer } from 'buffer'\r\n\r\n// `unzipper` has a bug when it doesn't include \"@aws-sdk/client-s3\" package in the `dependencies`\r\n// which causes some \"bundlers\" throw an error.\r\n// https://github.com/ZJONSSON/node-unzipper/issues/330\r\n//\r\n// One workaround is to install \"@aws-sdk/client-s3\" package manually, which would still lead to increased bundle size.\r\n// If the code is bundled for server-side-use only, that is will not be used in a web browser,\r\n// then the increased bundle size would not be an issue.\r\n//\r\n// Another workaround could be to \"alias\" \"@aws-sdk/client-s3\" package in a \"bundler\" configuration file\r\n// with a path to a `*.js` file containing just \"export default null\". But that kind of a workaround would also\r\n// result in errors when using other packages that `import` anything from \"@aws-sdk/client-s3\" package,\r\n// so it's not really a workaround but more of a ticking bomb.\r\n//\r\nimport unzip from 'unzipper'\r\n\r\n// Althernatively, it could use `fflate` if someone writes an example of handling a Node.js stream.\r\n// https://github.com/101arrowz/fflate/issues/251\r\n\r\n/**\r\n * Reads `*.zip` file contents.\r\n * @param {Stream} stream\r\n * @return {Promise<Record<string,Buffer>>} Resolves to an object holding `*.zip` file entries. P.S. `Buffer` is a `Uint8Array`.\r\n */\r\nexport default function unzipFromStream(stream, { filter } = {}) {\r\n\t// The `files` object stores the files and their contents.\r\n\tconst files = {}\r\n\r\n\treturn new Promise((resolve, reject) => {\r\n\t\tconst promises = []\r\n\r\n\t\tlet errored = false\r\n\r\n\t\tconst onError = (error) => {\r\n\t\t\tif (!errored) {\r\n\t\t\t\terrored = true\r\n\t\t\t\treject(error)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tstream\r\n\t\t\t// This first \"error\" listener catches the original stream errors.\r\n\t\t\t//\r\n\t\t\t// That's because the .pipe() method does not automatically propagate errors\r\n\t\t\t// from a source (input) stream to the destination stream or the end of the pipeline.\r\n\t\t\t// You would need to attach an 'error' event handler to each stream in the chain.\r\n\t\t\t//\r\n\t\t\t// A more convenient alternative would be to use `stream.pipeline()` function:\r\n\t\t\t// `pipeline(stream1, stream2, (error) => { ... })`\r\n\t\t\t//\r\n\t\t\t.on('error', onError)\r\n\t\t\t// Pipe the input stream through the unzipper stream.\r\n\t\t\t.pipe(unzip.Parse())\r\n\t\t\t// This second \"error\" listener catches the unzipper stream errors.\r\n\t\t\t//\r\n\t\t\t// That's because the .pipe() method does not automatically propagate errors\r\n\t\t\t// from a source (input) stream to the destination stream or the end of the pipeline.\r\n\t\t\t// You would need to attach an 'error' event handler to each stream in the chain.\r\n\t\t\t//\r\n\t\t\t// A more convenient alternative would be to use `stream.pipeline()` function:\r\n\t\t\t// `pipeline(stream1, stream2, (error) => { ... })`\r\n\t\t\t//\r\n\t\t\t.on('error', onError)\r\n\t\t\t// The unzipper stream is closed when all `entries` have been reported.\r\n\t\t\t.on('finish', () => {\r\n\t\t\t\tif (!errored) {\r\n\t\t\t\t\t// Wait for all `entries` to be read.\r\n\t\t\t\t\t// The second argument of `.then()` function is not required\r\n\t\t\t\t\t// but I didn't remove it just to potentially prevent any potential silly bugs\r\n\t\t\t\t\t// in case of some potential changes in some potential future.\r\n\t\t\t\t\tPromise.all(promises).then(() => {\r\n\t\t\t\t\t\tresolve(files)\r\n\t\t\t\t\t}, onError)\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t\t.on('entry', (entry) => {\r\n\t\t\t\t// See if this file should be ignored.\r\n\t\t\t\tlet ignore = false\r\n\t\t\t\t// `entry.type` could be 'Directory' or 'File'.\r\n\t\t\t\t// Ignore anything except files.\r\n\t\t\t\tif (entry.type === 'Directory') {\r\n\t\t\t\t\tignore = true\r\n\t\t\t\t}\r\n\t\t\t\tif (errored) {\r\n\t\t\t\t\tignore = true\r\n\t\t\t\t}\r\n\t\t\t\tif (filter) {\r\n\t\t\t\t\tif (!filter({ path: entry.path })) {\r\n\t\t\t\t\t\tignore = true\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// If this file should be ignored.\r\n\t\t\t\tif (ignore) {\r\n\t\t\t\t\t// Call `entry.autodrain()` when you do not intend to process a specific `entry`'s raw data.\r\n\t\t\t\t\t// Otherwise, if an `entry` is not consumed (via .pipe(), .buffer(), or .autodrain()),\r\n\t\t\t\t\t// the stream will halt, preventing further file processing.\r\n\t\t\t\t\tentry.autodrain().on('error', onError)\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\r\n\t\t\t\tconst chunks = []\r\n\r\n\t\t\t\tpromises.push(new Promise((resolve) => {\r\n\t\t\t\t\t// `entry` seems to be a generic Node.js stream.\r\n\t\t\t\t\t// `entry.pipe()` pipes the file contents to a stream.\r\n\t\t\t\t\t// `entry.stream()` returns a readable stream.\r\n\t\t\t\t\t// `entry.buffer()` returns a promise that resolves to a `Buffer` with the file contents.\r\n\t\t\t\t\tentry\r\n\t\t\t\t\t\t.on('data', (data) => {\r\n\t\t\t\t\t\t\tchunks.push(data)\r\n\t\t\t\t\t\t})\r\n\t\t\t\t\t\t.on('error', (error) => {\r\n\t\t\t\t\t\t\tonError(error)\r\n\t\t\t\t\t\t})\r\n\t\t\t\t\t\t.on('finish', () => {\r\n\t\t\t\t\t\t\tfiles[entry.path] = Buffer.concat(chunks)\r\n\t\t\t\t\t\t\tresolve()\r\n\t\t\t\t\t\t})\r\n\t\t\t\t}))\r\n\t\t\t})\r\n\t})\r\n}"],"mappings":"AAAA,SAASA,MAAM,QAAQ,QAAQ;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOC,KAAK,MAAM,UAAU;;AAE5B;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,eAAeA,CAACC,MAAM,EAAmB;EAAA,IAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,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CAAC,EAAE;UAClCF,MAAM,GAAG,IAAI;QACd;MACD;;MAEA;MACA,IAAIA,MAAM,EAAE;QACX;QACA;QACA;QACAD,KAAK,CAACI,SAAS,CAAC,CAAC,CAACT,EAAE,CAAC,OAAO,EAAEF,OAAO,CAAC;QACtC;MACD;MAEA,IAAMY,MAAM,GAAG,EAAE;MAEjBd,QAAQ,CAACe,IAAI,CAAC,IAAIlB,OAAO,CAAC,UAACC,OAAO,EAAK;QACtC;QACA;QACA;QACA;QACAW,KAAK,CACHL,EAAE,CAAC,MAAM,EAAE,UAACY,IAAI,EAAK;UACrBF,MAAM,CAACC,IAAI,CAACC,IAAI,CAAC;QAClB,CAAC,CAAC,CACDZ,EAAE,CAAC,OAAO,EAAE,UAACD,KAAK,EAAK;UACvBD,OAAO,CAACC,KAAK,CAAC;QACf,CAAC,CAAC,CACDC,EAAE,CAAC,QAAQ,EAAE,YAAM;UACnBR,KAAK,CAACa,KAAK,CAACG,IAAI,CAAC,GAAGzB,MAAM,CAAC8B,MAAM,CAACH,MAAM,CAAC;UACzChB,OAAO,CAAC,CAAC;QACV,CAAC,CAAC;MACJ,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACH"}
|
package/node/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
exports = module.exports = require('../commonjs/
|
|
2
|
-
exports['default'] = require('../commonjs/
|
|
3
|
-
exports.readSheetNames = require('../commonjs/
|
|
4
|
-
exports.parseExcelDate = require('../commonjs/
|
|
1
|
+
exports = module.exports = require('../commonjs/export/readXlsxFileNode.js').default
|
|
2
|
+
exports['default'] = require('../commonjs/export/readXlsxFileNode.js').default
|
|
3
|
+
exports.readSheetNames = require('../commonjs/export/readSheetNamesNode.js').default
|
|
4
|
+
exports.parseExcelDate = require('../commonjs/xlsx/parseDate.js').default
|
|
5
5
|
exports.Integer = require('../commonjs/types/Integer.js').default
|
|
6
6
|
exports.Email = require('../commonjs/types/Email.js').default
|
|
7
7
|
exports.URL = require('../commonjs/types/URL.js').default
|
package/node/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { PathLike } from 'fs';
|
|
5
5
|
import { Stream } from 'stream';
|
|
6
|
+
import { Blob } from 'buffer'
|
|
6
7
|
|
|
7
8
|
import {
|
|
8
9
|
ParseWithSchemaOptions,
|
|
@@ -24,7 +25,7 @@ export {
|
|
|
24
25
|
|
|
25
26
|
export function parseExcelDate(excelSerialDate: number) : typeof Date;
|
|
26
27
|
|
|
27
|
-
type Input = Stream | Buffer | PathLike;
|
|
28
|
+
type Input = Stream | Buffer | PathLike | Blob;
|
|
28
29
|
|
|
29
30
|
export function readXlsxFile<T extends object>(input: Input, options: ParseWithSchemaOptions<T>) : Promise<ParsedObjectsResult<T>>;
|
|
30
31
|
export function readXlsxFile(input: Input, options?: ParseWithoutSchemaOptions) : Promise<Row[]>;
|
package/node/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { default as default } from '../modules/
|
|
2
|
-
export { default as readSheetNames } from '../modules/
|
|
3
|
-
export { default as parseExcelDate } from '../modules/
|
|
1
|
+
export { default as default } from '../modules/export/readXlsxFileNode.js'
|
|
2
|
+
export { default as readSheetNames } from '../modules/export/readSheetNamesNode.js'
|
|
3
|
+
export { default as parseExcelDate } from '../modules/xlsx/parseDate.js'
|
|
4
4
|
export { default as Integer } from '../modules/types/Integer.js'
|
|
5
5
|
export { default as Email } from '../modules/types/Email.js'
|
|
6
6
|
export { default as URL } from '../modules/types/URL.js'
|
package/package.json
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "read-excel-file",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Read `*.xlsx` files of moderate size in a web browser or on a server.",
|
|
5
|
-
"module": "index.js",
|
|
6
|
-
"main": "index.cjs",
|
|
7
5
|
"type": "module",
|
|
8
6
|
"exports": {
|
|
9
|
-
"
|
|
10
|
-
"types": "./index.d.ts",
|
|
11
|
-
"import": "./index.js",
|
|
12
|
-
"require": "./index.cjs"
|
|
7
|
+
"./universal": {
|
|
8
|
+
"types": "./universal/index.d.ts",
|
|
9
|
+
"import": "./universal/index.js",
|
|
10
|
+
"require": "./universal/index.cjs"
|
|
11
|
+
},
|
|
12
|
+
"./browser": {
|
|
13
|
+
"types": "./browser/index.d.ts",
|
|
14
|
+
"import": "./browser/index.js",
|
|
15
|
+
"require": "./browser/index.cjs"
|
|
13
16
|
},
|
|
14
17
|
"./node": {
|
|
15
18
|
"types": "./node/index.d.ts",
|
|
@@ -24,9 +27,8 @@
|
|
|
24
27
|
"./package.json": "./package.json"
|
|
25
28
|
},
|
|
26
29
|
"sideEffects": false,
|
|
27
|
-
"types": "./index.d.ts",
|
|
28
30
|
"scripts": {
|
|
29
|
-
"test": "mocha --colors --bail --reporter spec --require ./test/
|
|
31
|
+
"test": "mocha --colors --bail --reporter spec --require ./test/globals.js \"./{,!(node_modules|commonjs|modules)/**/}*.test.js\" --recursive",
|
|
30
32
|
"clean-for-build": "rimraf ./commonjs/**/* ./modules/**/*",
|
|
31
33
|
"build-commonjs-modules": "better-npm-run build-commonjs-modules",
|
|
32
34
|
"build-commonjs-package.json": "node build-scripts/create-commonjs-package-json.js",
|
|
@@ -36,6 +38,9 @@
|
|
|
36
38
|
"build": "npm-run-all clean-for-build build-commonjs build-es6-modules browser-build",
|
|
37
39
|
"prepublishOnly": "npm-run-all build test browser-build"
|
|
38
40
|
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18"
|
|
43
|
+
},
|
|
39
44
|
"dependencies": {
|
|
40
45
|
"@xmldom/xmldom": "^0.8.11",
|
|
41
46
|
"fflate": "^0.8.2",
|
package/rollup.config.mjs
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
exports = module.exports = require('../commonjs/export/readXlsxFileUniversal.js').default
|
|
2
|
+
exports['default'] = require('../commonjs/export/readXlsxFileUniversal.js').default
|
|
3
|
+
exports.readSheetNames = require('../commonjs/export/readSheetNamesUniversal.js').default
|
|
4
|
+
exports.parseExcelDate = require('../commonjs/xlsx/parseDate.js').default
|
|
5
|
+
exports.Integer = require('../commonjs/types/Integer.js').default
|
|
6
|
+
exports.Email = require('../commonjs/types/Email.js').default
|
|
7
|
+
exports.URL = require('../commonjs/types/URL.js').default
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ParseWithSchemaOptions,
|
|
3
|
+
ParseWithoutSchemaOptions,
|
|
4
|
+
ParsedObjectsResult,
|
|
5
|
+
Row
|
|
6
|
+
} from '../types.d.js';
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
Schema,
|
|
10
|
+
ParsedObjectsResult,
|
|
11
|
+
Error,
|
|
12
|
+
CellValue,
|
|
13
|
+
Row,
|
|
14
|
+
Integer,
|
|
15
|
+
Email,
|
|
16
|
+
URL
|
|
17
|
+
} from '../types.d.js';
|
|
18
|
+
|
|
19
|
+
export function parseExcelDate(excelSerialDate: number) : typeof Date;
|
|
20
|
+
|
|
21
|
+
type Input = Blob;
|
|
22
|
+
|
|
23
|
+
export function readXlsxFile<T extends object>(input: Input, options: ParseWithSchemaOptions<T>) : Promise<ParsedObjectsResult<T>>;
|
|
24
|
+
export function readXlsxFile(input: Input, options?: ParseWithoutSchemaOptions) : Promise<Row[]>;
|
|
25
|
+
|
|
26
|
+
export function readSheetNames(input: Input) : Promise<string[]>;
|
|
27
|
+
|
|
28
|
+
export default readXlsxFile;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as default } from '../modules/export/readXlsxFileUniversal.js'
|
|
2
|
+
export { default as readSheetNames } from '../modules/export/readSheetNamesUniversal.js'
|
|
3
|
+
export { default as parseExcelDate } from '../modules/xlsx/parseDate.js'
|
|
4
|
+
export { default as Integer } from '../modules/types/Integer.js'
|
|
5
|
+
export { default as Email } from '../modules/types/Email.js'
|
|
6
|
+
export { default as URL } from '../modules/types/URL.js'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"private": true,
|
|
3
|
+
"name": "read-excel-file/universal",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"main": "index.cjs",
|
|
6
|
+
"module": "index.js",
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"import": "./index.js",
|
|
13
|
+
"require": "./index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": false
|
|
17
|
+
}
|
package/web-worker/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
exports = module.exports = require('../commonjs/
|
|
2
|
-
exports['default'] = require('../commonjs/
|
|
3
|
-
exports.readSheetNames = require('../commonjs/
|
|
4
|
-
exports.parseExcelDate = require('../commonjs/
|
|
1
|
+
exports = module.exports = require('../commonjs/export/readXlsxFileWebWorker.js').default
|
|
2
|
+
exports['default'] = require('../commonjs/export/readXlsxFileWebWorker.js').default
|
|
3
|
+
exports.readSheetNames = require('../commonjs/export/readSheetNamesWebWorker.js').default
|
|
4
|
+
exports.parseExcelDate = require('../commonjs/xlsx/parseDate.js').default
|
|
5
5
|
exports.Integer = require('../commonjs/types/Integer.js').default
|
|
6
6
|
exports.Email = require('../commonjs/types/Email.js').default
|
|
7
7
|
exports.URL = require('../commonjs/types/URL.js').default
|
package/web-worker/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { default as default } from '../modules/
|
|
2
|
-
export { default as readSheetNames } from '../modules/
|
|
3
|
-
export { default as parseExcelDate } from '../modules/
|
|
1
|
+
export { default as default } from '../modules/export/readXlsxFileWebWorker.js'
|
|
2
|
+
export { default as readSheetNames } from '../modules/export/readSheetNamesWebWorker.js'
|
|
3
|
+
export { default as parseExcelDate } from '../modules/xlsx/parseDate.js'
|
|
4
4
|
export { default as Integer } from '../modules/types/Integer.js'
|
|
5
5
|
export { default as Email } from '../modules/types/Email.js'
|
|
6
6
|
export { default as URL } from '../modules/types/URL.js'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readSheetNamesBrowser.js","names":["_readXlsxFileBrowser","_interopRequireDefault","require","obj","__esModule","readSheetNames","file","readXlsxFile","getSheets","then","sheets","map","sheet","name"],"sources":["../../source/read/readSheetNamesBrowser.js"],"sourcesContent":["import readXlsxFile from './readXlsxFileBrowser.js'\r\n\r\n/**\r\n * Reads the list of sheet names in an XLSX file in a web browser.\r\n * @param {file} file - A file being uploaded in the browser.\r\n * @return {Promise} Resolves to an array of objects of shape `{ name: string }`.\r\n */\r\nexport default function readSheetNames(file) {\r\n\treturn readXlsxFile(file, { getSheets: true })\r\n\t\t.then(sheets => sheets.map(sheet => sheet.name))\r\n}"],"mappings":";;;;;;AAAA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAmD,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAEnD;AACA;AACA;AACA;AACA;AACe,SAASE,cAAcA,CAACC,IAAI,EAAE;EAC5C,OAAO,IAAAC,+BAAY,EAACD,IAAI,EAAE;IAAEE,SAAS,EAAE;EAAK,CAAC,CAAC,CAC5CC,IAAI,CAAC,UAAAC,MAAM;IAAA,OAAIA,MAAM,CAACC,GAAG,CAAC,UAAAC,KAAK;MAAA,OAAIA,KAAK,CAACC,IAAI;IAAA,EAAC;EAAA,EAAC;AAClD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readSheetNamesNode.js","names":["_readXlsxFileNode","_interopRequireDefault","require","obj","__esModule","readSheetNames","input","readXlsxFile","getSheets","then","sheets","map","sheet","name"],"sources":["../../source/read/readSheetNamesNode.js"],"sourcesContent":["import readXlsxFile from './readXlsxFileNode.js'\r\n\r\n/**\r\n * Reads the list of sheet names in an XLSX file in Node.js.\r\n * @param {(string|Stream|Buffer)} input - A Node.js readable stream or a `Buffer` or a path to a file.\r\n * @return {Promise} Resolves to an array of objects of shape `{ name: string }`.\r\n */\r\nexport default function readSheetNames(input) {\r\n\treturn readXlsxFile(input, { getSheets: true })\r\n\t\t.then(sheets => sheets.map(sheet => sheet.name))\r\n}"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAgD,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAEhD;AACA;AACA;AACA;AACA;AACe,SAASE,cAAcA,CAACC,KAAK,EAAE;EAC7C,OAAO,IAAAC,4BAAY,EAACD,KAAK,EAAE;IAAEE,SAAS,EAAE;EAAK,CAAC,CAAC,CAC7CC,IAAI,CAAC,UAAAC,MAAM;IAAA,OAAIA,MAAM,CAACC,GAAG,CAAC,UAAAC,KAAK;MAAA,OAAIA,KAAK,CAACC,IAAI;IAAA,EAAC;EAAA,EAAC;AAClD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readSheetNamesNode.test.js","names":["_path","_interopRequireDefault","require","_readSheetNamesNode","obj","__esModule","describe","it","readSheetNamesNode","path","resolve","then","sheetNames","should","deep","equal"],"sources":["../../source/read/readSheetNamesNode.test.js"],"sourcesContent":["import path from 'path'\r\n\r\nimport readSheetNamesNode from './readSheetNamesNode.js'\r\n\r\ndescribe('readSheetNamesNode', () => {\r\n\tit('should read the list of sheet names in an *.xlsx file in Node.js', () => {\r\n\t\treturn readSheetNamesNode(path.resolve('./test/spreadsheets/multiple-sheets.xlsx')).then((sheetNames) => {\r\n\t\t\tsheetNames.should.deep.equal(['sheet 1', 'sheet 2'])\r\n\t\t})\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAwD,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAExDE,QAAQ,CAAC,oBAAoB,EAAE,YAAM;EACpCC,EAAE,CAAC,kEAAkE,EAAE,YAAM;IAC5E,OAAO,IAAAC,8BAAkB,EAACC,gBAAI,CAACC,OAAO,CAAC,0CAA0C,CAAC,CAAC,CAACC,IAAI,CAAC,UAACC,UAAU,EAAK;MACxGA,UAAU,CAACC,MAAM,CAACC,IAAI,CAACC,KAAK,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC,CAAC;EACH,CAAC,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readSheetNamesWebWorker.js","names":["_readXlsxFileWebWorker","_interopRequireDefault","require","obj","__esModule","readSheetNames","file","readXlsxFile","getSheets","then","sheets","map","sheet","name"],"sources":["../../source/read/readSheetNamesWebWorker.js"],"sourcesContent":["import readXlsxFile from './readXlsxFileWebWorker.js'\r\n\r\n/**\r\n * Reads the list of sheet names in an XLSX file in a Web Worker.\r\n * @param {file} file - The file.\r\n * @return {Promise} Resolves to an array of objects of shape `{ name: string }`.\r\n */\r\nexport default function readSheetNames(file) {\r\n\treturn readXlsxFile(file, { getSheets: true })\r\n\t\t.then(sheets => sheets.map(sheet => sheet.name))\r\n}"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAqD,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAErD;AACA;AACA;AACA;AACA;AACe,SAASE,cAAcA,CAACC,IAAI,EAAE;EAC5C,OAAO,IAAAC,iCAAY,EAACD,IAAI,EAAE;IAAEE,SAAS,EAAE;EAAK,CAAC,CAAC,CAC5CC,IAAI,CAAC,UAAAC,MAAM;IAAA,OAAIA,MAAM,CAACC,GAAG,CAAC,UAAAC,KAAK;MAAA,OAAIA,KAAK,CAACC,IAAI;IAAA,EAAC;EAAA,EAAC;AAClD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsx.js","names":["_parseProperties","_interopRequireDefault","require","_parseFilePaths","_parseStyles","_parseSharedStrings","_parseSheet","_getData","obj","__esModule","_typeof","o","Symbol","iterator","constructor","prototype","_createForOfIteratorHelperLoose","allowArrayLike","it","call","next","bind","Array","isArray","_unsupportedIterableToArray","length","i","done","value","TypeError","minLen","_arrayLikeToArray","n","Object","toString","slice","name","from","test","arr","len","arr2","ownKeys","e","r","t","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","toPrimitive","undefined","res","Number","readXlsx","contents","xml","options","sheet","getXmlFileContent","filePath","Error","concat","filePaths","parseFilePaths","values","sharedStrings","parseSharedStrings","styles","parseStyles","properties","parseProperties","getSheets","sheets","map","_ref","sheetId","getSheetId","createSheetNotFoundError","parseSheet","rowIndexSourceMap","data","getData","_sheet","relationId","_iterator","_step","sheetsList","join"],"sources":["../../source/read/readXlsx.js"],"sourcesContent":["import parseProperties from './parseProperties.js'\r\nimport parseFilePaths from './parseFilePaths.js'\r\nimport parseStyles from './parseStyles.js'\r\nimport parseSharedStrings from './parseSharedStrings.js'\r\nimport parseSheet from './parseSheet.js'\r\nimport getData from './getData.js'\r\n\r\n// For an introduction in reading `*.xlsx` files see \"The minimum viable XLSX reader\":\r\n// https://www.brendanlong.com/the-minimum-viable-xlsx-reader.html\r\n\r\n/**\r\n * Reads an (unzipped) XLSX file structure into a 2D array of cells.\r\n * @param {object} contents - A list of XML files inside XLSX file (which is a zipped directory).\r\n * @param {number?} options.sheet - Workbook sheet id (`1` by default).\r\n * @param {string?} options.dateFormat - Date format, e.g. \"mm/dd/yyyy\". Values having this format template set will be parsed as dates.\r\n * @param {object} contents - A list of XML files inside XLSX file (which is a zipped directory).\r\n * @return {object} An object of shape `{ data, cells, properties }`. `data: string[][]` is an array of rows, each row being an array of cell values. `cells: string[][]` is an array of rows, each row being an array of cells. `properties: object` is the spreadsheet properties (e.g. whether date epoch is 1904 instead of 1900).\r\n */\r\nexport default function readXlsx(contents, xml, options = {}) {\r\n if (!options.sheet) {\r\n options = {\r\n sheet: 1,\r\n ...options\r\n }\r\n }\r\n\r\n const getXmlFileContent = (filePath) => {\r\n if (!contents[filePath]) {\r\n throw new Error(`\"${filePath}\" file not found inside the *.xlsx file zip archive`)\r\n }\r\n return contents[filePath]\r\n }\r\n\r\n // Some Excel editors don't want to use standard naming scheme for sheet files.\r\n // https://github.com/tidyverse/readxl/issues/104\r\n const filePaths = parseFilePaths(getXmlFileContent('xl/_rels/workbook.xml.rels'), xml)\r\n\r\n // Default file path for \"shared strings\": \"xl/sharedStrings.xml\".\r\n const values = filePaths.sharedStrings\r\n ? parseSharedStrings(getXmlFileContent(filePaths.sharedStrings), xml)\r\n : []\r\n\r\n // Default file path for \"styles\": \"xl/styles.xml\".\r\n const styles = filePaths.styles\r\n ? parseStyles(getXmlFileContent(filePaths.styles), xml)\r\n : {}\r\n\r\n const properties = parseProperties(getXmlFileContent('xl/workbook.xml'), xml)\r\n\r\n // A feature for getting the list of sheets in an Excel file.\r\n // https://github.com/catamphetamine/read-excel-file/issues/14\r\n if (options.getSheets) {\r\n return properties.sheets.map(({ name }) => ({\r\n name\r\n }))\r\n }\r\n\r\n // Find the sheet by name, or take the first one.\r\n const sheetId = getSheetId(options.sheet, properties.sheets)\r\n\r\n // If the sheet wasn't found then throw an error.\r\n // Example: \"xl/worksheets/sheet1.xml\".\r\n if (!sheetId || !filePaths.sheets[sheetId]) {\r\n throw createSheetNotFoundError(options.sheet, properties.sheets)\r\n }\r\n\r\n // Parse sheet data.\r\n const sheet = parseSheet(\r\n getXmlFileContent(filePaths.sheets[sheetId]),\r\n xml,\r\n values,\r\n styles,\r\n properties,\r\n options\r\n )\r\n\r\n options = {\r\n // Create a `rowIndexSourceMap` for the original dataset, if not passed,\r\n // because \"empty\" rows will be dropped from the input data.\r\n rowIndexSourceMap: [],\r\n ...options\r\n }\r\n\r\n // Get spreadsheet data.\r\n const data = getData(sheet, options)\r\n\r\n // Can return properties, if required.\r\n if (options.properties) {\r\n return {\r\n data,\r\n properties\r\n }\r\n }\r\n\r\n // Return spreadsheet data.\r\n return data\r\n}\r\n\r\nfunction getSheetId(sheet, sheets) {\r\n if (typeof sheet === 'number') {\r\n const _sheet = sheets[sheet - 1]\r\n return _sheet && _sheet.relationId\r\n }\r\n for (const _sheet of sheets) {\r\n if (_sheet.name === sheet) {\r\n return _sheet.relationId\r\n }\r\n }\r\n}\r\n\r\nfunction createSheetNotFoundError(sheet, sheets) {\r\n const sheetsList = sheets && sheets.map((sheet, i) => `\"${sheet.name}\" (#${i + 1})`).join(', ')\r\n return new Error(`Sheet ${typeof sheet === 'number' ? '#' + sheet : '\"' + sheet + '\"'} not found in the *.xlsx file.${sheets ? ' Available sheets: ' + sheetsList + '.' : ''}`)\r\n}"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,mBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,WAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,QAAA,GAAAN,sBAAA,CAAAC,OAAA;AAAkC,SAAAD,uBAAAO,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,QAAAC,CAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QA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AAI3B,KAAK,UAAAC,MAAA,CAAU,OAAOJ,KAAK,KAAK,QAAQ,GAAG,GAAG,GAAGA,KAAK,GAAG,GAAG,GAAGA,KAAK,GAAG,GAAG,oCAAAI,MAAA,CAAiCW,MAAM,GAAG,qBAAqB,GAAGc,UAAU,GAAG,GAAG,GAAG,EAAE,CAAE,CAAC;AACjL"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsxFileBrowser.js","names":["_xmlBrowser","_interopRequireDefault","require","_unpackXlsxFileBrowser","_readXlsxFileContents","obj","__esModule","readXlsxFile","file","options","arguments","length","undefined","unpackXlsxFile","then","entries","readXlsxFileContents","xml"],"sources":["../../source/read/readXlsxFileBrowser.js"],"sourcesContent":["import xml from '../xml/xmlBrowser.js'\r\n\r\nimport unpackXlsxFile from './unpackXlsxFileBrowser.js'\r\nimport readXlsxFileContents from './readXlsxFileContents.js'\r\n\r\n/**\r\n * Reads XLSX file into a 2D array of cells in a browser.\r\n * @param {file} file - A file being uploaded in the browser.\r\n * @param {object?} options\r\n * @param {(number|string)?} options.sheet - Excel document sheet to read. Defaults to `1`. Will only read this sheet and skip others.\r\n * @return {Promise} Resolves to a 2D array of cells: an array of rows, each row being an array of cells.\r\n */\r\nexport default function readXlsxFile(file, options = {}) {\r\n\treturn unpackXlsxFile(file)\r\n\t\t.then((entries) => readXlsxFileContents(entries, xml, options))\r\n}"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,qBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,YAAYA,CAACC,IAAI,EAAgB;EAAA,IAAdC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACtD,OAAO,IAAAG,iCAAc,EAACL,IAAI,CAAC,CACzBM,IAAI,CAAC,UAACC,OAAO;IAAA,OAAK,IAAAC,gCAAoB,EAACD,OAAO,EAAEE,sBAAG,EAAER,OAAO,CAAC;EAAA,EAAC;AACjE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsxFileContents.js","names":["_readXlsx","_interopRequireDefault","require","_mapToObjects","_excluded","obj","__esModule","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","_typeof","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","i","sourceSymbolKeys","indexOf","prototype","propertyIsEnumerable","sourceKeys","readXlsxFileContents","entries","xml","_ref","schema","options","map","Error","result","readXlsx","properties","mapToObjects","data"],"sources":["../../source/read/readXlsxFileContents.js"],"sourcesContent":["import readXlsx from './readXlsx.js'\r\n\r\nimport mapToObjects from './schema/mapToObjects.js'\r\n\r\nexport default function readXlsxFileContents(entries, xml, { schema, ...options}) {\r\n\tif (options.map) {\r\n\t\tthrow new Error('`map` option was removed. Pass a `schema` option instead.')\r\n\t}\r\n\t// `readXlsx()` function creates `options.rowIndexSourceMap` property.\r\n\t// It maps parsed data row indexes to spreadsheet row indexes.\r\n\t// That's because empty rows are ignored (discarded) when parsing using `schema`.\r\n\tconst result = readXlsx(entries, xml, { ...options, properties: schema || options.properties })\r\n\tif (schema) {\r\n\t\treturn mapToObjects(result.data, schema, {\r\n\t\t\t...options,\r\n\t\t\tproperties: result.properties\r\n\t\t})\r\n\t}\r\n\treturn result\r\n}"],"mappings":";;;;;;;AAA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GAAA,aAAAsB,MAAA,CAAAtB,GAAA,IAAAoB,MAAA,CAAApB,GAAA,cAAAsB,MAAA;AAAA,SAAAC,8BAAAH,MAAA,EAAAC,QAAA,QAAAD,MAAA,yBAAAE,MAAA,WAAAO,UAAA,GAAA9C,MAAA,CAAAC,IAAA,CAAAoC,MAAA,OAAApB,GAAA,EAAAwB,CAAA,OAAAA,CAAA,MAAAA,CAAA,GAAAK,UAAA,CAAAnC,MAAA,EAAA8B,CAAA,MAAAxB,GAAA,GAAA6B,UAAA,CAAAL,CAAA,OAAAH,QAAA,CAAAK,OAAA,CAAA1B,GAAA,kBAAAsB,MAAA,CAAAtB,GAAA,IAAAoB,MAAA,CAAApB,GAAA,YAAAsB,MAAA;AAEpC,SAASQ,oBAAoBA,CAACC,OAAO,EAAEC,GAAG,EAAAC,IAAA,EAAyB;EAAA,IAArBC,MAAM,GAAAD,IAAA,CAANC,MAAM;IAAKC,OAAO,GAAAhB,wBAAA,CAAAc,IAAA,EAAAzD,SAAA;EAC9E,IAAI2D,OAAO,CAACC,GAAG,EAAE;IAChB,MAAM,IAAIC,KAAK,CAAC,2DAA2D,CAAC;EAC7E;EACA;EACA;EACA;EACA,IAAMC,MAAM,GAAG,IAAAC,oBAAQ,EAACR,OAAO,EAAEC,GAAG,EAAAxC,aAAA,CAAAA,aAAA,KAAO2C,OAAO;IAAEK,UAAU,EAAEN,MAAM,IAAIC,OAAO,CAACK;EAAU,EAAE,CAAC;EAC/F,IAAIN,MAAM,EAAE;IACX,OAAO,IAAAO,wBAAY,EAACH,MAAM,CAACI,IAAI,EAAER,MAAM,EAAA1C,aAAA,CAAAA,aAAA,KACnC2C,OAAO;MACVK,UAAU,EAAEF,MAAM,CAACE;IAAU,EAC7B,CAAC;EACH;EACA,OAAOF,MAAM;AACd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsxFileNode.js","names":["_xml","_interopRequireDefault","require","_unpackXlsxFileNode","_readXlsxFileContents","obj","__esModule","readXlsxFile","input","options","arguments","length","undefined","unpackXlsxFile","then","entries","readXlsxFileContents","xml"],"sources":["../../source/read/readXlsxFileNode.js"],"sourcesContent":["import xml from '../xml/xml.js'\r\n\r\nimport unpackXlsxFile from './unpackXlsxFileNode.js'\r\nimport readXlsxFileContents from './readXlsxFileContents.js'\r\n\r\n/**\r\n * Reads XLSX file into a 2D array of cells in a browser.\r\n * @param {(string|Stream|Buffer)} input - A Node.js readable stream or a `Buffer` or a path to a file.\r\n * @param {object?} options\r\n * @param {(number|string)?} options.sheet - Excel document sheet to read. Defaults to `1`. Will only read this sheet and skip others.\r\n * @return {Promise} Resolves to a 2D array of cells: an array of rows, each row being an array of cells.\r\n */\r\nexport default function readXlsxFile(input, options = {}) {\r\n\treturn unpackXlsxFile(input)\r\n\t\t.then((entries) => readXlsxFileContents(entries, xml, options))\r\n}"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,qBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,YAAYA,CAACC,KAAK,EAAgB;EAAA,IAAdC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACvD,OAAO,IAAAG,8BAAc,EAACL,KAAK,CAAC,CAC1BM,IAAI,CAAC,UAACC,OAAO;IAAA,OAAK,IAAAC,gCAAoB,EAACD,OAAO,EAAEE,eAAG,EAAER,OAAO,CAAC;EAAA,EAAC;AACjE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsxFileNode.test.js","names":["_path","_interopRequireDefault","require","_readXlsxFileNode","obj","__esModule","describe","it","schema","date","column","type","Date","numberOfStudents","Number","required","course","isFree","Boolean","cost","title","String","contact","value","rowIndexSourceMap","readXlsxFileNode","path","resolve","then","_ref","rows","getTime","should","deep","equal","convertToUTCTimezone","getTimezoneOffset"],"sources":["../../source/read/readXlsxFileNode.test.js"],"sourcesContent":["import path from 'path'\r\n\r\nimport readXlsxFileNode from './readXlsxFileNode.js'\r\n\r\ndescribe('readXlsxFileNode', () => {\r\n\tit('should read *.xlsx file on Node.js and parse it to JSON', () => {\r\n\t\tconst schema = {\r\n\t\t\tdate: {\r\n\t\t\t\tcolumn: 'START DATE',\r\n\t\t\t\ttype: Date\r\n\t\t\t},\r\n\t\t\tnumberOfStudents: {\r\n\t\t\t\tcolumn: 'NUMBER OF STUDENTS',\r\n\t\t\t\ttype: Number,\r\n\t\t\t\trequired: true\r\n\t\t\t},\r\n\t\t\tcourse: {\r\n\t\t\t\tschema: {\r\n\t\t\t\t\tisFree: {\r\n\t\t\t\t\t\tcolumn: 'IS FREE',\r\n\t\t\t\t\t\ttype: Boolean\r\n\t\t\t\t\t\t// Excel stores booleans as numbers:\r\n\t\t\t\t\t\t// `1` is `true` and `0` is `false`.\r\n\t\t\t\t\t\t// Such numbers are parsed into booleans.\r\n\t\t\t\t\t},\r\n\t\t\t\t\tcost: {\r\n\t\t\t\t\t\tcolumn: 'COST',\r\n\t\t\t\t\t\ttype: Number\r\n\t\t\t\t\t},\r\n\t\t\t\t\ttitle: {\r\n\t\t\t\t\t\tcolumn: 'COURSE TITLE',\r\n\t\t\t\t\t\ttype: String\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tcontact: {\r\n\t\t\t\tcolumn: 'CONTACT',\r\n\t\t\t\trequired: true,\r\n\t\t\t\ttype(value) {\r\n\t\t\t\t\treturn '+11234567890'\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst rowIndexSourceMap = []\r\n\r\n\t\treturn readXlsxFileNode(path.resolve('./test/spreadsheets/course.xlsx'), { schema, rowIndexSourceMap }).then(({ rows }) => {\r\n\t\t\trows[0].date = rows[0].date.getTime()\r\n\t\t\trows.should.deep.equal([{\r\n\t\t\t\tdate: convertToUTCTimezone(new Date(2018, 2, 24)).getTime(),\r\n\t\t\t\tnumberOfStudents: 123,\r\n\t\t\t\tcourse: {\r\n\t\t\t\t\tisFree: false,\r\n\t\t\t\t\tcost: 210.45,\r\n\t\t\t\t\ttitle: 'Chemistry'\r\n\t\t\t\t},\r\n\t\t\t\tcontact: '+11234567890'\r\n\t\t\t}])\r\n\t\t\trowIndexSourceMap.should.deep.equal([0, 1])\r\n\t\t})\r\n\t})\r\n})\r\n\r\n// Converts timezone to UTC while preserving the same time\r\nfunction convertToUTCTimezone(date) {\r\n\t// Doesn't account for leap seconds but I guess that's ok\r\n\t// given that javascript's own `Date()` does not either.\r\n\t// https://www.timeanddate.com/time/leap-seconds-background.html\r\n\t//\r\n\t// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset\r\n\t//\r\n\treturn new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000)\r\n}\r\n"],"mappings":";;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAoD,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAEpDE,QAAQ,CAAC,kBAAkB,EAAE,YAAM;EAClCC,EAAE,CAAC,yDAAyD,EAAE,YAAM;IACnE,IAAMC,MAAM,GAAG;MACdC,IAAI,EAAE;QACLC,MAAM,EAAE,YAAY;QACpBC,IAAI,EAAEC;MACP,CAAC;MACDC,gBAAgB,EAAE;QACjBH,MAAM,EAAE,oBAAoB;QAC5BC,IAAI,EAAEG,MAAM;QACZC,QAAQ,EAAE;MACX,CAAC;MACDC,MAAM,EAAE;QACP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AC;IAC5C,CAAC,CAAC;EACH,CAAC,CAAC;AACH,CAAC,CAAC;;AAEF;AACA,SAASC,oBAAoBA,CAAC1B,IAAI,EAAE;EACnC;EACA;EACA;EACA;EACA;EACA;EACA,OAAO,IAAIG,IAAI,CAACH,IAAI,CAACsB,OAAO,CAAC,CAAC,GAAGtB,IAAI,CAAC2B,iBAAiB,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AACvE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsxFileWebWorker.js","names":["_xml","_interopRequireDefault","require","_unpackXlsxFileBrowser","_readXlsxFileContents","obj","__esModule","readXlsxFile","file","options","arguments","length","undefined","unpackXlsxFile","then","entries","readXlsxFileContents","xml"],"sources":["../../source/read/readXlsxFileWebWorker.js"],"sourcesContent":["import xml from '../xml/xml.js'\r\n\r\nimport unpackXlsxFile from './unpackXlsxFileBrowser.js'\r\nimport readXlsxFileContents from './readXlsxFileContents.js'\r\n\r\n/**\r\n * Reads XLSX file into a 2D array of cells in a web worker.\r\n * @param {file} file - The file.\r\n * @param {object?} options\r\n * @param {(number|string)?} options.sheet - Excel document sheet to read. Defaults to `1`. Will only read this sheet and skip others.\r\n * @return {Promise} Resolves to a 2D array of cells: an array of rows, each row being an array of cells.\r\n */\r\nexport default function readXlsxFile(file, options = {}) {\r\n\treturn unpackXlsxFile(file)\r\n\t\t.then((entries) => readXlsxFileContents(entries, xml, options))\r\n}"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,qBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,YAAYA,CAACC,IAAI,EAAgB;EAAA,IAAdC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACtD,OAAO,IAAAG,iCAAc,EAACL,IAAI,CAAC,CACzBM,IAAI,CAAC,UAACC,OAAO;IAAA,OAAK,IAAAC,gCAAoB,EAACD,OAAO,EAAEE,eAAG,EAAER,OAAO,CAAC;EAAA,EAAC;AACjE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapToObjects.js","names":["_Number","_interopRequireDefault","require","_String","_Boolean","_Date","_excluded","obj","__esModule","_typeof","o","Symbol","iterator","constructor","prototype","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","r","l","t","e","n","u","a","f","call","next","Object","done","push","value","length","Array","isArray","_createForOfIteratorHelperLoose","allowArrayLike","it","bind","minLen","_arrayLikeToArray","toString","slice","name","from","test","len","arr2","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","key","getOwnPropertySymbols","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","keys","ownKeys","filter","getOwnPropertyDescriptor","enumerable","apply","_objectSpread","arguments","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","toPrimitive","undefined","res","Number","DEFAULT_OPTIONS","schemaPropertyValueForMissingColumn","schemaPropertyValueForMissingValue","schemaPropertyShouldSkipRequiredValidationForMissingColumn","getEmptyObjectValue","getEmptyArrayValue","isColumnOriented","ignoreEmptyRows","arrayValueSeparator","mapToObjects","data","schema","options","_options","rowIndexSourceMapOriginal","rowIndexSourceMap","schemaTransformOptions","validateSchema","transpose","row","isEmptyRow","every","cell","splice","columns","results","errors","result","read","_iterator","_step","error","rows","rowIndex","path","object","isEmptyObject","createError","_ref","schemaEntry","errorMessage","reason","column","type","pendingRequiredChecks","_loop","_Object$keys","_i","propertyName","columnTitle","propertyPath","concat","cellValue","columnIndex","isMissingColumn","array","parseArray","map","_value","parseValue","isEmpty","isEmptyValue","required","_i2","_pendingRequiredCheck","_pendingRequiredCheck2","skipRequiredValidation","isRequired","parse","Error","parseValueOfType","oneOf","validate","message","parseCustomValue","parsedValue","StringType","NumberType","Date","DateType","properties","Boolean","BooleanType","getBlock","string","endCharacter","startIndex","substring","character","block","blocks","index","_getBlock","_getBlock2","trim","_","_i3","_Object$keys2"],"sources":["../../../source/read/schema/mapToObjects.js"],"sourcesContent":["import NumberType from '../../types/Number.js'\r\nimport StringType from '../../types/String.js'\r\nimport BooleanType from '../../types/Boolean.js'\r\nimport DateType from '../../types/Date.js'\r\n\r\nconst DEFAULT_OPTIONS = {\r\n schemaPropertyValueForMissingColumn: undefined,\r\n schemaPropertyValueForMissingValue: null,\r\n schemaPropertyShouldSkipRequiredValidationForMissingColumn: () => false,\r\n // `getEmptyObjectValue(object, { path })` applies to both the top-level object\r\n // and any of its sub-objects.\r\n getEmptyObjectValue: () => null,\r\n getEmptyArrayValue: () => null,\r\n isColumnOriented: false,\r\n ignoreEmptyRows: true,\r\n arrayValueSeparator: ','\r\n}\r\n\r\n/**\r\n * Converts spreadsheet-alike data structure into an array of objects.\r\n *\r\n * Parameters:\r\n *\r\n * * `data` — An array of rows, each row being an array of cells. The first row should be the list of column headers and the rest of the rows should be the data.\r\n * * `schema` — A \"to JSON\" convertion schema (see above).\r\n * * `options` — (optional) Schema conversion parameters of `read-excel-file`:\r\n * * `schemaPropertyValueForMissingColumn` — By default, when some of the `schema` columns are missing in the input `data`, those properties are set to `undefined` in the output objects. Pass `schemaPropertyValueForMissingColumn: null` to set such \"missing column\" properties to `null` in the output objects.\r\n * * `schemaPropertyValueForNullCellValue` — By default, when it encounters a `null` value in a cell in input `data`, it sets it to `undefined` in the output object. Pass `schemaPropertyValueForNullCellValue: null` to make it set such values as `null`s in output objects.\r\n * * `schemaPropertyValueForUndefinedCellValue` — By default, when it encounters an `undefined` value in a cell in input `data`, it it sets it to `undefined` in the output object. Pass `schemaPropertyValueForUndefinedCellValue: null` to make it set such values as `null`s in output objects.\r\n * * `schemaPropertyShouldSkipRequiredValidationForMissingColumn: (column: string, { object }) => boolean` — By default, it does apply `required` validation to `schema` properties for which columns are missing in the input `data`. One could pass a custom `schemaPropertyShouldSkipRequiredValidationForMissingColumn(column, { object })` to disable `required` validation for missing columns in some or all cases.\r\n * * `getEmptyObjectValue(object, { path? })` — By default, it returns `null` for \"empty\" objects. One could override that value using `getEmptyObjectValue(object, { path })` parameter. The value applies to both top-level object and any nested sub-objects in case of a nested schema, hence the additional (optional) `path?: string` parameter.\r\n * * `getEmptyArrayValue(array, { path })` — By default, it returns `null` for an \"empty\" array value. One could override that value using `getEmptyArrayValue(array, { path })` parameter.\r\n *\r\n * When parsing a property value, in case of an error, the value of that property is gonna be `undefined`.\r\n *\r\n * @param {any[][]} data - An array of rows, each row being an array of cells.\r\n * @param {object} schema\r\n * @param {object} [options]\r\n * @param {null} [options.schemaPropertyValueForMissingColumn] — By default, when some of the `schema` columns are missing in the input `data`, those properties are set to `undefined` in the output objects. Pass `schemaPropertyValueForMissingColumn: null` to set such \"missing column\" properties to `null` in the output objects.\r\n * @param {null} [options.schemaPropertyValueForMissingValue] — By default, when it encounters a `null` value in a cell in input `data`, it leaves the value as is. Pass a custom `schemaPropertyValueForMissingValue` to make it set such values to that value.\r\n * @param {object} [options.properties] — An optional object with optional property `epoch1904: true/false`. It is used when parsing dates.\r\n * @param {boolean} [options.schemaPropertyShouldSkipRequiredValidationForMissingColumn(column: string, { object })] — By default, it does apply `required` validation to `schema` properties for which columns are missing in the input `data`. One could pass a custom `schemaPropertyShouldSkipRequiredValidationForMissingColumn(column, { object })` to disable `required` validation for missing columns in some or all cases.\r\n * @param {function} [options.getEmptyObjectValue(object, { path })] — By default, it returns `null` for an \"empty\" resulting object. One could override that value using `getEmptyObjectValue(object, { path })` parameter. The value applies to both top-level object and any nested sub-objects in case of a nested schema, hence the additional `path?: string` parameter.\r\n * @param {function} [getEmptyArrayValue(array, { path })] — By default, it returns `null` for an \"empty\" array value. One could override that value using `getEmptyArrayValue(array, { path })` parameter.\r\n * @param {boolean} [options.isColumnOriented] — By default, the headers are assumed to be the first row in the `data`. Pass `isColumnOriented: true` if the headers are the first column in the `data`. i.e. if `data` is \"transposed\".\r\n * @param {string} [options.arrayValueSeparator] — When specified, string values will be split by this separator to get the array.\r\n * @param {object} [options.rowIndexSourceMap] — Custom row indexes of `data` rows. If present, will overwrite the indexes of `data` rows with the indexes from this `rowIndexSourceMap`.\r\n * @return {object[]}\r\n */\r\nexport default function mapToObjects(data, schema, options) {\r\n if (options) {\r\n options = {\r\n ...DEFAULT_OPTIONS,\r\n ...options\r\n }\r\n } else {\r\n options = DEFAULT_OPTIONS\r\n }\r\n\r\n const {\r\n isColumnOriented,\r\n ignoreEmptyRows,\r\n rowIndexSourceMap: rowIndexSourceMapOriginal,\r\n ...schemaTransformOptions\r\n } = options\r\n\r\n // `rowIndexSourceMap` could be mutated by `ignoreEmptyRows: true` option.\r\n // Create a copy of it so that the original `rowIndexSourceMap` is not affected by those changes.\r\n let rowIndexSourceMap = rowIndexSourceMapOriginal && rowIndexSourceMapOriginal.slice()\r\n\r\n validateSchema(schema)\r\n\r\n if (isColumnOriented) {\r\n data = transpose(data)\r\n }\r\n\r\n\tif (ignoreEmptyRows) {\r\n\t\tdata = data.filter((row, i) => {\r\n const isEmptyRow = row.every(cell => cell === null)\r\n if (isEmptyRow) {\r\n // Adjust `rowIndexSourceMap` now that the row has been removed.\r\n if (rowIndexSourceMap) {\r\n // Remove the `rowIndexSourceMap` entry that corresponds to the removed row.\r\n rowIndexSourceMap.splice(i, 1)\r\n }\r\n return false;\r\n }\r\n return true;\r\n })\r\n\t}\r\n\r\n const columns = data[0]\r\n\r\n const results = []\r\n const errors = []\r\n\r\n for (let i = 1; i < data.length; i++) {\r\n const result = read(schema, data[i], i, undefined, columns, errors, schemaTransformOptions)\r\n results.push(result)\r\n }\r\n\r\n // Set the correct `row` number in `errors` if a custom `rowIndexSourceMap` is supplied.\r\n if (rowIndexSourceMap) {\r\n for (const error of errors) {\r\n // Convert the `row` index in `data` to the\r\n // actual `row` index in the spreadsheet.\r\n // `- 1` converts row number to row index.\r\n // `+ 1` converts row index to row number.\r\n error.row = rowIndexSourceMap[error.row - 1] + 1\r\n }\r\n }\r\n\r\n return {\r\n rows: results,\r\n errors\r\n }\r\n}\r\n\r\nfunction read(schema, row, rowIndex, path, columns, errors, options) {\r\n const object = {}\r\n let isEmptyObject = true\r\n\r\n const createError = ({\r\n schemaEntry,\r\n value,\r\n error: errorMessage,\r\n reason\r\n }) => {\r\n const error = {\r\n error: errorMessage,\r\n row: rowIndex + 1,\r\n column: schemaEntry.column,\r\n value\r\n }\r\n if (reason) {\r\n error.reason = reason\r\n }\r\n // * Regular values specify a `type?` property, which is included in the `error` object.\r\n // * Nested objects specify a `schema` property, which is not included in the `error` object.\r\n if (schemaEntry.type) {\r\n error.type = schemaEntry.type\r\n }\r\n return error\r\n }\r\n\r\n const pendingRequiredChecks = []\r\n\r\n // For each schema entry.\r\n for (const key of Object.keys(schema)) {\r\n const schemaEntry = schema[key]\r\n\r\n // `schemaEntry.prop` property is now deprecated and shouldn't be used.\r\n // Instead, it now uses `key` as the key in the `object`.\r\n // And column name is now read not from `key` but from `schemaEntry.column` property.\r\n const propertyName = key\r\n const columnTitle = schemaEntry.column\r\n\r\n // The path of this property inside the resulting object.\r\n const propertyPath = `${path || ''}.${propertyName}`\r\n\r\n // Read the cell value for the schema entry.\r\n let cellValue\r\n const columnIndex = columns.indexOf(columnTitle)\r\n const isMissingColumn = columnIndex < 0\r\n if (!isMissingColumn) {\r\n cellValue = row[columnIndex]\r\n }\r\n\r\n let value\r\n let error\r\n let reason\r\n\r\n // Get property `value` from cell value.\r\n if (schemaEntry.schema) {\r\n value = read(schemaEntry.schema, row, rowIndex, propertyPath, columns, errors, options)\r\n } else {\r\n if (isMissingColumn) {\r\n if ('schemaPropertyValueForMissingColumn' in options) {\r\n value = options.schemaPropertyValueForMissingColumn\r\n }\r\n }\r\n else if (cellValue === undefined) {\r\n // This isn't supposed to be possible. Cell values are always `null` when cells are empty.\r\n // Employ some sensible fallback behavior here.\r\n if ('schemaPropertyValueForMissingValue' in options) {\r\n value = options.schemaPropertyValueForMissingValue\r\n }\r\n }\r\n else if (cellValue === null) {\r\n if ('schemaPropertyValueForMissingValue' in options) {\r\n value = options.schemaPropertyValueForMissingValue\r\n }\r\n }\r\n else if (Array.isArray(schemaEntry.type)) {\r\n const array = parseArray(cellValue, options.arrayValueSeparator).map((_value) => {\r\n if (error) {\r\n return\r\n }\r\n const result = parseValue(_value, schemaEntry, options)\r\n if (result.error) {\r\n // In case of an error, `value` won't be returned and will just be reported\r\n // as part of an `error` object, so it's fine assigning just an element of the array.\r\n value = _value\r\n error = result.error\r\n reason = result.reason\r\n }\r\n return result.value\r\n })\r\n if (!error) {\r\n const isEmpty = array.every(isEmptyValue)\r\n value = isEmpty ? options.getEmptyArrayValue(array, { path: propertyPath }) : array\r\n }\r\n } else {\r\n const result = parseValue(cellValue, schemaEntry, options)\r\n error = result.error\r\n reason = result.reason\r\n value = error ? cellValue : result.value\r\n }\r\n }\r\n\r\n // Apply `required` validation if the value is \"empty\".\r\n if (!error && isEmptyValue(value)) {\r\n if (schemaEntry.required) {\r\n // Will perform this `required()` validation in the end,\r\n // when all properties of the mapped object have been mapped.\r\n pendingRequiredChecks.push({ schemaEntry, value, isMissingColumn })\r\n }\r\n }\r\n\r\n if (error) {\r\n // If there was an error then the property value in the `object` will be `undefined`,\r\n // i.e it won't add the property value to the mapped object.\r\n errors.push(createError({\r\n schemaEntry,\r\n value,\r\n error,\r\n reason\r\n }))\r\n } else {\r\n // Possibly unmark the mapped object as \"empty\".\r\n if (isEmptyObject && !isEmptyValue(value)) {\r\n isEmptyObject = false\r\n }\r\n // Set the value in the mapped object.\r\n // Skip setting `undefined` values because they're already `undefined`\r\n // due to not having previously been set.\r\n if (value !== undefined) {\r\n object[propertyName] = value\r\n }\r\n }\r\n }\r\n\r\n // Return `null` for an \"empty\" mapped object.\r\n if (isEmptyObject) {\r\n return options.getEmptyObjectValue(object, { path })\r\n }\r\n\r\n // Perform any `required` validations.\r\n for (const { schemaEntry, value, isMissingColumn } of pendingRequiredChecks) {\r\n // Can optionally skip `required` validation for missing columns.\r\n const skipRequiredValidation = isMissingColumn && options.schemaPropertyShouldSkipRequiredValidationForMissingColumn(schemaEntry.column, { object })\r\n if (!skipRequiredValidation) {\r\n const { required } = schemaEntry\r\n const isRequired = typeof required === 'boolean' ? required : required(object)\r\n if (isRequired) {\r\n errors.push(createError({\r\n schemaEntry,\r\n value,\r\n error: 'required'\r\n }))\r\n }\r\n }\r\n }\r\n\r\n // Return the mapped object.\r\n return object\r\n}\r\n\r\n/**\r\n * Converts textual value to a javascript typed value.\r\n * @param {any} value\r\n * @param {object} schemaEntry\r\n * @return {{ value: any, error: string }}\r\n */\r\nexport function parseValue(value, schemaEntry, options) {\r\n if (value === null) {\r\n return { value: null }\r\n }\r\n let result\r\n if (schemaEntry.parse) {\r\n throw new Error('`schemaEntry.parse` property was renamed to `schemaEntry.type`')\r\n } else if (schemaEntry.type) {\r\n result = parseValueOfType(\r\n value,\r\n // Supports parsing array types.\r\n // See `parseArray()` function for more details.\r\n // Example `type`: String[]\r\n // Input: 'Barack Obama, \"String, with, colons\", Donald Trump'\r\n // Output: ['Barack Obama', 'String, with, colons', 'Donald Trump']\r\n Array.isArray(schemaEntry.type) ? schemaEntry.type[0] : schemaEntry.type,\r\n options\r\n )\r\n } else {\r\n result = { value: value }\r\n // throw new Error('Invalid schema entry: no `type` specified:\\n\\n' + JSON.stringify(schemaEntry, null, 2))\r\n }\r\n // If errored then return the error.\r\n if (result.error) {\r\n return result\r\n }\r\n if (result.value !== null) {\r\n if (schemaEntry.oneOf && schemaEntry.oneOf.indexOf(result.value) < 0) {\r\n return { error: 'invalid', reason: 'unknown' }\r\n }\r\n if (schemaEntry.validate) {\r\n try {\r\n schemaEntry.validate(result.value)\r\n } catch (error) {\r\n return { error: error.message }\r\n }\r\n }\r\n }\r\n return result\r\n}\r\n\r\n/**\r\n * Converts textual value to a custom value using supplied `.parse()`.\r\n * @param {any} value\r\n * @param {function} parse\r\n * @return {{ value: any, error: string }}\r\n */\r\nfunction parseCustomValue(value, parse) {\r\n try {\r\n const parsedValue = parse(value)\r\n if (parsedValue === undefined) {\r\n return { value: null }\r\n }\r\n return { value: parsedValue }\r\n } catch (error) {\r\n const result = { error: error.message }\r\n if (error.reason) {\r\n result.reason = error.reason;\r\n }\r\n return result\r\n }\r\n}\r\n\r\n/**\r\n * Converts textual value to a javascript typed value.\r\n * @param {any} value\r\n * @param {} type\r\n * @return {{ value: (string|number|Date|boolean), error: string, reason?: string }}\r\n */\r\nfunction parseValueOfType(value, type, options) {\r\n switch (type) {\r\n case String:\r\n return parseCustomValue(value, StringType)\r\n\r\n case Number:\r\n return parseCustomValue(value, NumberType)\r\n\r\n case Date:\r\n return parseCustomValue(value, (value) => DateType(value, { properties: options.properties }))\r\n\r\n case Boolean:\r\n return parseCustomValue(value, BooleanType)\r\n\r\n default:\r\n if (typeof type === 'function') {\r\n return parseCustomValue(value, type)\r\n }\r\n throw new Error(`Unsupported schema type: ${type && type.name || type}`)\r\n }\r\n}\r\n\r\nexport function getBlock(string, endCharacter, startIndex) {\r\n let i = 0\r\n let substring = ''\r\n let character\r\n while (startIndex + i < string.length) {\r\n const character = string[startIndex + i]\r\n if (character === endCharacter) {\r\n return [substring, i]\r\n }\r\n else if (character === '\"') {\r\n const block = getBlock(string, '\"', startIndex + i + 1)\r\n substring += block[0]\r\n i += '\"'.length + block[1] + '\"'.length\r\n }\r\n else {\r\n substring += character\r\n i++\r\n }\r\n }\r\n return [substring, i]\r\n}\r\n\r\n/**\r\n * Parses a string of comma-separated substrings into an array of substrings.\r\n * (the `export` is just for tests)\r\n * @param {string} string — A string of comma-separated substrings.\r\n * @return {string[]} An array of substrings.\r\n */\r\nexport function parseArray(string, arrayValueSeparator) {\r\n const blocks = []\r\n let index = 0\r\n while (index < string.length) {\r\n const [substring, length] = getBlock(string, arrayValueSeparator, index)\r\n index += length + arrayValueSeparator.length\r\n blocks.push(substring.trim())\r\n }\r\n return blocks\r\n}\r\n\r\n// Transpose a 2D array.\r\n// https://stackoverflow.com/questions/17428587/transposing-a-2d-array-in-javascript\r\nconst transpose = array => array[0].map((_, i) => array.map(row => row[i]))\r\n\r\nfunction validateSchema(schema) {\r\n for (const key of Object.keys(schema)) {\r\n const schemaEntry = schema[key]\r\n // Validate that the `schema` is not using a deprecated `type: nestedSchema` format.\r\n if (typeof schemaEntry.type === 'object' && !Array.isArray(schemaEntry.type)) {\r\n throw new Error('When defining a nested schema, use a `schema` property instead of a `type` property')\r\n }\r\n // Validate that every property has a source `column` title specified for it.\r\n if (!schemaEntry.schema) {\r\n if (!schemaEntry.column) {\r\n throw new Error(`\"column\" not defined for schema entry \"${key}\".`)\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction isEmptyValue(value) {\r\n return value === undefined || value === null\r\n}"],"mappings":";;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,KAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAA0C,IAAAI,SAAA;AAAA,SAAAL,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,QAAAC,CAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,CAAA,kBAAAA,CAAA,gBAAAA,CAAA,WAAAA,CAAA,yBAAAC,MAAA,IAAAD,CAAA,CAAAG,WAAA,KAAAF,MAAA,IAAAD,CAAA,KAAAC,MAAA,CAAAG,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F,GAAG,QAAI,CAAC;MACpE;IACF;EACF;AACF;AAEA,SAAS6F,YAAYA,CAACnH,KAAK,EAAE;EAC3B,OAAOA,KAAK,KAAKmD,SAAS,IAAInD,KAAK,KAAK,IAAI;AAC9C"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = unpackXlsxFile;
|
|
7
|
-
var _fflate = require("fflate");
|
|
8
|
-
/**
|
|
9
|
-
* Reads XLSX file in a browser.
|
|
10
|
-
* @param {(File|Blob|ArrayBuffer)} input - A `File` or an `ArrayBuffer`.
|
|
11
|
-
* @return {Promise} Resolves to an object holding XLSX file entries.
|
|
12
|
-
*/
|
|
13
|
-
function unpackXlsxFile(input) {
|
|
14
|
-
if (input instanceof File) {
|
|
15
|
-
return input.arrayBuffer().then(unpackXlsxArrayBuffer);
|
|
16
|
-
}
|
|
17
|
-
if (input instanceof Blob) {
|
|
18
|
-
return input.arrayBuffer().then(unpackXlsxArrayBuffer);
|
|
19
|
-
}
|
|
20
|
-
return unpackXlsxArrayBuffer(input);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Reads XLSX file in a browser from an `ArrayBuffer`.
|
|
25
|
-
* @param {ArrayBuffer} input
|
|
26
|
-
* @return {Promise} Resolves to an object holding XLSX file entries.
|
|
27
|
-
*/
|
|
28
|
-
function unpackXlsxArrayBuffer(arrayBuffer) {
|
|
29
|
-
var archive = new Uint8Array(arrayBuffer);
|
|
30
|
-
var contents = (0, _fflate.unzipSync)(archive);
|
|
31
|
-
return Promise.resolve(getContents(contents));
|
|
32
|
-
// return new Promise((resolve, reject) => {
|
|
33
|
-
// unzip(archive, (error, contents) => {
|
|
34
|
-
// if (error) {
|
|
35
|
-
// return reject(error)
|
|
36
|
-
// }
|
|
37
|
-
// return resolve(getContents(contents))
|
|
38
|
-
// })
|
|
39
|
-
// })
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function getContents(contents) {
|
|
43
|
-
var unzippedFiles = [];
|
|
44
|
-
for (var _i = 0, _Object$keys = Object.keys(contents); _i < _Object$keys.length; _i++) {
|
|
45
|
-
var key = _Object$keys[_i];
|
|
46
|
-
unzippedFiles[key] = (0, _fflate.strFromU8)(contents[key]);
|
|
47
|
-
}
|
|
48
|
-
return unzippedFiles;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=unpackXlsxFileBrowser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unpackXlsxFileBrowser.js","names":["_fflate","require","unpackXlsxFile","input","File","arrayBuffer","then","unpackXlsxArrayBuffer","Blob","archive","Uint8Array","contents","unzipSync","Promise","resolve","getContents","unzippedFiles","_i","_Object$keys","Object","keys","length","key","strFromU8"],"sources":["../../source/read/unpackXlsxFileBrowser.js"],"sourcesContent":["import { unzipSync, strFromU8 } from 'fflate'\r\n\r\n/**\r\n * Reads XLSX file in a browser.\r\n * @param {(File|Blob|ArrayBuffer)} input - A `File` or an `ArrayBuffer`.\r\n * @return {Promise} Resolves to an object holding XLSX file entries.\r\n */\r\nexport default function unpackXlsxFile(input) {\r\n\tif (input instanceof File) {\r\n\t\treturn input.arrayBuffer().then(unpackXlsxArrayBuffer)\r\n\t}\r\n\tif (input instanceof Blob) {\r\n\t\treturn input.arrayBuffer().then(unpackXlsxArrayBuffer)\r\n\t}\r\n\treturn unpackXlsxArrayBuffer(input)\r\n}\r\n\r\n/**\r\n * Reads XLSX file in a browser from an `ArrayBuffer`.\r\n * @param {ArrayBuffer} input\r\n * @return {Promise} Resolves to an object holding XLSX file entries.\r\n */\r\nfunction unpackXlsxArrayBuffer(arrayBuffer) {\r\n\tconst archive = new Uint8Array(arrayBuffer)\r\n\tconst contents = unzipSync(archive)\r\n\treturn Promise.resolve(getContents(contents))\r\n\t// return new Promise((resolve, reject) => {\r\n\t// \tunzip(archive, (error, contents) => {\r\n\t// \t\tif (error) {\r\n\t// \t\t\treturn reject(error)\r\n\t// \t\t}\r\n\t// \t\treturn resolve(getContents(contents))\r\n\t// \t})\r\n\t// })\r\n}\r\n\r\nfunction getContents(contents) {\r\n\tconst unzippedFiles = []\r\n\tfor (const key of Object.keys(contents)) {\r\n\t\tunzippedFiles[key] = strFromU8(contents[key])\r\n\t}\r\n\treturn unzippedFiles\r\n}"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACe,SAASC,cAAcA,CAACC,KAAK,EAAE;EAC7C,IAAIA,KAAK,YAAYC,IAAI,EAAE;IAC1B,OAAOD,KAAK,CAACE,WAAW,CAAC,CAAC,CAACC,IAAI,CAACC,qBAAqB,CAAC;EACvD;EACA,IAAIJ,KAAK,YAAYK,IAAI,EAAE;IAC1B,OAAOL,KAAK,CAACE,WAAW,CAAC,CAAC,CAACC,IAAI,CAACC,qBAAqB,CAAC;EACvD;EACA,OAAOA,qBAAqB,CAACJ,KAAK,CAAC;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASI,qBAAqBA,CAACF,WAAW,EAAE;EAC3C,IAAMI,OAAO,GAAG,IAAIC,UAAU,CAACL,WAAW,CAAC;EAC3C,IAAMM,QAAQ,GAAG,IAAAC,iBAAS,EAACH,OAAO,CAAC;EACnC,OAAOI,OAAO,CAACC,OAAO,CAACC,WAAW,CAACJ,QAAQ,CAAC,CAAC;EAC7C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AACD;;AAEA,SAASI,WAAWA,CAACJ,QAAQ,EAAE;EAC9B,IAAMK,aAAa,GAAG,EAAE;EACxB,SAAAC,EAAA,MAAAC,YAAA,GAAkBC,MAAM,CAACC,IAAI,CAACT,QAAQ,CAAC,EAAAM,EAAA,GAAAC,YAAA,CAAAG,MAAA,EAAAJ,EAAA,IAAE;IAApC,IAAMK,GAAG,GAAAJ,YAAA,CAAAD,EAAA;IACbD,aAAa,CAACM,GAAG,CAAC,GAAG,IAAAC,iBAAS,EAACZ,QAAQ,CAACW,GAAG,CAAC,CAAC;EAC9C;EACA,OAAON,aAAa;AACrB"}
|