UNPKG

read-excel-file

Version:

Read `.xlsx` files in a web browser or in Node.js

34 lines (32 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = readXlsxFile; var _parseXml = _interopRequireDefault(require("../xml/parseXml.js")); var _unpackXlsxFileUniversal = _interopRequireDefault(require("./unpackXlsxFileUniversal.js")); var _parseSpreadsheetContents = _interopRequireDefault(require("../xlsx/parseSpreadsheetContents.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } // There seems to be no way to access Node.js `Worker` // other than explicitly `import`ing it from the "worker_threads" module. // It's in contrast to web browsers where the `Worker` class is accessible through a global variable. // // The requirement for an explicit `import` of a "native" module in Node.js // means that it's not really possible to write a "universal" worker implementation // because what works in Node.js won't work in a web browser due to the absence of the "native" module. // // So there seems to be no way to use `Worker` in a "universal" export. // var createWorkerFunction = undefined; /** * Reads an `.xlsx` file. * @param {(Blob|ArrayBuffer)} input * @param {object} [options] * @return {Promise<Sheet[]>} */ function readXlsxFile(input, options) { return (0, _unpackXlsxFileUniversal["default"])(input).then(function (contents) { return (0, _parseSpreadsheetContents["default"])(createWorkerFunction, _parseXml["default"], contents, options); }); } //# sourceMappingURL=readXlsxFileUniversal.js.map