read-excel-file 9.1.1 → 9.3.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/.gitlab-ci.yml +1 -1
- package/CHANGELOG.md +14 -0
- package/README.md +153 -50
- package/bundle/read-excel-file.min.js +1 -1
- package/bundle/read-excel-file.min.js.map +1 -1
- package/bundle/read-excel-file.min.old.js +2 -0
- package/bundle/read-excel-file.min.old.js.map +1 -0
- package/commonjs/export/convertValuesFromUint8ArraysToStrings.js +3 -0
- package/commonjs/export/convertValuesFromUint8ArraysToStrings.js.map +1 -1
- package/commonjs/export/parseSheet.js +12 -9
- package/commonjs/export/parseSheet.js.map +1 -1
- package/commonjs/export/readSheetBrowser.js +6 -2
- package/commonjs/export/readSheetBrowser.js.map +1 -1
- package/commonjs/export/readSheetNode.js +6 -2
- package/commonjs/export/readSheetNode.js.map +1 -1
- package/commonjs/export/readSheetUniversal.js +14 -2
- package/commonjs/export/readSheetUniversal.js.map +1 -1
- package/commonjs/export/readSheetWebWorker.js +12 -2
- package/commonjs/export/readSheetWebWorker.js.map +1 -1
- package/commonjs/export/readXlsxFileBrowser.js +6 -2
- package/commonjs/export/readXlsxFileBrowser.js.map +1 -1
- package/commonjs/export/readXlsxFileNode.js +6 -2
- package/commonjs/export/readXlsxFileNode.js.map +1 -1
- package/commonjs/export/readXlsxFileUniversal.js +14 -2
- package/commonjs/export/readXlsxFileUniversal.js.map +1 -1
- package/commonjs/export/readXlsxFileWebWorker.js +12 -2
- package/commonjs/export/readXlsxFileWebWorker.js.map +1 -1
- package/commonjs/export/unpackXlsxFileBrowser.js +29 -6
- package/commonjs/export/unpackXlsxFileBrowser.js.map +1 -1
- package/commonjs/export/unpackXlsxFileNode.js +6 -0
- package/commonjs/export/unpackXlsxFileNode.js.map +1 -1
- package/commonjs/export/unpackXlsxFileUniversal.js +6 -0
- package/commonjs/export/unpackXlsxFileUniversal.js.map +1 -1
- package/commonjs/export/unpackXlsxFileWebWorker.js +14 -0
- package/commonjs/export/unpackXlsxFileWebWorker.js.map +1 -0
- package/commonjs/parseSheetData/parseSheetData.js +6 -6
- package/commonjs/parseSheetData/parseSheetData.js.map +1 -1
- package/commonjs/utility/checkpoint.js +33 -0
- package/commonjs/utility/checkpoint.js.map +1 -0
- package/commonjs/utility/isObject.js +15 -0
- package/commonjs/utility/isObject.js.map +1 -0
- package/commonjs/utility/isPromise.js +18 -0
- package/commonjs/utility/isPromise.js.map +1 -0
- package/commonjs/xlsx/convertCellsToData2dArray.js +0 -3
- package/commonjs/xlsx/convertCellsToData2dArray.js.map +1 -1
- package/commonjs/xlsx/isDateFormatStyle.js +2 -2
- package/commonjs/xlsx/isDateFormatStyle.js.map +1 -1
- package/commonjs/xlsx/parseCell.js +89 -24
- package/commonjs/xlsx/parseCell.js.map +1 -1
- package/{modules/xlsx/parseCellCoordinates.js → commonjs/xlsx/parseCellAddress.js} +18 -7
- package/commonjs/xlsx/parseCellAddress.js.map +1 -0
- package/commonjs/xlsx/parseCellValue.js +7 -23
- package/commonjs/xlsx/parseCellValue.js.map +1 -1
- package/commonjs/xlsx/parseFilePaths.js +31 -32
- package/commonjs/xlsx/parseFilePaths.js.map +1 -1
- package/commonjs/xlsx/parseNumber.js +20 -0
- package/commonjs/xlsx/parseNumber.js.map +1 -0
- package/commonjs/xlsx/parseSharedString.js +64 -0
- package/commonjs/xlsx/parseSharedString.js.map +1 -0
- package/commonjs/xlsx/parseSharedStrings.js +45 -5
- package/commonjs/xlsx/parseSharedStrings.js.map +1 -1
- package/commonjs/xlsx/parseSheet.js +93 -9
- package/commonjs/xlsx/parseSheet.js.map +1 -1
- package/commonjs/xlsx/parseSheetData.js +68 -0
- package/commonjs/xlsx/parseSheetData.js.map +1 -0
- package/commonjs/xlsx/parseSpreadsheetContents.js +244 -43
- package/commonjs/xlsx/parseSpreadsheetContents.js.map +1 -1
- package/commonjs/xlsx/parseSpreadsheetInfo.js +67 -36
- package/commonjs/xlsx/parseSpreadsheetInfo.js.map +1 -1
- package/commonjs/xlsx/parseStyles.js +89 -36
- package/commonjs/xlsx/parseStyles.js.map +1 -1
- package/commonjs/xml/dom.js +2 -1
- package/commonjs/xml/dom.js.map +1 -1
- package/commonjs/xml/parseXmlStream.js +14 -0
- package/commonjs/xml/parseXmlStream.js.map +1 -0
- package/commonjs/xml/parseXmlStream.sax.js +109 -0
- package/commonjs/xml/parseXmlStream.sax.js.map +1 -0
- package/commonjs/xml/parseXmlStream.saxen.code.js +953 -0
- package/commonjs/xml/parseXmlStream.saxen.code.js.map +1 -0
- package/commonjs/xml/parseXmlStream.saxen.js +85 -0
- package/commonjs/xml/parseXmlStream.saxen.js.map +1 -0
- package/commonjs/xml/xlsx.js +75 -40
- package/commonjs/xml/xlsx.js.map +1 -1
- package/commonjs/zip/unzipFromArrayBuffer.js +5 -14
- package/commonjs/zip/unzipFromArrayBuffer.js.map +1 -1
- package/commonjs/zip/unzipFromStream.fflate.js +338 -0
- package/commonjs/zip/unzipFromStream.fflate.js.map +1 -0
- package/commonjs/zip/unzipFromStream.js +8 -200
- package/commonjs/zip/unzipFromStream.js.map +1 -1
- package/commonjs/zip/unzipFromStream.unzipper.js +138 -0
- package/commonjs/zip/unzipFromStream.unzipper.js.map +1 -0
- package/modules/export/convertValuesFromUint8ArraysToStrings.js +2 -0
- package/modules/export/convertValuesFromUint8ArraysToStrings.js.map +1 -1
- package/modules/export/parseSheet.js +12 -9
- package/modules/export/parseSheet.js.map +1 -1
- package/modules/export/readSheetBrowser.js +5 -2
- package/modules/export/readSheetBrowser.js.map +1 -1
- package/modules/export/readSheetNode.js +5 -2
- package/modules/export/readSheetNode.js.map +1 -1
- package/modules/export/readSheetUniversal.js +14 -2
- package/modules/export/readSheetUniversal.js.map +1 -1
- package/modules/export/readSheetWebWorker.js +12 -2
- package/modules/export/readSheetWebWorker.js.map +1 -1
- package/modules/export/readXlsxFileBrowser.js +5 -2
- package/modules/export/readXlsxFileBrowser.js.map +1 -1
- package/modules/export/readXlsxFileNode.js +5 -2
- package/modules/export/readXlsxFileNode.js.map +1 -1
- package/modules/export/readXlsxFileUniversal.js +14 -2
- package/modules/export/readXlsxFileUniversal.js.map +1 -1
- package/modules/export/readXlsxFileWebWorker.js +12 -2
- package/modules/export/readXlsxFileWebWorker.js.map +1 -1
- package/modules/export/unpackXlsxFileBrowser.js +26 -6
- package/modules/export/unpackXlsxFileBrowser.js.map +1 -1
- package/modules/export/unpackXlsxFileNode.js +3 -0
- package/modules/export/unpackXlsxFileNode.js.map +1 -1
- package/modules/export/unpackXlsxFileUniversal.js +3 -0
- package/modules/export/unpackXlsxFileUniversal.js.map +1 -1
- package/modules/export/unpackXlsxFileWebWorker.js +6 -0
- package/modules/export/unpackXlsxFileWebWorker.js.map +1 -0
- package/modules/parseSheetData/parseSheetData.js +4 -4
- package/modules/parseSheetData/parseSheetData.js.map +1 -1
- package/modules/utility/checkpoint.js +25 -0
- package/modules/utility/checkpoint.js.map +1 -0
- package/modules/utility/isObject.js +9 -0
- package/modules/utility/isObject.js.map +1 -0
- package/modules/utility/isPromise.js +12 -0
- package/modules/utility/isPromise.js.map +1 -0
- package/modules/xlsx/convertCellsToData2dArray.js +0 -3
- package/modules/xlsx/convertCellsToData2dArray.js.map +1 -1
- package/modules/xlsx/isDateFormatStyle.js +2 -2
- package/modules/xlsx/isDateFormatStyle.js.map +1 -1
- package/modules/xlsx/parseCell.js +85 -24
- package/modules/xlsx/parseCell.js.map +1 -1
- package/{commonjs/xlsx/parseCellCoordinates.js → modules/xlsx/parseCellAddress.js} +12 -13
- package/modules/xlsx/parseCellAddress.js.map +1 -0
- package/modules/xlsx/parseCellValue.js +7 -23
- package/modules/xlsx/parseCellValue.js.map +1 -1
- package/modules/xlsx/parseFilePaths.js +31 -33
- package/modules/xlsx/parseFilePaths.js.map +1 -1
- package/modules/xlsx/parseNumber.js +14 -0
- package/modules/xlsx/parseNumber.js.map +1 -0
- package/modules/xlsx/parseSharedString.js +55 -0
- package/modules/xlsx/parseSharedString.js.map +1 -0
- package/modules/xlsx/parseSharedStrings.js +46 -5
- package/modules/xlsx/parseSharedStrings.js.map +1 -1
- package/modules/xlsx/parseSheet.js +91 -9
- package/modules/xlsx/parseSheet.js.map +1 -1
- package/modules/xlsx/parseSheetData.js +55 -0
- package/modules/xlsx/parseSheetData.js.map +1 -0
- package/modules/xlsx/parseSpreadsheetContents.js +242 -43
- package/modules/xlsx/parseSpreadsheetContents.js.map +1 -1
- package/modules/xlsx/parseSpreadsheetInfo.js +67 -37
- package/modules/xlsx/parseSpreadsheetInfo.js.map +1 -1
- package/modules/xlsx/parseStyles.js +88 -36
- package/modules/xlsx/parseStyles.js.map +1 -1
- package/modules/xml/dom.js +2 -1
- package/modules/xml/dom.js.map +1 -1
- package/modules/xml/parseXmlStream.js +18 -0
- package/modules/xml/parseXmlStream.js.map +1 -0
- package/modules/xml/parseXmlStream.sax.js +103 -0
- package/modules/xml/parseXmlStream.sax.js.map +1 -0
- package/modules/xml/parseXmlStream.saxen.code.js +947 -0
- package/modules/xml/parseXmlStream.saxen.code.js.map +1 -0
- package/modules/xml/parseXmlStream.saxen.js +79 -0
- package/modules/xml/parseXmlStream.saxen.js.map +1 -0
- package/modules/xml/xlsx.js +72 -36
- package/modules/xml/xlsx.js.map +1 -1
- package/modules/zip/unzipFromArrayBuffer.js +5 -14
- package/modules/zip/unzipFromArrayBuffer.js.map +1 -1
- package/modules/zip/unzipFromStream.fflate.js +336 -0
- package/modules/zip/unzipFromStream.fflate.js.map +1 -0
- package/modules/zip/unzipFromStream.js +55 -187
- package/modules/zip/unzipFromStream.js.map +1 -1
- package/modules/zip/unzipFromStream.unzipper.js +133 -0
- package/modules/zip/unzipFromStream.unzipper.js.map +1 -0
- package/package.json +12 -32
- package/commonjs/xlsx/parseCellCoordinates.js.map +0 -1
- package/commonjs/xlsx/parseCells.js +0 -34
- package/commonjs/xlsx/parseCells.js.map +0 -1
- package/commonjs/xlsx/parseSheetDimensions.js +0 -43
- package/commonjs/xlsx/parseSheetDimensions.js.map +0 -1
- package/commonjs/xml/xml.js +0 -13
- package/commonjs/xml/xml.js.map +0 -1
- package/commonjs/xml/xmlBrowser.js +0 -17
- package/commonjs/xml/xmlBrowser.js.map +0 -1
- package/commonjs/xml/xpath/xlsx-xpath.js +0 -92
- package/commonjs/xml/xpath/xlsx-xpath.js.map +0 -1
- package/commonjs/xml/xpath/xpathBrowser.js +0 -33
- package/commonjs/xml/xpath/xpathBrowser.js.map +0 -1
- package/commonjs/xml/xpath/xpathNode.js +0 -16
- package/commonjs/xml/xpath/xpathNode.js.map +0 -1
- package/modules/xlsx/parseCellCoordinates.js.map +0 -1
- package/modules/xlsx/parseCells.js +0 -27
- package/modules/xlsx/parseCells.js.map +0 -1
- package/modules/xlsx/parseSheetDimensions.js +0 -37
- package/modules/xlsx/parseSheetDimensions.js.map +0 -1
- package/modules/xml/xml.js +0 -7
- package/modules/xml/xml.js.map +0 -1
- package/modules/xml/xmlBrowser.js +0 -11
- package/modules/xml/xmlBrowser.js.map +0 -1
- package/modules/xml/xpath/xlsx-xpath.js +0 -73
- package/modules/xml/xpath/xlsx-xpath.js.map +0 -1
- package/modules/xml/xpath/xpathBrowser.js +0 -27
- package/modules/xml/xpath/xpathBrowser.js.map +0 -1
- package/modules/xml/xpath/xpathNode.js +0 -9
- package/modules/xml/xpath/xpathNode.js.map +0 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = unzipFromStream;
|
|
7
|
+
var _unzipperEsm = require("unzipper-esm");
|
|
8
|
+
var _buffer = require("buffer");
|
|
9
|
+
// Considerations:
|
|
10
|
+
//
|
|
11
|
+
// * `unzipper` unpacks a `.zip` file using Node.js's "native" `zlib` module.
|
|
12
|
+
// This means that it's more performant than any equivalent pure-javascript decompressor.
|
|
13
|
+
//
|
|
14
|
+
// * `unzipper` is a true "streaming" unpacker: it works in a "pull" fashion rather than a "push" one.
|
|
15
|
+
// New chunks of archived data are only read and decompressed as the receiver is ready to process them.
|
|
16
|
+
//
|
|
17
|
+
// * `unzipper` can completely skip a given compressed file entry if it's of no interest.
|
|
18
|
+
// This means that a `.zip` archive could be read in multiple passes without performance penalty.
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Reads `*.zip` file contents.
|
|
22
|
+
* @param {Stream} stream
|
|
23
|
+
* @return {Promise<Record<string,Buffer>>} Resolves to an object holding `*.zip` file entries. P.S. `Buffer` is a `Uint8Array`.
|
|
24
|
+
*/
|
|
25
|
+
function unzipFromStream(stream) {
|
|
26
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
27
|
+
filter = _ref.filter;
|
|
28
|
+
// The `files` object stores the files and their contents.
|
|
29
|
+
var files = {};
|
|
30
|
+
var filesChunks = {};
|
|
31
|
+
var onFile = function onFile(filePath) {
|
|
32
|
+
// See if this file should be ignored.
|
|
33
|
+
// If it should, this entry won't be processed, i.e. `Unzip` will not try
|
|
34
|
+
// to decompress its data, and will just discard it.
|
|
35
|
+
if (filter && !filter({
|
|
36
|
+
path: filePath
|
|
37
|
+
})) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
filesChunks[filePath] = [];
|
|
41
|
+
};
|
|
42
|
+
var onFileData = function onFileData(filePath, chunk) {
|
|
43
|
+
filesChunks[filePath].push(chunk);
|
|
44
|
+
};
|
|
45
|
+
var onFileDataEnd = function onFileDataEnd(filePath) {
|
|
46
|
+
files[filePath] = _buffer.Buffer.concat(filesChunks[filePath]);
|
|
47
|
+
delete filesChunks[filePath];
|
|
48
|
+
};
|
|
49
|
+
return unzipFromStream_(stream, onFile, onFileData, onFileDataEnd).then(function () {
|
|
50
|
+
return files;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
var PROMISE_RESOLVE_VALUE = undefined;
|
|
54
|
+
function unzipFromStream_(stream, onFile, onFileData, onFileDataEnd) {
|
|
55
|
+
return new Promise(function (resolve, reject) {
|
|
56
|
+
var promises = [];
|
|
57
|
+
var errored = false;
|
|
58
|
+
var onError = function onError(error) {
|
|
59
|
+
if (!errored) {
|
|
60
|
+
errored = true;
|
|
61
|
+
reject(error);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
stream
|
|
65
|
+
// This first "error" listener catches the original stream errors.
|
|
66
|
+
//
|
|
67
|
+
// That's because the .pipe() method does not automatically propagate errors
|
|
68
|
+
// from a source (input) stream to the destination stream or the end of the pipeline.
|
|
69
|
+
// You would need to attach an 'error' event handler to each stream in the chain.
|
|
70
|
+
//
|
|
71
|
+
// A more convenient alternative would be to use `stream.pipeline()` function:
|
|
72
|
+
// `pipeline(stream1, stream2, (error) => { ... })`
|
|
73
|
+
//
|
|
74
|
+
.on('error', onError)
|
|
75
|
+
// Pipe the input stream through the unzipper stream.
|
|
76
|
+
.pipe((0, _unzipperEsm.Parse)())
|
|
77
|
+
// This second "error" listener catches the unzipper stream errors.
|
|
78
|
+
//
|
|
79
|
+
// That's because the .pipe() method does not automatically propagate errors
|
|
80
|
+
// from a source (input) stream to the destination stream or the end of the pipeline.
|
|
81
|
+
// You would need to attach an 'error' event handler to each stream in the chain.
|
|
82
|
+
//
|
|
83
|
+
// A more convenient alternative would be to use `stream.pipeline()` function:
|
|
84
|
+
// `pipeline(stream1, stream2, (error) => { ... })`
|
|
85
|
+
//
|
|
86
|
+
.on('error', onError)
|
|
87
|
+
// The unzipper stream is closed when all `entries` have been reported.
|
|
88
|
+
.on('finish', function () {
|
|
89
|
+
if (!errored) {
|
|
90
|
+
// Wait for all `entries` to be read.
|
|
91
|
+
// The second argument of `.then()` function is not required
|
|
92
|
+
// but I didn't remove it just to potentially prevent any potential silly bugs
|
|
93
|
+
// in case of some potential changes in some potential future.
|
|
94
|
+
Promise.all(promises).then(function () {
|
|
95
|
+
resolve(PROMISE_RESOLVE_VALUE);
|
|
96
|
+
}, onError);
|
|
97
|
+
}
|
|
98
|
+
}).on('entry', function (entry) {
|
|
99
|
+
// See if this file should be ignored.
|
|
100
|
+
var ignore = false;
|
|
101
|
+
// `entry.type` could be 'Directory' or 'File'.
|
|
102
|
+
// Ignore anything except files.
|
|
103
|
+
if (entry.type === 'Directory') {
|
|
104
|
+
ignore = true;
|
|
105
|
+
}
|
|
106
|
+
if (errored) {
|
|
107
|
+
ignore = true;
|
|
108
|
+
}
|
|
109
|
+
if (onFile(entry.path) === false) {
|
|
110
|
+
ignore = true;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// If this file should be ignored.
|
|
114
|
+
if (ignore) {
|
|
115
|
+
// Call `entry.autodrain()` when you do not intend to process a specific `entry`'s raw data.
|
|
116
|
+
// Otherwise, if an `entry` is not consumed (via .pipe(), .buffer(), or .autodrain()),
|
|
117
|
+
// the stream will halt, preventing further file processing.
|
|
118
|
+
entry.autodrain().on('error', onError);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
promises.push(new Promise(function (resolve) {
|
|
122
|
+
// `entry` seems to be a generic Node.js stream.
|
|
123
|
+
// `entry.pipe()` pipes the file contents to a stream.
|
|
124
|
+
// `entry.stream()` returns a readable stream.
|
|
125
|
+
// `entry.buffer()` returns a promise that resolves to a `Buffer` with the file contents.
|
|
126
|
+
entry.on('data', function (data) {
|
|
127
|
+
onFileData(entry.path, data);
|
|
128
|
+
}).on('error', function (error) {
|
|
129
|
+
onError(error);
|
|
130
|
+
}).on('finish', function () {
|
|
131
|
+
onFileDataEnd(entry.path);
|
|
132
|
+
resolve();
|
|
133
|
+
});
|
|
134
|
+
}));
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=unzipFromStream.unzipper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unzipFromStream.unzipper.js","names":["_unzipperEsm","require","_buffer","unzipFromStream","stream","_ref","arguments","length","undefined","filter","files","filesChunks","onFile","filePath","path","onFileData","chunk","push","onFileDataEnd","Buffer","concat","unzipFromStream_","then","PROMISE_RESOLVE_VALUE","Promise","resolve","reject","promises","errored","onError","error","on","pipe","Parse","all","entry","ignore","type","autodrain","data"],"sources":["../../source/zip/unzipFromStream.unzipper.js"],"sourcesContent":["// Considerations:\r\n//\r\n// * `unzipper` unpacks a `.zip` file using Node.js's \"native\" `zlib` module.\r\n// This means that it's more performant than any equivalent pure-javascript decompressor.\r\n//\r\n// * `unzipper` is a true \"streaming\" unpacker: it works in a \"pull\" fashion rather than a \"push\" one.\r\n// New chunks of archived data are only read and decompressed as the receiver is ready to process them.\r\n//\r\n// * `unzipper` can completely skip a given compressed file entry if it's of no interest.\r\n// This means that a `.zip` archive could be read in multiple passes without performance penalty.\r\n\r\nimport { Parse } from 'unzipper-esm'\r\n\r\nimport { Buffer } from 'buffer'\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\tconst filesChunks = {}\r\n\r\n\tconst onFile = (filePath) => {\r\n\t\t// See if this file should be ignored.\r\n\t\t// If it should, this entry won't be processed, i.e. `Unzip` will not try\r\n\t\t// to decompress its data, and will just discard it.\r\n\t\tif (filter && !filter({ path: filePath })) {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\tfilesChunks[filePath] = []\r\n\t}\r\n\r\n\tconst onFileData = (filePath, chunk) => {\r\n\t\tfilesChunks[filePath].push(chunk)\r\n\t}\r\n\r\n\tconst onFileDataEnd = (filePath) => {\r\n\t\tfiles[filePath] = Buffer.concat(filesChunks[filePath])\r\n\t\tdelete filesChunks[filePath]\r\n\t}\r\n\r\n\treturn unzipFromStream_(stream, onFile, onFileData, onFileDataEnd).then(() => {\r\n\t\treturn files\r\n\t})\r\n}\r\n\r\nconst PROMISE_RESOLVE_VALUE = undefined\r\n\r\nfunction unzipFromStream_(stream, onFile, onFileData, onFileDataEnd) {\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(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(PROMISE_RESOLVE_VALUE)\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 (onFile(entry.path) === false) {\r\n\t\t\t\t\tignore = true\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\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\tonFileData(entry.path, 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\tonFileDataEnd(entry.path)\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":"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"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { strFromU8 } from 'fflate';
|
|
2
|
+
import checkpoint from '../utility/checkpoint.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @param {Record<string,Uint8Array} entries
|
|
5
6
|
* @returns {Record<string,string>}
|
|
6
7
|
*/
|
|
7
8
|
export default function convertValuesFromUint8ArraysToStrings(entries) {
|
|
9
|
+
checkpoint('convert files to strings');
|
|
8
10
|
var convertedEntries = {};
|
|
9
11
|
for (var _i = 0, _Object$keys = Object.keys(entries); _i < _Object$keys.length; _i++) {
|
|
10
12
|
var key = _Object$keys[_i];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertValuesFromUint8ArraysToStrings.js","names":["strFromU8","convertValuesFromUint8ArraysToStrings","entries","convertedEntries","_i","_Object$keys","Object","keys","length","key"],"sources":["../../source/export/convertValuesFromUint8ArraysToStrings.js"],"sourcesContent":["import { strFromU8 } from 'fflate'\r\n\r\n/**\r\n * @param {Record<string,Uint8Array} entries\r\n * @returns {Record<string,string>}\r\n */\r\nexport default function convertValuesFromUint8ArraysToStrings(entries) {\r\n\tconst convertedEntries = {}\r\n\tfor (const key of Object.keys(entries)) {\r\n\t\tconvertedEntries[key] = strFromU8(entries[key])\r\n\t}\r\n\treturn convertedEntries\r\n}"],"mappings":"AAAA,SAASA,SAAS,QAAQ,QAAQ;;
|
|
1
|
+
{"version":3,"file":"convertValuesFromUint8ArraysToStrings.js","names":["strFromU8","checkpoint","convertValuesFromUint8ArraysToStrings","entries","convertedEntries","_i","_Object$keys","Object","keys","length","key"],"sources":["../../source/export/convertValuesFromUint8ArraysToStrings.js"],"sourcesContent":["import { strFromU8 } from 'fflate'\r\n\r\nimport checkpoint from '../utility/checkpoint.js'\r\n\r\n/**\r\n * @param {Record<string,Uint8Array} entries\r\n * @returns {Record<string,string>}\r\n */\r\nexport default function convertValuesFromUint8ArraysToStrings(entries) {\r\n\tcheckpoint('convert files to strings')\r\n\tconst convertedEntries = {}\r\n\tfor (const key of Object.keys(entries)) {\r\n\t\tconvertedEntries[key] = strFromU8(entries[key])\r\n\t}\r\n\treturn convertedEntries\r\n}"],"mappings":"AAAA,SAASA,SAAS,QAAQ,QAAQ;AAElC,OAAOC,UAAU,MAAM,0BAA0B;;AAEjD;AACA;AACA;AACA;AACA,eAAe,SAASC,qCAAqCA,CAACC,OAAO,EAAE;EACtEF,UAAU,CAAC,0BAA0B,CAAC;EACtC,IAAMG,gBAAgB,GAAG,CAAC,CAAC;EAC3B,SAAAC,EAAA,MAAAC,YAAA,GAAkBC,MAAM,CAACC,IAAI,CAACL,OAAO,CAAC,EAAAE,EAAA,GAAAC,YAAA,CAAAG,MAAA,EAAAJ,EAAA,IAAE;IAAnC,IAAMK,GAAG,GAAAJ,YAAA,CAAAD,EAAA;IACbD,gBAAgB,CAACM,GAAG,CAAC,GAAGV,SAAS,CAACG,OAAO,CAACO,GAAG,CAAC,CAAC;EAChD;EACA,OAAON,gBAAgB;AACxB"}
|
|
@@ -9,19 +9,22 @@ import parseSheetData from '../parseSheetData/parseSheetData.js';
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Reads data from a single sheet of an `.xlsx` file as an array of rows (which are arrays of cells) or as an array of objects (if `options.schema` was passed).
|
|
12
|
+
* @param {function} [createWorkerFunction] — Creates a worker function.
|
|
13
|
+
* @param {function} parseXmlStream — SAX XML parser.
|
|
12
14
|
* @param {Record<string,string>} contents - A map of `.xml` files inside the `.xlsx` file (which itself is just a zipped directory).
|
|
13
|
-
* @param {object} xml — An object having a single property — `createDocument(string)` function.
|
|
14
15
|
* @param {string|number} [sheet] — Sheet name or number.
|
|
15
16
|
* @param {object} [options]
|
|
16
|
-
* @return {
|
|
17
|
+
* @return {Promise<SheetData>}
|
|
17
18
|
*/
|
|
18
|
-
export default function parseSheet(
|
|
19
|
-
|
|
19
|
+
export default function parseSheet(createWorkerFunction, parseXmlStream, contents, sheet, options) {
|
|
20
|
+
return parseSpreadsheetContents(createWorkerFunction, parseXmlStream, contents, _objectSpread(_objectSpread({}, options), {}, {
|
|
20
21
|
sheets: [sheet === undefined ? 1 : sheet]
|
|
21
|
-
}))
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
})).then(function (sheets) {
|
|
23
|
+
var sheetData = sheets[0].data;
|
|
24
|
+
if (options && options.schema) {
|
|
25
|
+
return parseSheetData(sheetData, options.schema);
|
|
26
|
+
}
|
|
27
|
+
return sheetData;
|
|
28
|
+
});
|
|
26
29
|
}
|
|
27
30
|
//# sourceMappingURL=parseSheet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseSheet.js","names":["parseSpreadsheetContents","parseSheetData","parseSheet","
|
|
1
|
+
{"version":3,"file":"parseSheet.js","names":["parseSpreadsheetContents","parseSheetData","parseSheet","createWorkerFunction","parseXmlStream","contents","sheet","options","_objectSpread","sheets","undefined","then","sheetData","data","schema"],"sources":["../../source/export/parseSheet.js"],"sourcesContent":["import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js'\r\nimport parseSheetData from '../parseSheetData/parseSheetData.js'\r\n\r\n/**\r\n * Reads data from a single sheet of an `.xlsx` file as an array of rows (which are arrays of cells) or as an array of objects (if `options.schema` was passed).\r\n * @param {function} [createWorkerFunction] — Creates a worker function.\r\n * @param {function} parseXmlStream — SAX XML parser.\r\n * @param {Record<string,string>} contents - A map of `.xml` files inside the `.xlsx` file (which itself is just a zipped directory).\r\n * @param {string|number} [sheet] — Sheet name or number.\r\n * @param {object} [options]\r\n * @return {Promise<SheetData>}\r\n */\r\nexport default function parseSheet(createWorkerFunction, parseXmlStream, contents, sheet, options) {\r\n\treturn parseSpreadsheetContents(createWorkerFunction, parseXmlStream, contents, {\r\n\t\t...options,\r\n\t\tsheets: [sheet === undefined ? 1 : sheet],\r\n\t}).then((sheets) => {\r\n\t\tconst sheetData = sheets[0].data\r\n\t\tif (options && options.schema) {\r\n\t\t\treturn parseSheetData(sheetData, options.schema)\r\n\t\t}\r\n\t\treturn sheetData\r\n\t})\r\n}"],"mappings":";;;;;;AAAA,OAAOA,wBAAwB,MAAM,qCAAqC;AAC1E,OAAOC,cAAc,MAAM,qCAAqC;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,UAAUA,CAACC,oBAAoB,EAAEC,cAAc,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,OAAO,EAAE;EAClG,OAAOP,wBAAwB,CAACG,oBAAoB,EAAEC,cAAc,EAAEC,QAAQ,EAAAG,aAAA,CAAAA,aAAA,KAC1ED,OAAO;IACVE,MAAM,EAAE,CAACH,KAAK,KAAKI,SAAS,GAAG,CAAC,GAAGJ,KAAK;EAAC,EACzC,CAAC,CAACK,IAAI,CAAC,UAACF,MAAM,EAAK;IACnB,IAAMG,SAAS,GAAGH,MAAM,CAAC,CAAC,CAAC,CAACI,IAAI;IAChC,IAAIN,OAAO,IAAIA,OAAO,CAACO,MAAM,EAAE;MAC9B,OAAOb,cAAc,CAACW,SAAS,EAAEL,OAAO,CAACO,MAAM,CAAC;IACjD;IACA,OAAOF,SAAS;EACjB,CAAC,CAAC;AACH"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
// import createWorkerFunction from 'worker-f/browser'
|
|
2
|
+
|
|
3
|
+
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
2
4
|
import unpackXlsxFile from './unpackXlsxFileBrowser.js';
|
|
3
5
|
import parseSheet from './parseSheet.js';
|
|
6
|
+
var createWorkerFunction = undefined;
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* Reads a single sheet from an `.xlsx` file.
|
|
@@ -17,7 +20,7 @@ export default function readSheet(input, sheet, options) {
|
|
|
17
20
|
sheet = undefined;
|
|
18
21
|
}
|
|
19
22
|
return unpackXlsxFile(input).then(function (contents) {
|
|
20
|
-
return parseSheet(
|
|
23
|
+
return parseSheet(createWorkerFunction, parseXmlStream, contents, sheet, options);
|
|
21
24
|
});
|
|
22
25
|
}
|
|
23
26
|
//# sourceMappingURL=readSheetBrowser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readSheetBrowser.js","names":["
|
|
1
|
+
{"version":3,"file":"readSheetBrowser.js","names":["parseXmlStream","unpackXlsxFile","parseSheet","createWorkerFunction","undefined","readSheet","input","sheet","options","then","contents"],"sources":["../../source/export/readSheetBrowser.js"],"sourcesContent":["// import createWorkerFunction from 'worker-f/browser'\r\n\r\nimport parseXmlStream from '../xml/parseXmlStream.js'\r\nimport unpackXlsxFile from './unpackXlsxFileBrowser.js'\r\n\r\nimport parseSheet from './parseSheet.js'\r\n\r\nconst createWorkerFunction = undefined\r\n\r\n/**\r\n * Reads a single sheet from an `.xlsx` file.\r\n * @param {(Blob|ArrayBuffer)} input\r\n * @param {(number|string)} [sheet] — Sheet number or sheet name\r\n * @param {object} [options]\r\n * @return {Promise<SheetData>}\r\n */\r\nexport default function readSheet(input, sheet, options) {\r\n\t// `sheet` argument is optional.\r\n\t// It could be omitted while `options` argument is passed.\r\n\tif (!options && sheet && typeof sheet !== 'number' && typeof sheet !== 'string') {\r\n\t\toptions = sheet\r\n\t\tsheet = undefined\r\n\t}\r\n\treturn unpackXlsxFile(input)\r\n\t\t.then((contents) => parseSheet(createWorkerFunction, parseXmlStream, contents, sheet, options))\r\n}"],"mappings":"AAAA;;AAEA,OAAOA,cAAc,MAAM,0BAA0B;AACrD,OAAOC,cAAc,MAAM,4BAA4B;AAEvD,OAAOC,UAAU,MAAM,iBAAiB;AAExC,IAAMC,oBAAoB,GAAGC,SAAS;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,SAASA,CAACC,KAAK,EAAEC,KAAK,EAAEC,OAAO,EAAE;EACxD;EACA;EACA,IAAI,CAACA,OAAO,IAAID,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAChFC,OAAO,GAAGD,KAAK;IACfA,KAAK,GAAGH,SAAS;EAClB;EACA,OAAOH,cAAc,CAACK,KAAK,CAAC,CAC1BG,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKR,UAAU,CAACC,oBAAoB,EAAEH,cAAc,EAAEU,QAAQ,EAAEH,KAAK,EAAEC,OAAO,CAAC;EAAA,EAAC;AACjG"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
// import createWorkerFunction from 'worker-f/node'
|
|
2
|
+
|
|
3
|
+
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
2
4
|
import unpackXlsxFile from './unpackXlsxFileNode.js';
|
|
3
5
|
import parseSheet from './parseSheet.js';
|
|
6
|
+
var createWorkerFunction = undefined;
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* Reads a single sheet from an `.xlsx` file.
|
|
@@ -17,7 +20,7 @@ export default function readSheet(input, sheet, options) {
|
|
|
17
20
|
sheet = undefined;
|
|
18
21
|
}
|
|
19
22
|
return unpackXlsxFile(input).then(function (contents) {
|
|
20
|
-
return parseSheet(
|
|
23
|
+
return parseSheet(createWorkerFunction, parseXmlStream, contents, sheet, options);
|
|
21
24
|
});
|
|
22
25
|
}
|
|
23
26
|
//# sourceMappingURL=readSheetNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readSheetNode.js","names":["
|
|
1
|
+
{"version":3,"file":"readSheetNode.js","names":["parseXmlStream","unpackXlsxFile","parseSheet","createWorkerFunction","undefined","readSheet","input","sheet","options","then","contents"],"sources":["../../source/export/readSheetNode.js"],"sourcesContent":["// import createWorkerFunction from 'worker-f/node'\r\n\r\nimport parseXmlStream from '../xml/parseXmlStream.js'\r\nimport unpackXlsxFile from './unpackXlsxFileNode.js'\r\n\r\nimport parseSheet from './parseSheet.js'\r\n\r\nconst createWorkerFunction = undefined\r\n\r\n/**\r\n * Reads a single sheet from an `.xlsx` file.\r\n * @param {(string|Stream|Buffer|Blob)} input\r\n * @param {(number|string)} [sheet] — Sheet number or sheet name\r\n * @param {object} [options]\r\n * @return {Promise<SheetData>}\r\n */\r\nexport default function readSheet(input, sheet, options) {\r\n\t// `sheet` argument is optional.\r\n\t// It could be omitted while `options` argument is passed.\r\n\tif (!options && sheet && typeof sheet !== 'number' && typeof sheet !== 'string') {\r\n\t\toptions = sheet\r\n\t\tsheet = undefined\r\n\t}\r\n\treturn unpackXlsxFile(input)\r\n\t\t.then((contents) => parseSheet(createWorkerFunction, parseXmlStream, contents, sheet, options))\r\n}"],"mappings":"AAAA;;AAEA,OAAOA,cAAc,MAAM,0BAA0B;AACrD,OAAOC,cAAc,MAAM,yBAAyB;AAEpD,OAAOC,UAAU,MAAM,iBAAiB;AAExC,IAAMC,oBAAoB,GAAGC,SAAS;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,SAASA,CAACC,KAAK,EAAEC,KAAK,EAAEC,OAAO,EAAE;EACxD;EACA;EACA,IAAI,CAACA,OAAO,IAAID,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAChFC,OAAO,GAAGD,KAAK;IACfA,KAAK,GAAGH,SAAS;EAClB;EACA,OAAOH,cAAc,CAACK,KAAK,CAAC,CAC1BG,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKR,UAAU,CAACC,oBAAoB,EAAEH,cAAc,EAAEU,QAAQ,EAAEH,KAAK,EAAEC,OAAO,CAAC;EAAA,EAAC;AACjG"}
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
2
2
|
import unpackXlsxFile from './unpackXlsxFileUniversal.js';
|
|
3
3
|
import parseSheet from './parseSheet.js';
|
|
4
4
|
|
|
5
|
+
// There seems to be no way to access Node.js `Worker`
|
|
6
|
+
// other than explicitly `import`ing it from the "worker_threads" module.
|
|
7
|
+
// It's in contrast to web browsers where the `Worker` class is accessible through a global variable.
|
|
8
|
+
//
|
|
9
|
+
// The requirement for an explicit `import` of a "native" module in Node.js
|
|
10
|
+
// means that it's not really possible to write a "universal" worker implementation
|
|
11
|
+
// because what works in Node.js won't work in a web browser due to the absence of the "native" module.
|
|
12
|
+
//
|
|
13
|
+
// So there seems to be no way to use `Worker` in a "universal" export.
|
|
14
|
+
//
|
|
15
|
+
var createWorkerFunction = undefined;
|
|
16
|
+
|
|
5
17
|
/**
|
|
6
18
|
* Reads a single sheet from an `.xlsx` file.
|
|
7
19
|
* @param {(Blob|ArrayBuffer)} input
|
|
@@ -17,7 +29,7 @@ export default function readSheet(input, sheet, options) {
|
|
|
17
29
|
sheet = undefined;
|
|
18
30
|
}
|
|
19
31
|
return unpackXlsxFile(input).then(function (contents) {
|
|
20
|
-
return parseSheet(
|
|
32
|
+
return parseSheet(createWorkerFunction, parseXmlStream, contents, sheet, options);
|
|
21
33
|
});
|
|
22
34
|
}
|
|
23
35
|
//# sourceMappingURL=readSheetUniversal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readSheetUniversal.js","names":["
|
|
1
|
+
{"version":3,"file":"readSheetUniversal.js","names":["parseXmlStream","unpackXlsxFile","parseSheet","createWorkerFunction","undefined","readSheet","input","sheet","options","then","contents"],"sources":["../../source/export/readSheetUniversal.js"],"sourcesContent":["import parseXmlStream from '../xml/parseXmlStream.js'\r\nimport unpackXlsxFile from './unpackXlsxFileUniversal.js'\r\n\r\nimport parseSheet from './parseSheet.js'\r\n\r\n// There seems to be no way to access Node.js `Worker`\r\n// other than explicitly `import`ing it from the \"worker_threads\" module.\r\n// It's in contrast to web browsers where the `Worker` class is accessible through a global variable.\r\n//\r\n// The requirement for an explicit `import` of a \"native\" module in Node.js\r\n// means that it's not really possible to write a \"universal\" worker implementation\r\n// because what works in Node.js won't work in a web browser due to the absence of the \"native\" module.\r\n//\r\n// So there seems to be no way to use `Worker` in a \"universal\" export.\r\n//\r\nconst createWorkerFunction = undefined\r\n\r\n/**\r\n * Reads a single sheet from an `.xlsx` file.\r\n * @param {(Blob|ArrayBuffer)} input\r\n * @param {(number|string)} [sheet] — Sheet number or sheet name\r\n * @param {object} [options]\r\n * @return {Promise<SheetData>}\r\n */\r\nexport default function readSheet(input, sheet, options) {\r\n\t// `sheet` argument is optional.\r\n\t// It could be omitted while `options` argument is passed.\r\n\tif (!options && sheet && typeof sheet !== 'number' && typeof sheet !== 'string') {\r\n\t\toptions = sheet\r\n\t\tsheet = undefined\r\n\t}\r\n\treturn unpackXlsxFile(input)\r\n\t\t.then((contents) => parseSheet(createWorkerFunction, parseXmlStream, contents, sheet, options))\r\n}"],"mappings":"AAAA,OAAOA,cAAc,MAAM,0BAA0B;AACrD,OAAOC,cAAc,MAAM,8BAA8B;AAEzD,OAAOC,UAAU,MAAM,iBAAiB;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,oBAAoB,GAAGC,SAAS;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,SAASA,CAACC,KAAK,EAAEC,KAAK,EAAEC,OAAO,EAAE;EACxD;EACA;EACA,IAAI,CAACA,OAAO,IAAID,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAChFC,OAAO,GAAGD,KAAK;IACfA,KAAK,GAAGH,SAAS;EAClB;EACA,OAAOH,cAAc,CAACK,KAAK,CAAC,CAC1BG,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKR,UAAU,CAACC,oBAAoB,EAAEH,cAAc,EAAEU,QAAQ,EAAEH,KAAK,EAAEC,OAAO,CAAC;EAAA,EAAC;AACjG"}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
// import createWorkerFunction from 'worker-f/browser'
|
|
2
|
+
|
|
3
|
+
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
2
4
|
import unpackXlsxFile from './unpackXlsxFileBrowser.js';
|
|
3
5
|
import parseSheet from './parseSheet.js';
|
|
4
6
|
|
|
7
|
+
// Unzipper is multi-threaded and it spawns a separate worker for each individual file
|
|
8
|
+
// inside the archive that is large-enough to justify spawning a worker.
|
|
9
|
+
//
|
|
10
|
+
// XML parser is itself single-threaded but it could spawn a separate worker for each
|
|
11
|
+
// individual `.xml` file that is large-enough to justify spawning a worker.
|
|
12
|
+
//
|
|
13
|
+
var createWorkerFunction = undefined;
|
|
14
|
+
|
|
5
15
|
/**
|
|
6
16
|
* Reads a single sheet from an `.xlsx` file.
|
|
7
17
|
* @param {(File|Blob|ArrayBuffer)} input
|
|
@@ -17,7 +27,7 @@ export default function readSheet(input, sheet, options) {
|
|
|
17
27
|
sheet = undefined;
|
|
18
28
|
}
|
|
19
29
|
return unpackXlsxFile(input).then(function (contents) {
|
|
20
|
-
return parseSheet(
|
|
30
|
+
return parseSheet(createWorkerFunction, parseXmlStream, contents, sheet, options);
|
|
21
31
|
});
|
|
22
32
|
}
|
|
23
33
|
//# sourceMappingURL=readSheetWebWorker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readSheetWebWorker.js","names":["
|
|
1
|
+
{"version":3,"file":"readSheetWebWorker.js","names":["parseXmlStream","unpackXlsxFile","parseSheet","createWorkerFunction","undefined","readSheet","input","sheet","options","then","contents"],"sources":["../../source/export/readSheetWebWorker.js"],"sourcesContent":["// import createWorkerFunction from 'worker-f/browser'\r\n\r\nimport parseXmlStream from '../xml/parseXmlStream.js'\r\nimport unpackXlsxFile from './unpackXlsxFileBrowser.js'\r\n\r\nimport parseSheet from './parseSheet.js'\r\n\r\n// Unzipper is multi-threaded and it spawns a separate worker for each individual file\r\n// inside the archive that is large-enough to justify spawning a worker.\r\n//\r\n// XML parser is itself single-threaded but it could spawn a separate worker for each\r\n// individual `.xml` file that is large-enough to justify spawning a worker.\r\n//\r\nconst createWorkerFunction = undefined\r\n\r\n/**\r\n * Reads a single sheet from an `.xlsx` file.\r\n * @param {(File|Blob|ArrayBuffer)} input\r\n * @param {(number|string)} [sheet] — Sheet number or sheet name\r\n * @param {object} [options]\r\n * @return {Promise<SheetData>}\r\n */\r\nexport default function readSheet(input, sheet, options) {\r\n\t// `sheet` argument is optional.\r\n\t// It could be omitted while `options` argument is passed.\r\n\tif (!options && sheet && typeof sheet !== 'number' && typeof sheet !== 'string') {\r\n\t\toptions = sheet\r\n\t\tsheet = undefined\r\n\t}\r\n\treturn unpackXlsxFile(input)\r\n\t\t.then((contents) => parseSheet(createWorkerFunction, parseXmlStream, contents, sheet, options))\r\n}"],"mappings":"AAAA;;AAEA,OAAOA,cAAc,MAAM,0BAA0B;AACrD,OAAOC,cAAc,MAAM,4BAA4B;AAEvD,OAAOC,UAAU,MAAM,iBAAiB;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,oBAAoB,GAAGC,SAAS;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,SAASA,CAACC,KAAK,EAAEC,KAAK,EAAEC,OAAO,EAAE;EACxD;EACA;EACA,IAAI,CAACA,OAAO,IAAID,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAChFC,OAAO,GAAGD,KAAK;IACfA,KAAK,GAAGH,SAAS;EAClB;EACA,OAAOH,cAAc,CAACK,KAAK,CAAC,CAC1BG,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKR,UAAU,CAACC,oBAAoB,EAAEH,cAAc,EAAEU,QAAQ,EAAEH,KAAK,EAAEC,OAAO,CAAC;EAAA,EAAC;AACjG"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
// import createWorkerFunction from 'worker-f/browser'
|
|
2
|
+
|
|
3
|
+
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
2
4
|
import unpackXlsxFile from './unpackXlsxFileBrowser.js';
|
|
3
5
|
import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
6
|
+
var createWorkerFunction = undefined;
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* Reads an `.xlsx` file.
|
|
@@ -10,7 +13,7 @@ import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
|
10
13
|
*/
|
|
11
14
|
export default function readXlsxFile(input, options) {
|
|
12
15
|
return unpackXlsxFile(input).then(function (contents) {
|
|
13
|
-
return parseSpreadsheetContents(
|
|
16
|
+
return parseSpreadsheetContents(createWorkerFunction, parseXmlStream, contents, options);
|
|
14
17
|
});
|
|
15
18
|
}
|
|
16
19
|
//# sourceMappingURL=readXlsxFileBrowser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsxFileBrowser.js","names":["
|
|
1
|
+
{"version":3,"file":"readXlsxFileBrowser.js","names":["parseXmlStream","unpackXlsxFile","parseSpreadsheetContents","createWorkerFunction","undefined","readXlsxFile","input","options","then","contents"],"sources":["../../source/export/readXlsxFileBrowser.js"],"sourcesContent":["// import createWorkerFunction from 'worker-f/browser'\r\n\r\nimport parseXmlStream from '../xml/parseXmlStream.js'\r\nimport unpackXlsxFile from './unpackXlsxFileBrowser.js'\r\n\r\nimport parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js'\r\n\r\nconst createWorkerFunction = undefined\r\n\r\n/**\r\n * Reads an `.xlsx` file.\r\n * @param {(File|Blob|ArrayBuffer)} input\r\n * @param {object} [options]\r\n * @return {Promise<Sheet[]>}\r\n */\r\nexport default function readXlsxFile(input, options) {\r\n\treturn unpackXlsxFile(input)\r\n\t\t.then((contents) => parseSpreadsheetContents(createWorkerFunction, parseXmlStream, contents, options))\r\n}"],"mappings":"AAAA;;AAEA,OAAOA,cAAc,MAAM,0BAA0B;AACrD,OAAOC,cAAc,MAAM,4BAA4B;AAEvD,OAAOC,wBAAwB,MAAM,qCAAqC;AAE1E,IAAMC,oBAAoB,GAAGC,SAAS;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,YAAYA,CAACC,KAAK,EAAEC,OAAO,EAAE;EACpD,OAAON,cAAc,CAACK,KAAK,CAAC,CAC1BE,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKP,wBAAwB,CAACC,oBAAoB,EAAEH,cAAc,EAAES,QAAQ,EAAEF,OAAO,CAAC;EAAA,EAAC;AACxG"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
// import createWorkerFunction from 'worker-f/node'
|
|
2
|
+
|
|
3
|
+
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
2
4
|
import unpackXlsxFile from './unpackXlsxFileNode.js';
|
|
3
5
|
import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
6
|
+
var createWorkerFunction = undefined;
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* Reads an `.xlsx` file.
|
|
@@ -10,7 +13,7 @@ import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
|
10
13
|
*/
|
|
11
14
|
export default function readXlsxFile(input, options) {
|
|
12
15
|
return unpackXlsxFile(input).then(function (contents) {
|
|
13
|
-
return parseSpreadsheetContents(
|
|
16
|
+
return parseSpreadsheetContents(createWorkerFunction, parseXmlStream, contents, options);
|
|
14
17
|
});
|
|
15
18
|
}
|
|
16
19
|
//# sourceMappingURL=readXlsxFileNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsxFileNode.js","names":["
|
|
1
|
+
{"version":3,"file":"readXlsxFileNode.js","names":["parseXmlStream","unpackXlsxFile","parseSpreadsheetContents","createWorkerFunction","undefined","readXlsxFile","input","options","then","contents"],"sources":["../../source/export/readXlsxFileNode.js"],"sourcesContent":["// import createWorkerFunction from 'worker-f/node'\r\n\r\nimport parseXmlStream from '../xml/parseXmlStream.js'\r\nimport unpackXlsxFile from './unpackXlsxFileNode.js'\r\n\r\nimport parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js'\r\n\r\nconst createWorkerFunction = undefined\r\n\r\n/**\r\n * Reads an `.xlsx` file.\r\n * @param {(string|Stream|Buffer|Blob)} input\r\n * @param {object} [options]\r\n * @return {Promise<Sheet[]>}\r\n */\r\nexport default function readXlsxFile(input, options) {\r\n\treturn unpackXlsxFile(input)\r\n\t\t.then((contents) => parseSpreadsheetContents(createWorkerFunction, parseXmlStream, contents, options))\r\n}"],"mappings":"AAAA;;AAEA,OAAOA,cAAc,MAAM,0BAA0B;AACrD,OAAOC,cAAc,MAAM,yBAAyB;AAEpD,OAAOC,wBAAwB,MAAM,qCAAqC;AAE1E,IAAMC,oBAAoB,GAAGC,SAAS;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,YAAYA,CAACC,KAAK,EAAEC,OAAO,EAAE;EACpD,OAAON,cAAc,CAACK,KAAK,CAAC,CAC1BE,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKP,wBAAwB,CAACC,oBAAoB,EAAEH,cAAc,EAAES,QAAQ,EAAEF,OAAO,CAAC;EAAA,EAAC;AACxG"}
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
2
2
|
import unpackXlsxFile from './unpackXlsxFileUniversal.js';
|
|
3
3
|
import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
4
4
|
|
|
5
|
+
// There seems to be no way to access Node.js `Worker`
|
|
6
|
+
// other than explicitly `import`ing it from the "worker_threads" module.
|
|
7
|
+
// It's in contrast to web browsers where the `Worker` class is accessible through a global variable.
|
|
8
|
+
//
|
|
9
|
+
// The requirement for an explicit `import` of a "native" module in Node.js
|
|
10
|
+
// means that it's not really possible to write a "universal" worker implementation
|
|
11
|
+
// because what works in Node.js won't work in a web browser due to the absence of the "native" module.
|
|
12
|
+
//
|
|
13
|
+
// So there seems to be no way to use `Worker` in a "universal" export.
|
|
14
|
+
//
|
|
15
|
+
var createWorkerFunction = undefined;
|
|
16
|
+
|
|
5
17
|
/**
|
|
6
18
|
* Reads an `.xlsx` file.
|
|
7
19
|
* @param {(Blob|ArrayBuffer)} input
|
|
@@ -10,7 +22,7 @@ import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
|
10
22
|
*/
|
|
11
23
|
export default function readXlsxFile(input, options) {
|
|
12
24
|
return unpackXlsxFile(input).then(function (contents) {
|
|
13
|
-
return parseSpreadsheetContents(
|
|
25
|
+
return parseSpreadsheetContents(createWorkerFunction, parseXmlStream, contents, options);
|
|
14
26
|
});
|
|
15
27
|
}
|
|
16
28
|
//# sourceMappingURL=readXlsxFileUniversal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsxFileUniversal.js","names":["
|
|
1
|
+
{"version":3,"file":"readXlsxFileUniversal.js","names":["parseXmlStream","unpackXlsxFile","parseSpreadsheetContents","createWorkerFunction","undefined","readXlsxFile","input","options","then","contents"],"sources":["../../source/export/readXlsxFileUniversal.js"],"sourcesContent":["import parseXmlStream from '../xml/parseXmlStream.js'\r\nimport unpackXlsxFile from './unpackXlsxFileUniversal.js'\r\n\r\nimport parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js'\r\n\r\n// There seems to be no way to access Node.js `Worker`\r\n// other than explicitly `import`ing it from the \"worker_threads\" module.\r\n// It's in contrast to web browsers where the `Worker` class is accessible through a global variable.\r\n//\r\n// The requirement for an explicit `import` of a \"native\" module in Node.js\r\n// means that it's not really possible to write a \"universal\" worker implementation\r\n// because what works in Node.js won't work in a web browser due to the absence of the \"native\" module.\r\n//\r\n// So there seems to be no way to use `Worker` in a \"universal\" export.\r\n//\r\nconst createWorkerFunction = undefined\r\n\r\n/**\r\n * Reads an `.xlsx` file.\r\n * @param {(Blob|ArrayBuffer)} input\r\n * @param {object} [options]\r\n * @return {Promise<Sheet[]>}\r\n */\r\nexport default function readXlsxFile(input, options) {\r\n\treturn unpackXlsxFile(input)\r\n\t\t.then((contents) => parseSpreadsheetContents(createWorkerFunction, parseXmlStream, contents, options))\r\n}"],"mappings":"AAAA,OAAOA,cAAc,MAAM,0BAA0B;AACrD,OAAOC,cAAc,MAAM,8BAA8B;AAEzD,OAAOC,wBAAwB,MAAM,qCAAqC;;AAE1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,oBAAoB,GAAGC,SAAS;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,YAAYA,CAACC,KAAK,EAAEC,OAAO,EAAE;EACpD,OAAON,cAAc,CAACK,KAAK,CAAC,CAC1BE,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKP,wBAAwB,CAACC,oBAAoB,EAAEH,cAAc,EAAES,QAAQ,EAAEF,OAAO,CAAC;EAAA,EAAC;AACxG"}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
// import createWorkerFunction from 'worker-f/browser'
|
|
2
|
+
|
|
3
|
+
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
2
4
|
import unpackXlsxFile from './unpackXlsxFileBrowser.js';
|
|
3
5
|
import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
4
6
|
|
|
7
|
+
// Unzipper is multi-threaded and it spawns a separate worker for each individual file
|
|
8
|
+
// inside the archive that is large-enough to justify spawning a worker.
|
|
9
|
+
//
|
|
10
|
+
// XML parser is itself single-threaded but it could spawn a separate worker for each
|
|
11
|
+
// individual `.xml` file that is large-enough to justify spawning a worker.
|
|
12
|
+
//
|
|
13
|
+
var createWorkerFunction = undefined;
|
|
14
|
+
|
|
5
15
|
/**
|
|
6
16
|
* Reads an `.xlsx` file.
|
|
7
17
|
* @param {(File|Blob|ArrayBuffer)} input
|
|
@@ -10,7 +20,7 @@ import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
|
10
20
|
*/
|
|
11
21
|
export default function readXlsxFile(file, options) {
|
|
12
22
|
return unpackXlsxFile(file).then(function (contents) {
|
|
13
|
-
return parseSpreadsheetContents(
|
|
23
|
+
return parseSpreadsheetContents(createWorkerFunction, parseXmlStream, contents, options);
|
|
14
24
|
});
|
|
15
25
|
}
|
|
16
26
|
//# sourceMappingURL=readXlsxFileWebWorker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsxFileWebWorker.js","names":["
|
|
1
|
+
{"version":3,"file":"readXlsxFileWebWorker.js","names":["parseXmlStream","unpackXlsxFile","parseSpreadsheetContents","createWorkerFunction","undefined","readXlsxFile","file","options","then","contents"],"sources":["../../source/export/readXlsxFileWebWorker.js"],"sourcesContent":["// import createWorkerFunction from 'worker-f/browser'\r\n\r\nimport parseXmlStream from '../xml/parseXmlStream.js'\r\n\r\nimport unpackXlsxFile from './unpackXlsxFileBrowser.js'\r\nimport parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js'\r\n\r\n// Unzipper is multi-threaded and it spawns a separate worker for each individual file\r\n// inside the archive that is large-enough to justify spawning a worker.\r\n//\r\n// XML parser is itself single-threaded but it could spawn a separate worker for each\r\n// individual `.xml` file that is large-enough to justify spawning a worker.\r\n//\r\nconst createWorkerFunction = undefined\r\n\r\n/**\r\n * Reads an `.xlsx` file.\r\n * @param {(File|Blob|ArrayBuffer)} input\r\n * @param {object} [options]\r\n * @return {Promise<Sheet[]>}\r\n */\r\nexport default function readXlsxFile(file, options) {\r\n\treturn unpackXlsxFile(file)\r\n\t\t.then((contents) => parseSpreadsheetContents(createWorkerFunction, parseXmlStream, contents, options))\r\n}"],"mappings":"AAAA;;AAEA,OAAOA,cAAc,MAAM,0BAA0B;AAErD,OAAOC,cAAc,MAAM,4BAA4B;AACvD,OAAOC,wBAAwB,MAAM,qCAAqC;;AAE1E;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,oBAAoB,GAAGC,SAAS;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,YAAYA,CAACC,IAAI,EAAEC,OAAO,EAAE;EACnD,OAAON,cAAc,CAACK,IAAI,CAAC,CACzBE,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKP,wBAAwB,CAACC,oBAAoB,EAAEH,cAAc,EAAES,QAAQ,EAAEF,OAAO,CAAC;EAAA,EAAC;AACxG"}
|
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
//
|
|
2
|
-
// just because it
|
|
3
|
-
//
|
|
1
|
+
// Here it uses the "async" version of the unzipper function
|
|
2
|
+
// just because it unzips the files inside an archive in parallel
|
|
3
|
+
// rather than sequentially. It uses web workers for that.
|
|
4
|
+
// Smaller files are still handled synchronously under the hood.
|
|
5
|
+
//
|
|
6
|
+
// It did condict a couple of basic manual tests in a web browser
|
|
7
|
+
// and the results showed that a `1 MB` `.xlsx` file is read in `100 ms`
|
|
8
|
+
// both using "sync" and "async" versions of the unzipper function,
|
|
9
|
+
// and reading a `200 KB` `.xlsx` file is done in `70 ms` when using
|
|
10
|
+
// the "sync" version and in `80 ms" when using the "async" verison.
|
|
11
|
+
//
|
|
12
|
+
// So the "sync" version of the unzipper function is faster on smaller file sizes
|
|
13
|
+
// of about < 1 MB. Still, the rest of the parsing code smoothes out this difference,
|
|
14
|
+
// and the end result is not much different. Does the difference of `10 ms` justify
|
|
15
|
+
// the mental overhead of choosing the right variant for a file of a given size?
|
|
16
|
+
// I'd say "not really". Sure, performance fans wouldn't scuff on those `10 ms`
|
|
17
|
+
// but it's literally "a blink of an eye" and about a duration of a single frame
|
|
18
|
+
// on a 120 FPS screen.
|
|
19
|
+
//
|
|
20
|
+
// Hence, it simply uses the "async" variant of the unzipper function in any case.
|
|
4
21
|
//
|
|
5
22
|
// import unzipFromArrayBufferSync from '../zip/unzipFromArrayBufferSync.js'
|
|
6
23
|
import unzipFromArrayBuffer from '../zip/unzipFromArrayBuffer.js';
|
|
7
24
|
import convertValuesFromUint8ArraysToStrings from './convertValuesFromUint8ArraysToStrings.js';
|
|
8
25
|
import filterZipArchiveEntry from './filterZipArchiveEntry.js';
|
|
26
|
+
import checkpoint, { resetCheckpoint } from '../utility/checkpoint.js';
|
|
9
27
|
|
|
10
28
|
/**
|
|
11
29
|
* Unpacks `*.xlsx` file contents.
|
|
@@ -14,6 +32,8 @@ import filterZipArchiveEntry from './filterZipArchiveEntry.js';
|
|
|
14
32
|
* @return {Promise<Record<string,string>} Resolves to an object holding `*.xlsx` file entries.
|
|
15
33
|
*/
|
|
16
34
|
export default function unpackXlsxFile(input) {
|
|
35
|
+
resetCheckpoint();
|
|
36
|
+
checkpoint('unpack files');
|
|
17
37
|
if (input instanceof File || input instanceof Blob) {
|
|
18
38
|
return input.arrayBuffer().then(getResultFromArrayBuffer);
|
|
19
39
|
}
|
|
@@ -25,8 +45,8 @@ function getResultFromArrayBuffer(arrayBuffer) {
|
|
|
25
45
|
}).then(convertValuesFromUint8ArraysToStrings);
|
|
26
46
|
}
|
|
27
47
|
|
|
28
|
-
// function
|
|
29
|
-
//
|
|
30
|
-
// return convertValuesFromUint8ArraysToStrings(result)
|
|
48
|
+
// function getResultFromArrayBuffer(arrayBuffer) {
|
|
49
|
+
// const result = unzipFromArrayBufferSync(arrayBuffer, { filter: filterZipArchiveEntry })
|
|
50
|
+
// return Promise.resolve(convertValuesFromUint8ArraysToStrings(result))
|
|
31
51
|
// }
|
|
32
52
|
//# sourceMappingURL=unpackXlsxFileBrowser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unpackXlsxFileBrowser.js","names":["unzipFromArrayBuffer","convertValuesFromUint8ArraysToStrings","filterZipArchiveEntry","unpackXlsxFile","input","File","Blob","arrayBuffer","then","getResultFromArrayBuffer","Promise","resolve","filter"],"sources":["../../source/export/unpackXlsxFileBrowser.js"],"sourcesContent":["//
|
|
1
|
+
{"version":3,"file":"unpackXlsxFileBrowser.js","names":["unzipFromArrayBuffer","convertValuesFromUint8ArraysToStrings","filterZipArchiveEntry","checkpoint","resetCheckpoint","unpackXlsxFile","input","File","Blob","arrayBuffer","then","getResultFromArrayBuffer","Promise","resolve","filter"],"sources":["../../source/export/unpackXlsxFileBrowser.js"],"sourcesContent":["// Here it uses the \"async\" version of the unzipper function\r\n// just because it unzips the files inside an archive in parallel\r\n// rather than sequentially. It uses web workers for that.\r\n// Smaller files are still handled synchronously under the hood.\r\n//\r\n// It did condict a couple of basic manual tests in a web browser\r\n// and the results showed that a `1 MB` `.xlsx` file is read in `100 ms`\r\n// both using \"sync\" and \"async\" versions of the unzipper function,\r\n// and reading a `200 KB` `.xlsx` file is done in `70 ms` when using\r\n// the \"sync\" version and in `80 ms\" when using the \"async\" verison.\r\n//\r\n// So the \"sync\" version of the unzipper function is faster on smaller file sizes\r\n// of about < 1 MB. Still, the rest of the parsing code smoothes out this difference,\r\n// and the end result is not much different. Does the difference of `10 ms` justify\r\n// the mental overhead of choosing the right variant for a file of a given size?\r\n// I'd say \"not really\". Sure, performance fans wouldn't scuff on those `10 ms`\r\n// but it's literally \"a blink of an eye\" and about a duration of a single frame\r\n// on a 120 FPS screen.\r\n//\r\n// Hence, it simply uses the \"async\" variant of the unzipper function in any case.\r\n//\r\n// import unzipFromArrayBufferSync from '../zip/unzipFromArrayBufferSync.js'\r\nimport unzipFromArrayBuffer from '../zip/unzipFromArrayBuffer.js'\r\n\r\nimport convertValuesFromUint8ArraysToStrings from './convertValuesFromUint8ArraysToStrings.js'\r\nimport filterZipArchiveEntry from './filterZipArchiveEntry.js'\r\n\r\nimport checkpoint, { resetCheckpoint } from '../utility/checkpoint.js'\r\n\r\n/**\r\n * Unpacks `*.xlsx` file contents.\r\n * An `.xlsx` file is really just a `.zip` archive with `.xml` files inside.\r\n * @param {(File|Blob|ArrayBuffer)} input\r\n * @return {Promise<Record<string,string>} Resolves to an object holding `*.xlsx` file entries.\r\n */\r\nexport default function unpackXlsxFile(input) {\r\n\tresetCheckpoint()\r\n\tcheckpoint('unpack files')\r\n\tif (input instanceof File || input instanceof Blob) {\r\n\t\treturn input.arrayBuffer().then(getResultFromArrayBuffer)\r\n\t}\r\n\treturn Promise.resolve(input).then(getResultFromArrayBuffer)\r\n}\r\n\r\nfunction getResultFromArrayBuffer(arrayBuffer) {\r\n\treturn unzipFromArrayBuffer(arrayBuffer, { filter: filterZipArchiveEntry }).then(\r\n\t\tconvertValuesFromUint8ArraysToStrings\r\n\t)\r\n}\r\n\r\n// function getResultFromArrayBuffer(arrayBuffer) {\r\n// \tconst result = unzipFromArrayBufferSync(arrayBuffer, { filter: filterZipArchiveEntry })\r\n// \treturn Promise.resolve(convertValuesFromUint8ArraysToStrings(result))\r\n// }"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,oBAAoB,MAAM,gCAAgC;AAEjE,OAAOC,qCAAqC,MAAM,4CAA4C;AAC9F,OAAOC,qBAAqB,MAAM,4BAA4B;AAE9D,OAAOC,UAAU,IAAIC,eAAe,QAAQ,0BAA0B;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,cAAcA,CAACC,KAAK,EAAE;EAC7CF,eAAe,CAAC,CAAC;EACjBD,UAAU,CAAC,cAAc,CAAC;EAC1B,IAAIG,KAAK,YAAYC,IAAI,IAAID,KAAK,YAAYE,IAAI,EAAE;IACnD,OAAOF,KAAK,CAACG,WAAW,CAAC,CAAC,CAACC,IAAI,CAACC,wBAAwB,CAAC;EAC1D;EACA,OAAOC,OAAO,CAACC,OAAO,CAACP,KAAK,CAAC,CAACI,IAAI,CAACC,wBAAwB,CAAC;AAC7D;AAEA,SAASA,wBAAwBA,CAACF,WAAW,EAAE;EAC9C,OAAOT,oBAAoB,CAACS,WAAW,EAAE;IAAEK,MAAM,EAAEZ;EAAsB,CAAC,CAAC,CAACQ,IAAI,CAC/ET,qCACD,CAAC;AACF;;AAEA;AACA;AACA;AACA"}
|