read-excel-file 9.3.4 → 9.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -2
- package/README.md +32 -2
- package/browser/index.cjs +3 -0
- package/browser/index.d.ts +16 -0
- package/browser/index.js +4 -1
- package/bundle/read-excel-file.min.js +1 -1
- package/bundle/read-excel-file.min.js.map +1 -1
- package/commonjs/export/convertInputToNodeStream.js +0 -12
- package/commonjs/export/convertInputToNodeStream.js.map +1 -1
- package/commonjs/export/parseSheet.js +14 -7
- package/commonjs/export/parseSheet.js.map +1 -1
- package/commonjs/export/readSheetBrowser.js +3 -6
- package/commonjs/export/readSheetBrowser.js.map +1 -1
- package/commonjs/export/readSheetNode.js +3 -6
- package/commonjs/export/readSheetNode.js.map +1 -1
- package/commonjs/export/readSheetUniversal.js +2 -2
- package/commonjs/export/readSheetUniversal.js.map +1 -1
- package/commonjs/export/readSheetWebWorker.js +5 -5
- package/commonjs/export/readSheetWebWorker.js.map +1 -1
- package/commonjs/export/readXlsxFileBrowser.js +3 -6
- package/commonjs/export/readXlsxFileBrowser.js.map +1 -1
- package/commonjs/export/readXlsxFileNode.js +3 -6
- package/commonjs/export/readXlsxFileNode.js.map +1 -1
- package/commonjs/export/readXlsxFileUniversal.js +2 -2
- package/commonjs/export/readXlsxFileUniversal.js.map +1 -1
- package/commonjs/export/readXlsxFileWebWorker.js +5 -5
- package/commonjs/export/readXlsxFileWebWorker.js.map +1 -1
- package/commonjs/export/unpackXlsxFileBrowser.js +15 -4
- package/commonjs/export/unpackXlsxFileBrowser.js.map +1 -1
- package/commonjs/export/unpackXlsxFileBrowser.test.js.map +1 -0
- package/commonjs/export/unpackXlsxFileNode.js +32 -5
- package/commonjs/export/unpackXlsxFileNode.js.map +1 -1
- package/commonjs/export/unpackXlsxFileNode.test.js.map +1 -0
- package/commonjs/export/unpackXlsxFileUniversal.js +14 -3
- package/commonjs/export/unpackXlsxFileUniversal.js.map +1 -1
- package/commonjs/export/unpackXlsxFileUniversal.test.js.map +1 -0
- package/commonjs/parseSheetData/parseSheetData.js +9 -6
- package/commonjs/parseSheetData/parseSheetData.js.map +1 -1
- package/commonjs/utility/convertValuesFromUint8ArraysToStrings.js +100 -0
- package/commonjs/utility/convertValuesFromUint8ArraysToStrings.js.map +1 -0
- package/commonjs/xlsx/InvalidSpreadsheetError.js +55 -0
- package/commonjs/xlsx/InvalidSpreadsheetError.js.map +1 -0
- package/commonjs/xlsx/SheetNotFoundError.js +55 -0
- package/commonjs/xlsx/SheetNotFoundError.js.map +1 -0
- package/commonjs/xlsx/file/InputValidationStream.js +101 -0
- package/commonjs/xlsx/file/InputValidationStream.js.map +1 -0
- package/commonjs/xlsx/file/InputValidationStream.test.js.map +1 -0
- package/commonjs/xlsx/file/InvalidInputError.js +105 -0
- package/commonjs/xlsx/file/InvalidInputError.js.map +1 -0
- package/commonjs/xlsx/file/createFileTypeDetector.js +70 -0
- package/commonjs/xlsx/file/createFileTypeDetector.js.map +1 -0
- package/commonjs/xlsx/file/createFileTypeDetector.test.js.map +1 -0
- package/commonjs/xlsx/file/validateLeadingBytes.js +47 -0
- package/commonjs/xlsx/file/validateLeadingBytes.js.map +1 -0
- package/commonjs/xlsx/file/validateLeadingBytes.test.js.map +1 -0
- package/commonjs/xlsx/isDateFormat.js +32 -27
- package/commonjs/xlsx/isDateFormat.js.map +1 -1
- package/commonjs/xlsx/isDateFormatStyle.js +19 -21
- package/commonjs/xlsx/isDateFormatStyle.js.map +1 -1
- package/commonjs/xlsx/parseCell.js +252 -115
- package/commonjs/xlsx/parseCell.js.map +1 -1
- package/commonjs/xlsx/parseCellAddress.js +22 -18
- package/commonjs/xlsx/parseCellAddress.js.map +1 -1
- package/commonjs/xlsx/parseExcelDate.js +4 -124
- package/commonjs/xlsx/parseExcelDate.js.map +1 -1
- package/commonjs/xlsx/parseExcelDate.test.js.map +1 -1
- package/commonjs/xlsx/parseExcelTimestamp.js +139 -0
- package/commonjs/xlsx/parseExcelTimestamp.js.map +1 -0
- package/commonjs/xlsx/parseFilePaths.js +48 -47
- package/commonjs/xlsx/parseFilePaths.js.map +1 -1
- package/commonjs/xlsx/parseSharedStrings.js +91 -36
- package/commonjs/xlsx/parseSharedStrings.js.map +1 -1
- package/commonjs/xlsx/parseSheet.js +527 -69
- package/commonjs/xlsx/parseSheet.js.map +1 -1
- package/commonjs/xlsx/parseSpreadsheetContents.js +154 -83
- package/commonjs/xlsx/parseSpreadsheetContents.js.map +1 -1
- package/commonjs/xlsx/parseSpreadsheetInfo.js +60 -59
- package/commonjs/xlsx/parseSpreadsheetInfo.js.map +1 -1
- package/commonjs/xlsx/parseStyles.js +75 -75
- package/commonjs/xlsx/parseStyles.js.map +1 -1
- package/commonjs/xml/parseXml.js +112 -0
- package/commonjs/xml/parseXml.js.map +1 -0
- package/commonjs/xml/parseXml.test.js.map +1 -0
- package/commonjs/xml/parseXmlStream.js.map +1 -1
- package/commonjs/xml/parseXmlStream.sax.js +69 -28
- package/commonjs/xml/parseXmlStream.sax.js.map +1 -1
- package/commonjs/xml/parseXmlStream.saxen.js +66 -40
- package/commonjs/xml/parseXmlStream.saxen.js.map +1 -1
- package/commonjs/zip/UnzipError.js +55 -0
- package/commonjs/zip/UnzipError.js.map +1 -0
- package/commonjs/zip/unzipFromArrayBuffer.js +21 -1
- package/commonjs/zip/unzipFromArrayBuffer.js.map +1 -1
- package/commonjs/zip/unzipFromArrayBuffer.test.js.map +1 -0
- package/commonjs/zip/unzipFromStream.fflate.js +43 -35
- package/commonjs/zip/unzipFromStream.fflate.js.map +1 -1
- package/commonjs/zip/unzipFromStream.js +188 -6
- package/commonjs/zip/unzipFromStream.js.map +1 -1
- package/commonjs/zip/unzipFromStream.unzipper.js +19 -34
- package/commonjs/zip/unzipFromStream.unzipper.js.map +1 -1
- package/modules/export/convertInputToNodeStream.js +0 -12
- package/modules/export/convertInputToNodeStream.js.map +1 -1
- package/modules/export/parseSheet.js +13 -6
- package/modules/export/parseSheet.js.map +1 -1
- package/modules/export/readSheetBrowser.js +3 -5
- package/modules/export/readSheetBrowser.js.map +1 -1
- package/modules/export/readSheetNode.js +3 -5
- package/modules/export/readSheetNode.js.map +1 -1
- package/modules/export/readSheetUniversal.js +2 -2
- package/modules/export/readSheetUniversal.js.map +1 -1
- package/modules/export/readSheetWebWorker.js +7 -8
- package/modules/export/readSheetWebWorker.js.map +1 -1
- package/modules/export/readXlsxFileBrowser.js +3 -5
- package/modules/export/readXlsxFileBrowser.js.map +1 -1
- package/modules/export/readXlsxFileNode.js +3 -5
- package/modules/export/readXlsxFileNode.js.map +1 -1
- package/modules/export/readXlsxFileUniversal.js +2 -2
- package/modules/export/readXlsxFileUniversal.js.map +1 -1
- package/modules/export/readXlsxFileWebWorker.js +7 -8
- package/modules/export/readXlsxFileWebWorker.js.map +1 -1
- package/modules/export/unpackXlsxFileBrowser.js +15 -4
- package/modules/export/unpackXlsxFileBrowser.js.map +1 -1
- package/modules/export/unpackXlsxFileBrowser.test.js.map +1 -0
- package/modules/export/unpackXlsxFileNode.js +32 -5
- package/modules/export/unpackXlsxFileNode.js.map +1 -1
- package/modules/export/unpackXlsxFileNode.test.js.map +1 -0
- package/modules/export/unpackXlsxFileUniversal.js +14 -3
- package/modules/export/unpackXlsxFileUniversal.js.map +1 -1
- package/modules/export/unpackXlsxFileUniversal.test.js.map +1 -0
- package/modules/parseSheetData/parseSheetData.js +9 -6
- package/modules/parseSheetData/parseSheetData.js.map +1 -1
- package/modules/utility/convertValuesFromUint8ArraysToStrings.js +92 -0
- package/modules/utility/convertValuesFromUint8ArraysToStrings.js.map +1 -0
- package/modules/xlsx/InvalidSpreadsheetError.js +50 -0
- package/modules/xlsx/InvalidSpreadsheetError.js.map +1 -0
- package/modules/xlsx/SheetNotFoundError.js +50 -0
- package/modules/xlsx/SheetNotFoundError.js.map +1 -0
- package/modules/xlsx/file/InputValidationStream.js +96 -0
- package/modules/xlsx/file/InputValidationStream.js.map +1 -0
- package/modules/xlsx/file/InputValidationStream.test.js.map +1 -0
- package/modules/xlsx/file/InvalidInputError.js +100 -0
- package/modules/xlsx/file/InvalidInputError.js.map +1 -0
- package/modules/xlsx/file/createFileTypeDetector.js +63 -0
- package/modules/xlsx/file/createFileTypeDetector.js.map +1 -0
- package/modules/xlsx/file/createFileTypeDetector.test.js.map +1 -0
- package/modules/xlsx/file/validateLeadingBytes.js +37 -0
- package/modules/xlsx/file/validateLeadingBytes.js.map +1 -0
- package/modules/xlsx/file/validateLeadingBytes.test.js.map +1 -0
- package/modules/xlsx/isDateFormat.js +31 -27
- package/modules/xlsx/isDateFormat.js.map +1 -1
- package/modules/xlsx/isDateFormatStyle.js +18 -21
- package/modules/xlsx/isDateFormatStyle.js.map +1 -1
- package/modules/xlsx/parseCell.js +251 -111
- package/modules/xlsx/parseCell.js.map +1 -1
- package/modules/xlsx/parseCellAddress.js +21 -18
- package/modules/xlsx/parseCellAddress.js.map +1 -1
- package/modules/xlsx/parseExcelDate.js +4 -124
- package/modules/xlsx/parseExcelDate.js.map +1 -1
- package/modules/xlsx/parseExcelDate.test.js.map +1 -1
- package/modules/xlsx/parseExcelTimestamp.js +133 -0
- package/modules/xlsx/parseExcelTimestamp.js.map +1 -0
- package/modules/xlsx/parseFilePaths.js +48 -47
- package/modules/xlsx/parseFilePaths.js.map +1 -1
- package/modules/xlsx/parseSharedStrings.js +91 -37
- package/modules/xlsx/parseSharedStrings.js.map +1 -1
- package/modules/xlsx/parseSheet.js +526 -68
- package/modules/xlsx/parseSheet.js.map +1 -1
- package/modules/xlsx/parseSpreadsheetContents.js +153 -81
- package/modules/xlsx/parseSpreadsheetContents.js.map +1 -1
- package/modules/xlsx/parseSpreadsheetInfo.js +60 -59
- package/modules/xlsx/parseSpreadsheetInfo.js.map +1 -1
- package/modules/xlsx/parseStyles.js +75 -75
- package/modules/xlsx/parseStyles.js.map +1 -1
- package/modules/xml/parseXml.js +106 -0
- package/modules/xml/parseXml.js.map +1 -0
- package/modules/xml/parseXml.test.js.map +1 -0
- package/modules/xml/parseXmlStream.js +2 -0
- package/modules/xml/parseXmlStream.js.map +1 -1
- package/modules/xml/parseXmlStream.sax.js +69 -28
- package/modules/xml/parseXmlStream.sax.js.map +1 -1
- package/modules/xml/parseXmlStream.saxen.js +67 -40
- package/modules/xml/parseXmlStream.saxen.js.map +1 -1
- package/modules/zip/UnzipError.js +49 -0
- package/modules/zip/UnzipError.js.map +1 -0
- package/modules/zip/unzipFromArrayBuffer.js +21 -1
- package/modules/zip/unzipFromArrayBuffer.js.map +1 -1
- package/modules/zip/unzipFromArrayBuffer.test.js.map +1 -0
- package/modules/zip/unzipFromStream.fflate.js +41 -35
- package/modules/zip/unzipFromStream.fflate.js.map +1 -1
- package/modules/zip/unzipFromStream.js +124 -1
- package/modules/zip/unzipFromStream.js.map +1 -1
- package/modules/zip/unzipFromStream.unzipper.js +19 -35
- package/modules/zip/unzipFromStream.unzipper.js.map +1 -1
- package/node/index.cjs +3 -0
- package/node/index.d.ts +16 -0
- package/node/index.js +3 -0
- package/package.json +5 -3
- package/types/InvalidInputError.d.ts +16 -0
- package/types/InvalidSpreadsheetError.d.ts +4 -0
- package/types/SheetNotFoundError.d.ts +4 -0
- package/universal/index.cjs +3 -0
- package/universal/index.d.ts +16 -0
- package/universal/index.js +3 -0
- package/web-worker/index.cjs +3 -0
- package/web-worker/index.d.ts +16 -0
- package/web-worker/index.js +3 -0
- package/commonjs/export/convertValuesFromUint8ArraysToStrings.js +0 -23
- package/commonjs/export/convertValuesFromUint8ArraysToStrings.js.map +0 -1
- package/commonjs/xlsx/convertCellsToData2dArray.js +0 -84
- package/commonjs/xlsx/convertCellsToData2dArray.js.map +0 -1
- package/commonjs/xlsx/dropEmptyColumns.js +0 -40
- package/commonjs/xlsx/dropEmptyColumns.js.map +0 -1
- package/commonjs/xlsx/dropEmptyColumns.test.js.map +0 -1
- package/commonjs/xlsx/dropEmptyRows.js +0 -43
- package/commonjs/xlsx/dropEmptyRows.js.map +0 -1
- package/commonjs/xlsx/dropEmptyRows.test.js.map +0 -1
- package/commonjs/xlsx/parseCellValue.js +0 -189
- package/commonjs/xlsx/parseCellValue.js.map +0 -1
- package/commonjs/xlsx/parseNumber.js +0 -20
- package/commonjs/xlsx/parseNumber.js.map +0 -1
- package/commonjs/xlsx/parseSharedString.js +0 -64
- package/commonjs/xlsx/parseSharedString.js.map +0 -1
- package/commonjs/xlsx/parseSheetData.js +0 -68
- package/commonjs/xlsx/parseSheetData.js.map +0 -1
- package/commonjs/xlsx/reconstructSheetDimensionsFromSheetCells.js +0 -29
- package/commonjs/xlsx/reconstructSheetDimensionsFromSheetCells.js.map +0 -1
- package/commonjs/xml/parseXmlStream.saxen.code.js +0 -953
- package/commonjs/xml/parseXmlStream.saxen.code.js.map +0 -1
- package/commonjs/xml/parseXmlStream.test.js.map +0 -1
- package/modules/export/convertValuesFromUint8ArraysToStrings.js +0 -17
- package/modules/export/convertValuesFromUint8ArraysToStrings.js.map +0 -1
- package/modules/xlsx/convertCellsToData2dArray.js +0 -77
- package/modules/xlsx/convertCellsToData2dArray.js.map +0 -1
- package/modules/xlsx/dropEmptyColumns.js +0 -34
- package/modules/xlsx/dropEmptyColumns.js.map +0 -1
- package/modules/xlsx/dropEmptyColumns.test.js.map +0 -1
- package/modules/xlsx/dropEmptyRows.js +0 -37
- package/modules/xlsx/dropEmptyRows.js.map +0 -1
- package/modules/xlsx/dropEmptyRows.test.js.map +0 -1
- package/modules/xlsx/parseCellValue.js +0 -183
- package/modules/xlsx/parseCellValue.js.map +0 -1
- package/modules/xlsx/parseNumber.js +0 -14
- package/modules/xlsx/parseNumber.js.map +0 -1
- package/modules/xlsx/parseSharedString.js +0 -55
- package/modules/xlsx/parseSharedString.js.map +0 -1
- package/modules/xlsx/parseSheetData.js +0 -55
- package/modules/xlsx/parseSheetData.js.map +0 -1
- package/modules/xlsx/reconstructSheetDimensionsFromSheetCells.js +0 -23
- package/modules/xlsx/reconstructSheetDimensionsFromSheetCells.js.map +0 -1
- package/modules/xml/parseXmlStream.saxen.code.js +0 -947
- package/modules/xml/parseXmlStream.saxen.code.js.map +0 -1
- package/modules/xml/parseXmlStream.test.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unzipFromStream.js","names":["_unzipFromStreamUnzipper","_interopRequireDefault","require","obj","__esModule"],"sources":["../../source/zip/unzipFromStream.js"],"sourcesContent":["// `unzipFromStream` function reads `.zip` archive data from a Node.js stream.\r\n//\r\n// Even though it receives a Node.js stream as an input, it doesn't return the results\r\n// as a Node.js output stream (with `objectMode: true` setting). The reason is that\r\n// the result of this function is then passed to the XML parser which currently\r\n// doesn't support consuming a Node.js stream and instead consumes the entire XML document\r\n// as a single string. This means that implementing streaming output in this function\r\n// wouldn't result in any performance improvements, so currently it simply returns\r\n// a \"map\" of all files in the input `.zip` archive, and that seems to be enough.\r\n//\r\n// Currently, there're two decompressor implementations:\r\n// * `fflate` — a pure-javascript implementation that uses `fflate` package.\r\n// * `unzipper` — a \"native\" Node.js module that uses Node's `zlib` which is written in C.\r\n//\r\n// The implementations are compared in a benchmark:\r\n//\r\n// ```\r\n// npm run test:benchmark:unzipFromStream\r\n// ```\r\n//\r\n// The benchmark tells that `unzipper` is 2x faster than `fflate` with the default `ZipInflate` decompressor.\r\n//\r\n// However, when swapping `fflate`'s default `ZipInflate` decompressor with a custom\r\n// \"native\" `zlib` one, `fflate` happens to be about 20% faster than `unzipper`.\r\n//\r\n// Still, when measuring the total time of parsing `.xlsx` files,\r\n// the time difference becomes unmeasurable between `unzipper`\r\n// and `fflate` with \"native\" `zlib` decompressor,\r\n// as could be seen by running `npm run test:benchmark` command\r\n// where `fflate` is slightly faster than `unzipper`.\r\n//\r\n// * When decompressing a `1 MB` `.xlsx` file, the decompression time is `90 ms`\r\n// when using `fflate` with `zlib` decompressor and `100 ms` when using `unzipper` decompressor.\r\n// * When decompressing a `10 MB` `.xlsx` file, the decompression time is `530 ms`\r\n// when using `fflate` with `zlib` decompressor and `550 ms` when using `unzipper` decompressor.\r\n// * When decompressing a `50 MB` `.xlsx` file, the decompression time is `2800 ms`\r\n// when using `fflate` with `zlib` decompressor and `3000 ms` when using `unzipper` decompressor.\r\n//\r\n// So, at the end of the day, there's no substantial difference between the two\r\n// when it comes to parsing `.xlsx` files, and one may choose depending on personal preference.\r\n//\r\n// And my personal preference leans towards `unzipper` because:\r\n//\r\n// * I personally refactored it into `unzipper-esm` in about 5-6 hours.\r\n// https://github.com/ZJONSSON/node-unzipper/pull/356\r\n//\r\n// * It is designed as a Node.js-first module, i.e. it is designed around the concept\r\n// of Node.js streams \"from the ground up\". Meanwhile, `fflate` is a \"universal\" module\r\n// and it does not implement Node.js streams \"contract\", i.e. it just unzips the archive\r\n// as fast as it can consume it from the input stream, without throttling the data throughput\r\n// in cases when the input data flows faster than `fflate` can process it. This means that\r\n// in the \"worst case\" scenario when `fflate`'s decompressor is unable to keep up with the\r\n// data influx, it would \"buffer\" the entire `.zip` archive in RAM until it's processed.\r\n// And while this is no big deal by any means, it's still not as elegant as adhering to\r\n// Node.js streaming protocol.\r\n//\r\n// * `unzipper` uses native `zlib` decompressor which `fflate` doesn't officially include\r\n// and it had to be hacked into it using a couple of tricks. That's also no big deal,\r\n// but still a slightly weird experience.\r\n//\r\n// * Rumors are circulating that `fflate`'s \"streaming\" `Zip`/`Unzip` classes have a few\r\n// implementation issues when compared to non-\"streaming\" `zipSync`/`unzipSync`/`zip`/`unzip` functions.\r\n// Some people even suggested in the comments that `Zip`/`Unzip` classes are not really production-ready\r\n// when compared to `zipSync`/`unzipSync`/`zip`/`unzip` functions.\r\n// https://github.com/101arrowz/fflate/issues/282\r\n//\r\nexport { default as default } from './unzipFromStream.unzipper.js'"],"mappings":";;;;;;;;;;;AAkEA,IAAAA,wBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAkE,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA"}
|
|
1
|
+
{"version":3,"file":"unzipFromStream.js","names":["_unzipFromStreamUnzipper","_interopRequireDefault","require","obj","__esModule","_createForOfIteratorHelperLoose","o","allowArrayLike","it","Symbol","iterator","call","next","bind","Array","isArray","_unsupportedIterableToArray","length","i","done","value","TypeError","minLen","_arrayLikeToArray","n","Object","prototype","toString","slice","constructor","name","from","test","arr","len","arr2","unzipFromStream","stream","_ref","arguments","undefined","filter","files","filesData","onFile","filePath","fileSize","path","size","chunks","buffer","Buffer","alloc","position","onFileData","chunk","push","copy","onFileDataEnd","concatChunksToNonPooledBuffer","unzipFromStream_","then","totalLength","reduce","sum","allocUnsafeSlow","offset","_iterator","_step"],"sources":["../../source/zip/unzipFromStream.js"],"sourcesContent":["// `unzipFromStream` function reads `.zip` archive data from a Node.js stream.\r\n//\r\n// Even though it receives a Node.js stream as an input, it doesn't return the results\r\n// as a Node.js output stream (with `objectMode: true` setting). The reason is that\r\n// the result of this function is then passed to the XML parser which currently\r\n// doesn't support consuming a Node.js stream and instead consumes the entire XML document\r\n// as a single string. This means that implementing streaming output in this function\r\n// wouldn't result in any performance improvements, so currently it simply returns\r\n// a \"map\" of all files in the input `.zip` archive, and that seems to be enough.\r\n//\r\n// Currently, there're two decompressor implementations:\r\n// * `fflate` — a pure-javascript implementation that uses `fflate` package.\r\n// * `unzipper` — a \"native\" Node.js module that uses Node's `zlib` which is written in C.\r\n//\r\n// The implementations are compared in a benchmark:\r\n//\r\n// ```\r\n// npm run test:benchmark:unzipFromStream\r\n// ```\r\n//\r\n// The benchmark tells that `unzipper` is 2x faster than `fflate` with the default `ZipInflate` decompressor.\r\n//\r\n// However, when swapping `fflate`'s default `ZipInflate` decompressor with a custom\r\n// \"native\" `zlib` one, `fflate` happens to be about 20% faster than `unzipper`.\r\n//\r\n// Still, when measuring the total time of parsing `.xlsx` files,\r\n// the time difference becomes unmeasurable between `unzipper`\r\n// and `fflate` with \"native\" `zlib` decompressor,\r\n// as could be seen by running `npm run test:benchmark` command\r\n// where `fflate` is slightly faster than `unzipper`.\r\n//\r\n// * When decompressing a `1 MB` `.xlsx` file, the decompression time is `90 ms`\r\n// when using `fflate` with `zlib` decompressor and `100 ms` when using `unzipper` decompressor.\r\n// * When decompressing a `10 MB` `.xlsx` file, the decompression time is `530 ms`\r\n// when using `fflate` with `zlib` decompressor and `550 ms` when using `unzipper` decompressor.\r\n// * When decompressing a `50 MB` `.xlsx` file, the decompression time is `2800 ms`\r\n// when using `fflate` with `zlib` decompressor and `3000 ms` when using `unzipper` decompressor.\r\n//\r\n// So, at the end of the day, there's no substantial difference between the two\r\n// when it comes to parsing `.xlsx` files, and one may choose depending on personal preference.\r\n//\r\n// And my personal preference leans towards `unzipper` because:\r\n//\r\n// * I personally refactored it into `unzipper-esm` in about 5-6 hours.\r\n// https://github.com/ZJONSSON/node-unzipper/pull/356\r\n//\r\n// * It is designed as a Node.js-first module, i.e. it is designed around the concept\r\n// of Node.js streams \"from the ground up\". Meanwhile, `fflate` is a \"universal\" module\r\n// and it does not implement Node.js streams \"contract\", i.e. it just unzips the archive\r\n// as fast as it can consume it from the input stream, without throttling the data throughput\r\n// in cases when the input data flows faster than `fflate` can process it. This means that\r\n// in the \"worst case\" scenario when `fflate`'s decompressor is unable to keep up with the\r\n// data influx, it would \"buffer\" the entire `.zip` archive in RAM until it's processed.\r\n// And while this is no big deal by any means, it's still not as elegant as adhering to\r\n// Node.js streaming protocol.\r\n//\r\n// * `unzipper` uses native `zlib` decompressor which `fflate` doesn't officially include\r\n// and it had to be hacked into it using a couple of tricks. That's also no big deal,\r\n// but still a slightly weird experience.\r\n//\r\n// * Rumors are circulating that `fflate`'s \"streaming\" `Zip`/`Unzip` classes have a few\r\n// implementation issues when compared to non-\"streaming\" `zipSync`/`unzipSync`/`zip`/`unzip` functions.\r\n// Some people even suggested in the comments that `Zip`/`Unzip` classes are not really production-ready\r\n// when compared to `zipSync`/`unzipSync`/`zip`/`unzip` functions.\r\n// https://github.com/101arrowz/fflate/issues/282\r\n//\r\nimport unzipFromStream_ from './unzipFromStream.unzipper.js'\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 filesData = {}\r\n\r\n\t// `fileSize` is optional and will not be present for `.zip` archives\r\n\t// that were created in a streaming fashion.\r\n\tconst onFile = (filePath, fileSize) => {\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\t// filesData[filePath] = []\r\n\t\tfilesData[filePath] = {\r\n\t\t\tsize: fileSize,\r\n\t\t\tchunks: [],\r\n\t\t\tbuffer: fileSize === undefined ? undefined : Buffer.alloc(fileSize),\r\n\t\t\tposition: 0\r\n\t\t}\r\n\t}\r\n\r\n\tconst onFileData = (filePath, chunk) => {\r\n\t\t// filesData[filePath].push(chunk)\r\n\t\tif (filesData[filePath].size === undefined) {\r\n\t\t\tfilesData[filePath].chunks.push(chunk)\r\n\t\t} else {\r\n\t\t\tfilesData[filePath].position += chunk.copy(filesData[filePath].buffer, filesData[filePath].position)\r\n\t\t}\r\n\t}\r\n\r\n\tconst onFileDataEnd = (filePath) => {\r\n\t\tif (filesData[filePath].size === undefined) {\r\n\t\t\t// // `Buffer.concat()` will produce a pooled buffer if it's <= 4KB.\r\n\t\t\t// let buffer = Buffer.concat(filesData[filePath].chunks)\r\n\t\t\t// if (isBufferPooled(buffer)) {\r\n\t\t\t// \t// Here it uses `Buffer.allocUnsafeSlow()` instead of the regular `Buffer.alloc()`.\r\n\t\t\t// \t// The reason is that `Buffer.allocUnsafeSlow()` doesn't bother resetting the memory\r\n\t\t\t// \t// that is being allocated, which is fine because it will be overwritten anyway.\r\n\t\t\t// \t// It could also have used `Buffer.allocUnsafe()` if it wasn't returning pooled buffers,\r\n\t\t\t// \t// which is what is being avoided here in the first place.\r\n\t\t\t// \tconst pooledBuffer = buffer\r\n\t\t\t// \tbuffer = Buffer.allocUnsafeSlow(buffer.byteLength)\r\n\t\t\t// \tpooledBuffer.copy(buffer)\r\n\t\t\t// }\r\n\t\t\t// files[filePath] = buffer\r\n\t\t\tfiles[filePath] = concatChunksToNonPooledBuffer(filesData[filePath].chunks)\r\n\t\t} else {\r\n\t\t\tfiles[filePath] = filesData[filePath].buffer\r\n\t\t}\r\n\t\tdelete filesData[filePath]\r\n\t}\r\n\r\n\treturn unzipFromStream_(stream, onFile, onFileData, onFileDataEnd)\r\n\t\t.then(() => files)\r\n}\r\n\r\n// // Node.js allocates small buffers (<= 4KB) in a shared 8KB pool.\r\n// // This interferes with passing such buffers to another worker thread.\r\n// // In order for a buffer to be transferrable to another worker thread,\r\n// // it has to be non-pooled.\r\n// function isBufferPooled(buffer) {\r\n// \t// If it doesn't utilize the full underlying `ArrayBuffer`, it's sliced out of a pool.\r\n// \tif (buffer.byteOffset > 0) {\r\n// \t\treturn true\r\n// \t}\r\n//\r\n// \t// If it starts at `0`, but the underlying allocation is larger than the buffer itself, it's pooled/\r\n// \tif (buffer.buffer.byteLength > buffer.byteLength) {\r\n// \t\treturn true\r\n// \t}\r\n//\r\n// \treturn false\r\n// }\r\n\r\n// Concatenates chunks into a non-\"pooled\" buffer.\r\n//\r\n// It could've simply used `Buffer.concat(chunks)` to concatenate chunks into a buffer.\r\n// But, while using `Buffer.concat()` is simple, it results in a Node.js optimization\r\n// when it uses a \"shared\" memory region of about `8KB` to co-locate this array buffer\r\n// with other small array buffers if this array buffer is small too (i.e. <= `4KB`).\r\n//\r\n// Such co-location results in the inability to \"transfer\" this buffer\r\n// to a worker thread.\r\n//\r\n// A workaround is to manually allocate a separate memory region of a certain size.\r\n// This way, the resulting buffer will be non-\"pooled\".\r\n//\r\nfunction concatChunksToNonPooledBuffer(chunks) {\r\n\t// Calculate the total byte length of all the chunks combined.\r\n\tconst totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0)\r\n\r\n\t// Allocate a non-pooled buffer.\r\n\t// Here it uses `Buffer.allocUnsafeSlow()` instead of the regular `Buffer.alloc()`.\r\n\t// The reason is that `Buffer.allocUnsafeSlow()` doesn't bother resetting the memory\r\n\t// that is being allocated, which is fine because it will be overwritten anyway.\r\n\t// It could also have used `Buffer.allocUnsafe()` if it wasn't returning pooled buffers,\r\n\t// which is what is being avoided here in the first place.\r\n\tconst buffer = Buffer.allocUnsafeSlow(totalLength)\r\n\r\n\t// Manually copy each chunk into the buffer.\r\n\tlet offset = 0\r\n\tfor (const chunk of chunks) {\r\n\t\tchunk.copy(buffer, offset)\r\n\t\toffset += chunk.length\r\n\t}\r\n\r\n\treturn buffer\r\n}"],"mappings":"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"}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports["default"] =
|
|
6
|
+
exports["default"] = unzipFromStream_;
|
|
7
7
|
var _unzipperEsm = require("unzipper-esm");
|
|
8
|
-
var
|
|
8
|
+
var _UnzipError = require("./UnzipError.js");
|
|
9
9
|
// Considerations:
|
|
10
10
|
//
|
|
11
11
|
// * `unzipper` unpacks a `.zip` file using Node.js's "native" `zlib` module.
|
|
@@ -17,52 +17,31 @@ var _buffer = require("buffer");
|
|
|
17
17
|
// * `unzipper` can completely skip a given compressed file entry if it's of no interest.
|
|
18
18
|
// This means that a `.zip` archive could be read in multiple passes without performance penalty.
|
|
19
19
|
|
|
20
|
+
var PROMISE_RESOLVE_VALUE = undefined;
|
|
21
|
+
|
|
20
22
|
/**
|
|
21
23
|
* Reads `*.zip` file contents.
|
|
22
24
|
* @param {Stream} stream
|
|
23
|
-
* @
|
|
25
|
+
* @param {function} onFile
|
|
26
|
+
* @param {function} onFileData
|
|
27
|
+
* @param {function} onFileDataEnd
|
|
28
|
+
* @return {Promise<void>}
|
|
24
29
|
*/
|
|
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
30
|
function unzipFromStream_(stream, onFile, onFileData, onFileDataEnd) {
|
|
55
31
|
return new Promise(function (resolve, reject) {
|
|
56
32
|
var promises = [];
|
|
57
33
|
var errored = false;
|
|
58
34
|
var onError = function onError(error) {
|
|
35
|
+
if (error instanceof _unzipperEsm.ZipFileError) {
|
|
36
|
+
error = (0, _UnzipError.createUnzipError)(error);
|
|
37
|
+
}
|
|
59
38
|
if (!errored) {
|
|
60
39
|
errored = true;
|
|
61
40
|
reject(error);
|
|
62
41
|
}
|
|
63
42
|
};
|
|
64
43
|
stream
|
|
65
|
-
// This first "error" listener catches the
|
|
44
|
+
// This first "error" listener catches errors emitted from the input stream (for example, a file read error).
|
|
66
45
|
//
|
|
67
46
|
// That's because the .pipe() method does not automatically propagate errors
|
|
68
47
|
// from a source (input) stream to the destination stream or the end of the pipeline.
|
|
@@ -106,7 +85,13 @@ function unzipFromStream_(stream, onFile, onFileData, onFileDataEnd) {
|
|
|
106
85
|
if (errored) {
|
|
107
86
|
ignore = true;
|
|
108
87
|
}
|
|
109
|
-
|
|
88
|
+
// `entry.vars.uncompressedSize` will be `0` for `.zip` archives
|
|
89
|
+
// that were created in a streaming fashion.
|
|
90
|
+
// The `const fileSizeKnown = ...` code was copy-pasted from `node-unzipper` source code:
|
|
91
|
+
// https://github.com/ZJONSSON/node-unzipper/blob/master/lib/Open/unzip.js
|
|
92
|
+
var uncompressedFileSizeIsKnown = !(entry.vars.flags & 0x08) || entry.vars.compressedSize > 0;
|
|
93
|
+
var uncompressedFileSize = uncompressedFileSizeIsKnown ? entry.vars.uncompressedSize : undefined;
|
|
94
|
+
if (onFile(entry.path, uncompressedFileSize) === false) {
|
|
110
95
|
ignore = true;
|
|
111
96
|
}
|
|
112
97
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unzipFromStream.unzipper.js","names":["_unzipperEsm","require","
|
|
1
|
+
{"version":3,"file":"unzipFromStream.unzipper.js","names":["_unzipperEsm","require","_UnzipError","PROMISE_RESOLVE_VALUE","undefined","unzipFromStream_","stream","onFile","onFileData","onFileDataEnd","Promise","resolve","reject","promises","errored","onError","error","ZipFileError","createUnzipError","on","pipe","Parse","all","then","entry","ignore","type","uncompressedFileSizeIsKnown","vars","flags","compressedSize","uncompressedFileSize","uncompressedSize","path","autodrain","push","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, ZipFileError } from 'unzipper-esm'\r\n\r\nimport { createUnzipError } from './UnzipError.js'\r\n\r\nconst PROMISE_RESOLVE_VALUE = undefined\r\n\r\n/**\r\n * Reads `*.zip` file contents.\r\n * @param {Stream} stream\r\n * @param {function} onFile\r\n * @param {function} onFileData\r\n * @param {function} onFileDataEnd\r\n * @return {Promise<void>}\r\n */\r\nexport default function 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 (error instanceof ZipFileError) {\r\n\t\t\t\terror = createUnzipError(error)\r\n\t\t\t}\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 errors emitted from the input stream (for example, a file read error).\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\t// `entry.vars.uncompressedSize` will be `0` for `.zip` archives\r\n\t\t\t\t// that were created in a streaming fashion.\r\n\t\t\t\t// The `const fileSizeKnown = ...` code was copy-pasted from `node-unzipper` source code:\r\n\t\t\t\t// https://github.com/ZJONSSON/node-unzipper/blob/master/lib/Open/unzip.js\r\n\t\t\t\tconst uncompressedFileSizeIsKnown = !(entry.vars.flags & 0x08) || entry.vars.compressedSize > 0\r\n\t\t\t\tconst uncompressedFileSize = uncompressedFileSizeIsKnown ? entry.vars.uncompressedSize : undefined\r\n\t\t\t\tif (onFile(entry.path, uncompressedFileSize) === 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":";;;;;;AAWA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,IAAME,qBAAqB,GAAGC,SAAS;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,gBAAgBA,CAACC,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,aAAa,EAAE;EACnF,OAAO,IAAIC,OAAO,CAAC,UAACC,OAAO,EAAEC,MAAM,EAAK;IACvC,IAAMC,QAAQ,GAAG,EAAE;IAEnB,IAAIC,OAAO,GAAG,KAAK;IAEnB,IAAMC,OAAO,GAAG,SAAVA,OAAOA,CAAIC,KAAK,EAAK;MAC1B,IAAIA,KAAK,YAAYC,yBAAY,EAAE;QAClCD,KAAK,GAAG,IAAAE,4BAAgB,EAACF,KAAK,CAAC;MAChC;MACA,IAAI,CAACF,OAAO,EAAE;QACbA,OAAO,GAAG,IAAI;QACdF,MAAM,CAACI,KAAK,CAAC;MACd;IACD,CAAC;IAEDV;IACC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAAA,CACCa,EAAE,CAAC,OAAO,EAAEJ,OAAO;IACpB;IAAA,CACCK,IAAI,CAAC,IAAAC,kBAAK,EAAC,CAAC;IACb;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAAA,CACCF,EAAE,CAAC,OAAO,EAAEJ,OAAO;IACpB;IAAA,CACCI,EAAE,CAAC,QAAQ,EAAE,YAAM;MACnB,IAAI,CAACL,OAAO,EAAE;QACb;QACA;QACA;QACA;QACAJ,OAAO,CAACY,GAAG,CAACT,QAAQ,CAAC,CAACU,IAAI,CAAC,YAAM;UAChCZ,OAAO,CAACR,qBAAqB,CAAC;QAC/B,CAAC,EAAEY,OAAO,CAAC;MACZ;IACD,CAAC,CAAC,CACDI,EAAE,CAAC,OAAO,EAAE,UAACK,KAAK,EAAK;MACvB;MACA,IAAIC,MAAM,GAAG,KAAK;MAClB;MACA;MACA,IAAID,KAAK,CAACE,IAAI,KAAK,WAAW,EAAE;QAC/BD,MAAM,GAAG,IAAI;MACd;MACA,IAAIX,OAAO,EAAE;QACZW,MAAM,GAAG,IAAI;MACd;MACA;MACA;MACA;MACA;MACA,IAAME,2BAA2B,GAAG,EAAEH,KAAK,CAACI,IAAI,CAACC,KAAK,GAAG,IAAI,CAAC,IAAIL,KAAK,CAACI,IAAI,CAACE,cAAc,GAAG,CAAC;MAC/F,IAAMC,oBAAoB,GAAGJ,2BAA2B,GAAGH,KAAK,CAACI,IAAI,CAACI,gBAAgB,GAAG5B,SAAS;MAClG,IAAIG,MAAM,CAACiB,KAAK,CAACS,IAAI,EAAEF,oBAAoB,CAAC,KAAK,KAAK,EAAE;QACvDN,MAAM,GAAG,IAAI;MACd;;MAEA;MACA,IAAIA,MAAM,EAAE;QACX;QACA;QACA;QACAD,KAAK,CAACU,SAAS,CAAC,CAAC,CAACf,EAAE,CAAC,OAAO,EAAEJ,OAAO,CAAC;QACtC;MACD;MAEAF,QAAQ,CAACsB,IAAI,CAAC,IAAIzB,OAAO,CAAC,UAACC,OAAO,EAAK;QACtC;QACA;QACA;QACA;QACAa,KAAK,CACHL,EAAE,CAAC,MAAM,EAAE,UAACiB,IAAI,EAAK;UACrB5B,UAAU,CAACgB,KAAK,CAACS,IAAI,EAAEG,IAAI,CAAC;QAC7B,CAAC,CAAC,CACDjB,EAAE,CAAC,OAAO,EAAE,UAACH,KAAK,EAAK;UACvBD,OAAO,CAACC,KAAK,CAAC;QACf,CAAC,CAAC,CACDG,EAAE,CAAC,QAAQ,EAAE,YAAM;UACnBV,aAAa,CAACe,KAAK,CAACS,IAAI,CAAC;UACzBtB,OAAO,CAAC,CAAC;QACV,CAAC,CAAC;MACJ,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACH"}
|
|
@@ -13,23 +13,11 @@ export default function convertInputToNodeStream(input) {
|
|
|
13
13
|
|
|
14
14
|
// Creates a readable stream from a `Buffer`.
|
|
15
15
|
function createReadableStreamFromBuffer(buffer) {
|
|
16
|
-
// Node.js seems to have a bug in `Readable.from()` function:
|
|
17
|
-
// it doesn't correctly handle empty buffers, i.e. it doesn't return a correct stream.
|
|
18
|
-
// https://gitlab.com/catamphetamine/read-excel-file/-/issues/106
|
|
19
|
-
if (buffer.length === 0) {
|
|
20
|
-
throw new Error('No data');
|
|
21
|
-
}
|
|
22
16
|
return Readable.from(buffer);
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
// Creates a readable stream from a `Blob`.
|
|
26
20
|
function createReadableStreamFromBlob(blob) {
|
|
27
|
-
// I didn't test but I'd presume that Node.js would throw on an empty `Blob`
|
|
28
|
-
// same way it does on an empty `Buffer`.
|
|
29
|
-
// https://gitlab.com/catamphetamine/read-excel-file/-/issues/106
|
|
30
|
-
if (blob.size === 0) {
|
|
31
|
-
throw new Error('No data');
|
|
32
|
-
}
|
|
33
21
|
// Convert a web `ReadableStream` to a Node.js `Readable` `Stream`.
|
|
34
22
|
return Readable.fromWeb(blob.stream());
|
|
35
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertInputToNodeStream.js","names":["fs","Blob","Stream","Readable","convertInputToNodeStream","input","Buffer","createReadableStreamFromBuffer","createReadableStreamFromBlob","createReadStream","buffer","
|
|
1
|
+
{"version":3,"file":"convertInputToNodeStream.js","names":["fs","Blob","Stream","Readable","convertInputToNodeStream","input","Buffer","createReadableStreamFromBuffer","createReadableStreamFromBlob","createReadStream","buffer","from","blob","fromWeb","stream"],"sources":["../../source/export/convertInputToNodeStream.js"],"sourcesContent":["import fs from 'node:fs'\r\nimport { Blob } from 'node:buffer'\r\nimport Stream, { Readable } from 'node:stream'\r\n\r\n/**\r\n * Converts Node.js input argument to a stream.\r\n * @param {(string|Stream|Buffer|Blob)} input - A Node.js readable stream or a `Buffer` or a `Blob` or a path to a file.\r\n * @returns {Stream}\r\n */\r\nexport default function convertInputToNodeStream(input) {\r\n return input instanceof Stream\r\n ? input\r\n : (\r\n input instanceof Buffer\r\n ? createReadableStreamFromBuffer(input)\r\n : (\r\n input instanceof Blob\r\n ? createReadableStreamFromBlob(input)\r\n : fs.createReadStream(input)\r\n )\r\n )\r\n}\r\n\r\n// Creates a readable stream from a `Buffer`.\r\nfunction createReadableStreamFromBuffer(buffer) {\r\n return Readable.from(buffer)\r\n}\r\n\r\n// Creates a readable stream from a `Blob`.\r\nfunction createReadableStreamFromBlob(blob) {\r\n // Convert a web `ReadableStream` to a Node.js `Readable` `Stream`.\r\n return Readable.fromWeb(blob.stream())\r\n}"],"mappings":"AAAA,OAAOA,EAAE,MAAM,SAAS;AACxB,SAASC,IAAI,QAAQ,aAAa;AAClC,OAAOC,MAAM,IAAIC,QAAQ,QAAQ,aAAa;;AAE9C;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,wBAAwBA,CAACC,KAAK,EAAE;EACtD,OAAOA,KAAK,YAAYH,MAAM,GAC1BG,KAAK,GAELA,KAAK,YAAYC,MAAM,GACnBC,8BAA8B,CAACF,KAAK,CAAC,GAErCA,KAAK,YAAYJ,IAAI,GACjBO,4BAA4B,CAACH,KAAK,CAAC,GACnCL,EAAE,CAACS,gBAAgB,CAACJ,KAAK,CAElC;AACL;;AAEA;AACA,SAASE,8BAA8BA,CAACG,MAAM,EAAE;EAC9C,OAAOP,QAAQ,CAACQ,IAAI,CAACD,MAAM,CAAC;AAC9B;;AAEA;AACA,SAASF,4BAA4BA,CAACI,IAAI,EAAE;EAC1C;EACA,OAAOT,QAAQ,CAACU,OAAO,CAACD,IAAI,CAACE,MAAM,CAAC,CAAC,CAAC;AACxC"}
|
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["schema"];
|
|
2
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
6
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
7
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
7
10
|
import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
8
11
|
import parseSheetData from '../parseSheetData/parseSheetData.js';
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* 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
15
|
* @param {function} [createWorkerFunction] — Creates a worker function.
|
|
13
|
-
* @param {function}
|
|
14
|
-
* @param {Record<string,
|
|
16
|
+
* @param {function} parseXml — SAX XML parser.
|
|
17
|
+
* @param {Record<string,Uint8Array>} contents - A map of `.xml` files inside the `.xlsx` file (which itself is just a zipped directory).
|
|
15
18
|
* @param {string|number} [sheet] — Sheet name or number.
|
|
16
19
|
* @param {object} [options]
|
|
17
20
|
* @return {Promise<SheetData>}
|
|
18
21
|
*/
|
|
19
|
-
export default function parseSheet(createWorkerFunction,
|
|
20
|
-
|
|
22
|
+
export default function parseSheet(createWorkerFunction, parseXml, contents, sheet, optionsWithSchema) {
|
|
23
|
+
// `schema` has to be excluded from the `options`
|
|
24
|
+
var _ref = optionsWithSchema || {},
|
|
25
|
+
schema = _ref.schema,
|
|
26
|
+
options = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
return parseSpreadsheetContents(createWorkerFunction, parseXml, contents, _objectSpread(_objectSpread({}, options), {}, {
|
|
21
28
|
sheets: [sheet === undefined ? 1 : sheet]
|
|
22
29
|
})).then(function (sheets) {
|
|
23
30
|
var sheetData = sheets[0].data;
|
|
24
|
-
if (
|
|
25
|
-
return parseSheetData(sheetData,
|
|
31
|
+
if (schema) {
|
|
32
|
+
return parseSheetData(sheetData, schema);
|
|
26
33
|
}
|
|
27
34
|
return sheetData;
|
|
28
35
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseSheet.js","names":["parseSpreadsheetContents","parseSheetData","parseSheet","createWorkerFunction","
|
|
1
|
+
{"version":3,"file":"parseSheet.js","names":["parseSpreadsheetContents","parseSheetData","parseSheet","createWorkerFunction","parseXml","contents","sheet","optionsWithSchema","_ref","schema","options","_objectWithoutProperties","_excluded","_objectSpread","sheets","undefined","then","sheetData","data"],"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} parseXml — SAX XML parser.\r\n * @param {Record<string,Uint8Array>} 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, parseXml, contents, sheet, optionsWithSchema) {\r\n\t// `schema` has to be excluded from the `options`\r\n\tconst { schema, ...options } = optionsWithSchema || {}\r\n\treturn parseSpreadsheetContents(createWorkerFunction, parseXml, 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 (schema) {\r\n\t\t\treturn parseSheetData(sheetData, 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,QAAQ,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,iBAAiB,EAAE;EACtG;EACA,IAAAC,IAAA,GAA+BD,iBAAiB,IAAI,CAAC,CAAC;IAA9CE,MAAM,GAAAD,IAAA,CAANC,MAAM;IAAKC,OAAO,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EAC1B,OAAOZ,wBAAwB,CAACG,oBAAoB,EAAEC,QAAQ,EAAEC,QAAQ,EAAAQ,aAAA,CAAAA,aAAA,KACpEH,OAAO;IACVI,MAAM,EAAE,CAACR,KAAK,KAAKS,SAAS,GAAG,CAAC,GAAGT,KAAK;EAAC,EACzC,CAAC,CAACU,IAAI,CAAC,UAACF,MAAM,EAAK;IACnB,IAAMG,SAAS,GAAGH,MAAM,CAAC,CAAC,CAAC,CAACI,IAAI;IAChC,IAAIT,MAAM,EAAE;MACX,OAAOR,cAAc,CAACgB,SAAS,EAAER,MAAM,CAAC;IACzC;IACA,OAAOQ,SAAS;EACjB,CAAC,CAAC;AACH"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
1
|
+
import createWorkerFunction from 'worker-f/browser';
|
|
2
|
+
import parseXml from '../xml/parseXml.js';
|
|
4
3
|
import unpackXlsxFile from './unpackXlsxFileBrowser.js';
|
|
5
4
|
import parseSheet from './parseSheet.js';
|
|
6
|
-
var createWorkerFunction = undefined;
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* Reads a single sheet from an `.xlsx` file.
|
|
@@ -20,7 +18,7 @@ export default function readSheet(input, sheet, options) {
|
|
|
20
18
|
sheet = undefined;
|
|
21
19
|
}
|
|
22
20
|
return unpackXlsxFile(input).then(function (contents) {
|
|
23
|
-
return parseSheet(createWorkerFunction,
|
|
21
|
+
return parseSheet(createWorkerFunction, parseXml, contents, sheet, options);
|
|
24
22
|
});
|
|
25
23
|
}
|
|
26
24
|
//# sourceMappingURL=readSheetBrowser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readSheetBrowser.js","names":["
|
|
1
|
+
{"version":3,"file":"readSheetBrowser.js","names":["createWorkerFunction","parseXml","unpackXlsxFile","parseSheet","readSheet","input","sheet","options","undefined","then","contents"],"sources":["../../source/export/readSheetBrowser.js"],"sourcesContent":["import createWorkerFunction from 'worker-f/browser'\r\n\r\nimport parseXml from '../xml/parseXml.js'\r\nimport unpackXlsxFile from './unpackXlsxFileBrowser.js'\r\n\r\nimport parseSheet from './parseSheet.js'\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, parseXml, contents, sheet, options))\r\n}"],"mappings":"AAAA,OAAOA,oBAAoB,MAAM,kBAAkB;AAEnD,OAAOC,QAAQ,MAAM,oBAAoB;AACzC,OAAOC,cAAc,MAAM,4BAA4B;AAEvD,OAAOC,UAAU,MAAM,iBAAiB;;AAExC;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,GAAGE,SAAS;EAClB;EACA,OAAON,cAAc,CAACG,KAAK,CAAC,CAC1BI,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKP,UAAU,CAACH,oBAAoB,EAAEC,QAAQ,EAAES,QAAQ,EAAEJ,KAAK,EAAEC,OAAO,CAAC;EAAA,EAAC;AAC3F"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
1
|
+
import createWorkerFunction from 'worker-f/node';
|
|
2
|
+
import parseXml from '../xml/parseXml.js';
|
|
4
3
|
import unpackXlsxFile from './unpackXlsxFileNode.js';
|
|
5
4
|
import parseSheet from './parseSheet.js';
|
|
6
|
-
var createWorkerFunction = undefined;
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* Reads a single sheet from an `.xlsx` file.
|
|
@@ -20,7 +18,7 @@ export default function readSheet(input, sheet, options) {
|
|
|
20
18
|
sheet = undefined;
|
|
21
19
|
}
|
|
22
20
|
return unpackXlsxFile(input).then(function (contents) {
|
|
23
|
-
return parseSheet(createWorkerFunction,
|
|
21
|
+
return parseSheet(createWorkerFunction, parseXml, contents, sheet, options);
|
|
24
22
|
});
|
|
25
23
|
}
|
|
26
24
|
//# sourceMappingURL=readSheetNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readSheetNode.js","names":["
|
|
1
|
+
{"version":3,"file":"readSheetNode.js","names":["createWorkerFunction","parseXml","unpackXlsxFile","parseSheet","readSheet","input","sheet","options","undefined","then","contents"],"sources":["../../source/export/readSheetNode.js"],"sourcesContent":["import createWorkerFunction from 'worker-f/node'\r\n\r\nimport parseXml from '../xml/parseXml.js'\r\nimport unpackXlsxFile from './unpackXlsxFileNode.js'\r\n\r\nimport parseSheet from './parseSheet.js'\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, parseXml, contents, sheet, options))\r\n}"],"mappings":"AAAA,OAAOA,oBAAoB,MAAM,eAAe;AAEhD,OAAOC,QAAQ,MAAM,oBAAoB;AACzC,OAAOC,cAAc,MAAM,yBAAyB;AAEpD,OAAOC,UAAU,MAAM,iBAAiB;;AAExC;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,GAAGE,SAAS;EAClB;EACA,OAAON,cAAc,CAACG,KAAK,CAAC,CAC1BI,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKP,UAAU,CAACH,oBAAoB,EAAEC,QAAQ,EAAES,QAAQ,EAAEJ,KAAK,EAAEC,OAAO,CAAC;EAAA,EAAC;AAC3F"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import parseXml from '../xml/parseXml.js';
|
|
2
2
|
import unpackXlsxFile from './unpackXlsxFileUniversal.js';
|
|
3
3
|
import parseSheet from './parseSheet.js';
|
|
4
4
|
|
|
@@ -29,7 +29,7 @@ export default function readSheet(input, sheet, options) {
|
|
|
29
29
|
sheet = undefined;
|
|
30
30
|
}
|
|
31
31
|
return unpackXlsxFile(input).then(function (contents) {
|
|
32
|
-
return parseSheet(createWorkerFunction,
|
|
32
|
+
return parseSheet(createWorkerFunction, parseXml, contents, sheet, options);
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
//# sourceMappingURL=readSheetUniversal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readSheetUniversal.js","names":["
|
|
1
|
+
{"version":3,"file":"readSheetUniversal.js","names":["parseXml","unpackXlsxFile","parseSheet","createWorkerFunction","undefined","readSheet","input","sheet","options","then","contents"],"sources":["../../source/export/readSheetUniversal.js"],"sourcesContent":["import parseXml from '../xml/parseXml.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, parseXml, contents, sheet, options))\r\n}"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,oBAAoB;AACzC,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,QAAQ,EAAEU,QAAQ,EAAEH,KAAK,EAAEC,OAAO,CAAC;EAAA,EAAC;AAC3F"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
// import createWorkerFunction from 'worker-f/browser'
|
|
2
|
-
|
|
3
|
-
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
4
|
-
import unpackXlsxFile from './unpackXlsxFileBrowser.js';
|
|
5
|
-
import parseSheet from './parseSheet.js';
|
|
6
|
-
|
|
7
1
|
// Unzipper is multi-threaded and it spawns a separate worker for each individual file
|
|
8
2
|
// inside the archive that is large-enough to justify spawning a worker.
|
|
3
|
+
// Because it uses its own `Worker` implementation, it won't use `createWorkerFunction()`.
|
|
9
4
|
//
|
|
10
5
|
// XML parser is itself single-threaded but it could spawn a separate worker for each
|
|
11
6
|
// individual `.xml` file that is large-enough to justify spawning a worker.
|
|
7
|
+
// So it could use `createWorkerFunction()`.
|
|
12
8
|
//
|
|
13
|
-
|
|
9
|
+
import createWorkerFunction from 'worker-f/browser';
|
|
10
|
+
import parseXml from '../xml/parseXml.js';
|
|
11
|
+
import unpackXlsxFile from './unpackXlsxFileBrowser.js';
|
|
12
|
+
import parseSheet from './parseSheet.js';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Reads a single sheet from an `.xlsx` file.
|
|
@@ -27,7 +26,7 @@ export default function readSheet(input, sheet, options) {
|
|
|
27
26
|
sheet = undefined;
|
|
28
27
|
}
|
|
29
28
|
return unpackXlsxFile(input).then(function (contents) {
|
|
30
|
-
return parseSheet(createWorkerFunction,
|
|
29
|
+
return parseSheet(createWorkerFunction, parseXml, contents, sheet, options);
|
|
31
30
|
});
|
|
32
31
|
}
|
|
33
32
|
//# sourceMappingURL=readSheetWebWorker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readSheetWebWorker.js","names":["
|
|
1
|
+
{"version":3,"file":"readSheetWebWorker.js","names":["createWorkerFunction","parseXml","unpackXlsxFile","parseSheet","readSheet","input","sheet","options","undefined","then","contents"],"sources":["../../source/export/readSheetWebWorker.js"],"sourcesContent":["// 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// Because it uses its own `Worker` implementation, it won't use `createWorkerFunction()`.\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// So it could use `createWorkerFunction()`.\r\n//\r\nimport createWorkerFunction from 'worker-f/browser'\r\n\r\nimport parseXml from '../xml/parseXml.js'\r\nimport unpackXlsxFile from './unpackXlsxFileBrowser.js'\r\n\r\nimport parseSheet from './parseSheet.js'\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, parseXml, contents, sheet, options))\r\n}"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,oBAAoB,MAAM,kBAAkB;AAEnD,OAAOC,QAAQ,MAAM,oBAAoB;AACzC,OAAOC,cAAc,MAAM,4BAA4B;AAEvD,OAAOC,UAAU,MAAM,iBAAiB;;AAExC;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,GAAGE,SAAS;EAClB;EACA,OAAON,cAAc,CAACG,KAAK,CAAC,CAC1BI,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKP,UAAU,CAACH,oBAAoB,EAAEC,QAAQ,EAAES,QAAQ,EAAEJ,KAAK,EAAEC,OAAO,CAAC;EAAA,EAAC;AAC3F"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
1
|
+
import createWorkerFunction from 'worker-f/browser';
|
|
2
|
+
import parseXml from '../xml/parseXml.js';
|
|
4
3
|
import unpackXlsxFile from './unpackXlsxFileBrowser.js';
|
|
5
4
|
import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
6
|
-
var createWorkerFunction = undefined;
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* Reads an `.xlsx` file.
|
|
@@ -13,7 +11,7 @@ var createWorkerFunction = undefined;
|
|
|
13
11
|
*/
|
|
14
12
|
export default function readXlsxFile(input, options) {
|
|
15
13
|
return unpackXlsxFile(input).then(function (contents) {
|
|
16
|
-
return parseSpreadsheetContents(createWorkerFunction,
|
|
14
|
+
return parseSpreadsheetContents(createWorkerFunction, parseXml, contents, options);
|
|
17
15
|
});
|
|
18
16
|
}
|
|
19
17
|
//# sourceMappingURL=readXlsxFileBrowser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsxFileBrowser.js","names":["
|
|
1
|
+
{"version":3,"file":"readXlsxFileBrowser.js","names":["createWorkerFunction","parseXml","unpackXlsxFile","parseSpreadsheetContents","readXlsxFile","input","options","then","contents"],"sources":["../../source/export/readXlsxFileBrowser.js"],"sourcesContent":["import createWorkerFunction from 'worker-f/browser'\r\n\r\nimport parseXml from '../xml/parseXml.js'\r\nimport unpackXlsxFile from './unpackXlsxFileBrowser.js'\r\n\r\nimport parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js'\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, parseXml, contents, options))\r\n}"],"mappings":"AAAA,OAAOA,oBAAoB,MAAM,kBAAkB;AAEnD,OAAOC,QAAQ,MAAM,oBAAoB;AACzC,OAAOC,cAAc,MAAM,4BAA4B;AAEvD,OAAOC,wBAAwB,MAAM,qCAAqC;;AAE1E;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,YAAYA,CAACC,KAAK,EAAEC,OAAO,EAAE;EACpD,OAAOJ,cAAc,CAACG,KAAK,CAAC,CAC1BE,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKL,wBAAwB,CAACH,oBAAoB,EAAEC,QAAQ,EAAEO,QAAQ,EAAEF,OAAO,CAAC;EAAA,EAAC;AAClG"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
1
|
+
import createWorkerFunction from 'worker-f/node';
|
|
2
|
+
import parseXml from '../xml/parseXml.js';
|
|
4
3
|
import unpackXlsxFile from './unpackXlsxFileNode.js';
|
|
5
4
|
import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
6
|
-
var createWorkerFunction = undefined;
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* Reads an `.xlsx` file.
|
|
@@ -13,7 +11,7 @@ var createWorkerFunction = undefined;
|
|
|
13
11
|
*/
|
|
14
12
|
export default function readXlsxFile(input, options) {
|
|
15
13
|
return unpackXlsxFile(input).then(function (contents) {
|
|
16
|
-
return parseSpreadsheetContents(createWorkerFunction,
|
|
14
|
+
return parseSpreadsheetContents(createWorkerFunction, parseXml, contents, options);
|
|
17
15
|
});
|
|
18
16
|
}
|
|
19
17
|
//# sourceMappingURL=readXlsxFileNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsxFileNode.js","names":["
|
|
1
|
+
{"version":3,"file":"readXlsxFileNode.js","names":["createWorkerFunction","parseXml","unpackXlsxFile","parseSpreadsheetContents","readXlsxFile","input","options","then","contents"],"sources":["../../source/export/readXlsxFileNode.js"],"sourcesContent":["import createWorkerFunction from 'worker-f/node'\r\n\r\nimport parseXml from '../xml/parseXml.js'\r\nimport unpackXlsxFile from './unpackXlsxFileNode.js'\r\n\r\nimport parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js'\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, parseXml, contents, options))\r\n}"],"mappings":"AAAA,OAAOA,oBAAoB,MAAM,eAAe;AAEhD,OAAOC,QAAQ,MAAM,oBAAoB;AACzC,OAAOC,cAAc,MAAM,yBAAyB;AAEpD,OAAOC,wBAAwB,MAAM,qCAAqC;;AAE1E;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,YAAYA,CAACC,KAAK,EAAEC,OAAO,EAAE;EACpD,OAAOJ,cAAc,CAACG,KAAK,CAAC,CAC1BE,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKL,wBAAwB,CAACH,oBAAoB,EAAEC,QAAQ,EAAEO,QAAQ,EAAEF,OAAO,CAAC;EAAA,EAAC;AAClG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import parseXml from '../xml/parseXml.js';
|
|
2
2
|
import unpackXlsxFile from './unpackXlsxFileUniversal.js';
|
|
3
3
|
import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
4
4
|
|
|
@@ -22,7 +22,7 @@ var createWorkerFunction = undefined;
|
|
|
22
22
|
*/
|
|
23
23
|
export default function readXlsxFile(input, options) {
|
|
24
24
|
return unpackXlsxFile(input).then(function (contents) {
|
|
25
|
-
return parseSpreadsheetContents(createWorkerFunction,
|
|
25
|
+
return parseSpreadsheetContents(createWorkerFunction, parseXml, contents, options);
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
//# sourceMappingURL=readXlsxFileUniversal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsxFileUniversal.js","names":["
|
|
1
|
+
{"version":3,"file":"readXlsxFileUniversal.js","names":["parseXml","unpackXlsxFile","parseSpreadsheetContents","createWorkerFunction","undefined","readXlsxFile","input","options","then","contents"],"sources":["../../source/export/readXlsxFileUniversal.js"],"sourcesContent":["import parseXml from '../xml/parseXml.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, parseXml, contents, options))\r\n}"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,oBAAoB;AACzC,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,QAAQ,EAAES,QAAQ,EAAEF,OAAO,CAAC;EAAA,EAAC;AAClG"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
// import createWorkerFunction from 'worker-f/browser'
|
|
2
|
-
|
|
3
|
-
import parseXmlStream from '../xml/parseXmlStream.js';
|
|
4
|
-
import unpackXlsxFile from './unpackXlsxFileBrowser.js';
|
|
5
|
-
import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
6
|
-
|
|
7
1
|
// Unzipper is multi-threaded and it spawns a separate worker for each individual file
|
|
8
2
|
// inside the archive that is large-enough to justify spawning a worker.
|
|
3
|
+
// Because it uses its own `Worker` implementation, it won't use `createWorkerFunction()`.
|
|
9
4
|
//
|
|
10
5
|
// XML parser is itself single-threaded but it could spawn a separate worker for each
|
|
11
6
|
// individual `.xml` file that is large-enough to justify spawning a worker.
|
|
7
|
+
// So it could use `createWorkerFunction()`.
|
|
12
8
|
//
|
|
13
|
-
|
|
9
|
+
import createWorkerFunction from 'worker-f/browser';
|
|
10
|
+
import parseXml from '../xml/parseXml.js';
|
|
11
|
+
import unpackXlsxFile from './unpackXlsxFileBrowser.js';
|
|
12
|
+
import parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Reads an `.xlsx` file.
|
|
@@ -20,7 +19,7 @@ var createWorkerFunction = undefined;
|
|
|
20
19
|
*/
|
|
21
20
|
export default function readXlsxFile(file, options) {
|
|
22
21
|
return unpackXlsxFile(file).then(function (contents) {
|
|
23
|
-
return parseSpreadsheetContents(createWorkerFunction,
|
|
22
|
+
return parseSpreadsheetContents(createWorkerFunction, parseXml, contents, options);
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
25
|
//# sourceMappingURL=readXlsxFileWebWorker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readXlsxFileWebWorker.js","names":["
|
|
1
|
+
{"version":3,"file":"readXlsxFileWebWorker.js","names":["createWorkerFunction","parseXml","unpackXlsxFile","parseSpreadsheetContents","readXlsxFile","file","options","then","contents"],"sources":["../../source/export/readXlsxFileWebWorker.js"],"sourcesContent":["// 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// Because it uses its own `Worker` implementation, it won't use `createWorkerFunction()`.\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// So it could use `createWorkerFunction()`.\r\n//\r\nimport createWorkerFunction from 'worker-f/browser'\r\n\r\nimport parseXml from '../xml/parseXml.js'\r\n\r\nimport unpackXlsxFile from './unpackXlsxFileBrowser.js'\r\nimport parseSpreadsheetContents from '../xlsx/parseSpreadsheetContents.js'\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, parseXml, contents, options))\r\n}"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,oBAAoB,MAAM,kBAAkB;AAEnD,OAAOC,QAAQ,MAAM,oBAAoB;AAEzC,OAAOC,cAAc,MAAM,4BAA4B;AACvD,OAAOC,wBAAwB,MAAM,qCAAqC;;AAE1E;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,YAAYA,CAACC,IAAI,EAAEC,OAAO,EAAE;EACnD,OAAOJ,cAAc,CAACG,IAAI,CAAC,CACzBE,IAAI,CAAC,UAACC,QAAQ;IAAA,OAAKL,wBAAwB,CAACH,oBAAoB,EAAEC,QAAQ,EAAEO,QAAQ,EAAEF,OAAO,CAAC;EAAA,EAAC;AAClG"}
|