read-excel-file 5.2.21 → 5.2.22

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 CHANGED
@@ -5,6 +5,11 @@
5
5
  * Added [TypeScript](https://github.com/catamphetamine/read-excel-file/issues/71) definitions.
6
6
  -->
7
7
 
8
+ 5.2.22 / 11.11.2021
9
+ ==================
10
+
11
+ * [Added](https://github.com/catamphetamine/read-excel-file/issues/100) `/web-worker` export
12
+
8
13
  5.2.11 / 08.10.2021
9
14
  ==================
10
15
 
package/README.md CHANGED
@@ -50,10 +50,47 @@ readXlsxFile('/path/to/file').then((rows) => {
50
50
 
51
51
  // Readable Stream.
52
52
  readXlsxFile(fs.createReadStream('/path/to/file')).then((rows) => {
53
- ...
53
+ // `rows` is an array of rows
54
+ // each row being an array of cells.
55
+ })
56
+ ```
57
+
58
+ ### Web Worker
59
+
60
+ ```js
61
+ const worker = new Worker('web-worker.js')
62
+
63
+ worker.onmessage = function(event) {
64
+ // `event.data` is an array of rows
65
+ // each row being an array of cells.
66
+ console.log(event.data)
67
+ }
68
+
69
+ worker.onerror = function(event) {
70
+ console.error(event.message)
71
+ }
72
+
73
+ const input = document.getElementById('input')
74
+
75
+ input.addEventListener('change', () => {
76
+ worker.postMessage(input.files[0])
54
77
  })
55
78
  ```
56
79
 
80
+ ##### `web-worker.js`
81
+
82
+ ```js
83
+ import readXlsxFile from 'read-excel-file/web-worker'
84
+
85
+ onmessage = function(event) {
86
+ readXlsxFile(event.data).then((rows) => {
87
+ // `rows` is an array of rows
88
+ // each row being an array of cells.
89
+ postMessage(rows)
90
+ })
91
+ }
92
+ ```
93
+
57
94
  ## JSON
58
95
 
59
96
  To convert table rows to JSON objects, pass a `schema` option to `readXlsxFile()`. It will return `{ rows, errors }` object instead of just `rows`.
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = readXlsxFile;
7
7
 
8
- var _xmlNode = _interopRequireDefault(require("../xml/xmlNode"));
8
+ var _xml = _interopRequireDefault(require("../xml/xml"));
9
9
 
10
10
  var _unpackXlsxFileNode = _interopRequireDefault(require("./unpackXlsxFileNode"));
11
11
 
@@ -23,7 +23,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
23
23
  function readXlsxFile(input) {
24
24
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25
25
  return (0, _unpackXlsxFileNode["default"])(input).then(function (entries) {
26
- return (0, _readXlsxFileContents["default"])(entries, _xmlNode["default"], options);
26
+ return (0, _readXlsxFileContents["default"])(entries, _xml["default"], options);
27
27
  });
28
28
  }
29
29
  //# sourceMappingURL=readXlsxFileNode.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../source/read/readXlsxFileNode.js"],"names":["readXlsxFile","input","options","then","entries","xml"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,YAAT,CAAsBC,KAAtB,EAA2C;AAAA,MAAdC,OAAc,uEAAJ,EAAI;AACzD,SAAO,oCAAeD,KAAf,EACLE,IADK,CACA,UAACC,OAAD;AAAA,WAAa,sCAAqBA,OAArB,EAA8BC,mBAA9B,EAAmCH,OAAnC,CAAb;AAAA,GADA,CAAP;AAEA","sourcesContent":["import xml from '../xml/xmlNode'\r\n\r\nimport unpackXlsxFile from './unpackXlsxFileNode'\r\nimport readXlsxFileContents from './readXlsxFileContents'\r\n\r\n/**\r\n * Reads XLSX file into a 2D array of cells in a browser.\r\n * @param {(string|Stream|Buffer)} input - A Node.js readable stream or a `Buffer` or a path to a file.\r\n * @param {object?} options\r\n * @param {(number|string)?} options.sheet - Excel document sheet to read. Defaults to `1`. Will only read this sheet and skip others.\r\n * @return {Promise} Resolves to a 2D array of cells: an array of rows, each row being an array of cells.\r\n */\r\nexport default function readXlsxFile(input, options = {}) {\r\n\treturn unpackXlsxFile(input)\r\n\t\t.then((entries) => readXlsxFileContents(entries, xml, options))\r\n}"],"file":"readXlsxFileNode.js"}
1
+ {"version":3,"sources":["../../source/read/readXlsxFileNode.js"],"names":["readXlsxFile","input","options","then","entries","xml"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,YAAT,CAAsBC,KAAtB,EAA2C;AAAA,MAAdC,OAAc,uEAAJ,EAAI;AACzD,SAAO,oCAAeD,KAAf,EACLE,IADK,CACA,UAACC,OAAD;AAAA,WAAa,sCAAqBA,OAArB,EAA8BC,eAA9B,EAAmCH,OAAnC,CAAb;AAAA,GADA,CAAP;AAEA","sourcesContent":["import xml from '../xml/xml'\r\n\r\nimport unpackXlsxFile from './unpackXlsxFileNode'\r\nimport readXlsxFileContents from './readXlsxFileContents'\r\n\r\n/**\r\n * Reads XLSX file into a 2D array of cells in a browser.\r\n * @param {(string|Stream|Buffer)} input - A Node.js readable stream or a `Buffer` or a path to a file.\r\n * @param {object?} options\r\n * @param {(number|string)?} options.sheet - Excel document sheet to read. Defaults to `1`. Will only read this sheet and skip others.\r\n * @return {Promise} Resolves to a 2D array of cells: an array of rows, each row being an array of cells.\r\n */\r\nexport default function readXlsxFile(input, options = {}) {\r\n\treturn unpackXlsxFile(input)\r\n\t\t.then((entries) => readXlsxFileContents(entries, xml, options))\r\n}"],"file":"readXlsxFileNode.js"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = readXlsxFile;
7
+
8
+ var _xml = _interopRequireDefault(require("../xml/xml"));
9
+
10
+ var _unpackXlsxFileBrowser = _interopRequireDefault(require("./unpackXlsxFileBrowser"));
11
+
12
+ var _readXlsxFileContents = _interopRequireDefault(require("./readXlsxFileContents"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
+
16
+ /**
17
+ * Reads XLSX file into a 2D array of cells in a web worker.
18
+ * @param {file} file - The file.
19
+ * @param {object?} options
20
+ * @param {(number|string)?} options.sheet - Excel document sheet to read. Defaults to `1`. Will only read this sheet and skip others.
21
+ * @return {Promise} Resolves to a 2D array of cells: an array of rows, each row being an array of cells.
22
+ */
23
+ function readXlsxFile(file) {
24
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25
+ return (0, _unpackXlsxFileBrowser["default"])(file).then(function (entries) {
26
+ return (0, _readXlsxFileContents["default"])(entries, _xml["default"], options);
27
+ });
28
+ }
29
+ //# sourceMappingURL=readXlsxFileWebWorker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../source/read/readXlsxFileWebWorker.js"],"names":["readXlsxFile","file","options","then","entries","xml"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,YAAT,CAAsBC,IAAtB,EAA0C;AAAA,MAAdC,OAAc,uEAAJ,EAAI;AACxD,SAAO,uCAAeD,IAAf,EACLE,IADK,CACA,UAACC,OAAD;AAAA,WAAa,sCAAqBA,OAArB,EAA8BC,eAA9B,EAAmCH,OAAnC,CAAb;AAAA,GADA,CAAP;AAEA","sourcesContent":["import xml from '../xml/xml'\r\n\r\nimport unpackXlsxFile from './unpackXlsxFileBrowser'\r\nimport readXlsxFileContents from './readXlsxFileContents'\r\n\r\n/**\r\n * Reads XLSX file into a 2D array of cells in a web worker.\r\n * @param {file} file - The file.\r\n * @param {object?} options\r\n * @param {(number|string)?} options.sheet - Excel document sheet to read. Defaults to `1`. Will only read this sheet and skip others.\r\n * @return {Promise} Resolves to a 2D array of cells: an array of rows, each row being an array of cells.\r\n */\r\nexport default function readXlsxFile(file, options = {}) {\r\n\treturn unpackXlsxFile(file)\r\n\t\t.then((entries) => readXlsxFileContents(entries, xml, options))\r\n}"],"file":"readXlsxFileWebWorker.js"}
@@ -15,4 +15,4 @@ var _default = {
15
15
  }
16
16
  };
17
17
  exports["default"] = _default;
18
- //# sourceMappingURL=xmlNode.js.map
18
+ //# sourceMappingURL=xml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../source/xml/xml.js"],"names":["createDocument","content","XMLDOM","DOMParser","parseFromString"],"mappings":";;;;;;;AAAA;;;;eAEe;AACdA,EAAAA,cADc,0BACCC,OADD,EACU;AACvB,WAAO,IAAIC,mBAAOC,SAAX,GAAuBC,eAAvB,CAAuCH,OAAvC,CAAP;AACA;AAHa,C","sourcesContent":["import XMLDOM from '@xmldom/xmldom'\r\n\r\nexport default {\r\n\tcreateDocument(content) {\r\n\t\treturn new XMLDOM.DOMParser().parseFromString(content)\r\n\t}\r\n}"],"file":"xml.js"}
@@ -1,4 +1,4 @@
1
- import xml from '../xml/xmlNode';
1
+ import xml from '../xml/xml';
2
2
  import unpackXlsxFile from './unpackXlsxFileNode';
3
3
  import readXlsxFileContents from './readXlsxFileContents';
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../source/read/readXlsxFileNode.js"],"names":["xml","unpackXlsxFile","readXlsxFileContents","readXlsxFile","input","options","then","entries"],"mappings":"AAAA,OAAOA,GAAP,MAAgB,gBAAhB;AAEA,OAAOC,cAAP,MAA2B,sBAA3B;AACA,OAAOC,oBAAP,MAAiC,wBAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,YAAT,CAAsBC,KAAtB,EAA2C;AAAA,MAAdC,OAAc,uEAAJ,EAAI;AACzD,SAAOJ,cAAc,CAACG,KAAD,CAAd,CACLE,IADK,CACA,UAACC,OAAD;AAAA,WAAaL,oBAAoB,CAACK,OAAD,EAAUP,GAAV,EAAeK,OAAf,CAAjC;AAAA,GADA,CAAP;AAEA","sourcesContent":["import xml from '../xml/xmlNode'\r\n\r\nimport unpackXlsxFile from './unpackXlsxFileNode'\r\nimport readXlsxFileContents from './readXlsxFileContents'\r\n\r\n/**\r\n * Reads XLSX file into a 2D array of cells in a browser.\r\n * @param {(string|Stream|Buffer)} input - A Node.js readable stream or a `Buffer` or a path to a file.\r\n * @param {object?} options\r\n * @param {(number|string)?} options.sheet - Excel document sheet to read. Defaults to `1`. Will only read this sheet and skip others.\r\n * @return {Promise} Resolves to a 2D array of cells: an array of rows, each row being an array of cells.\r\n */\r\nexport default function readXlsxFile(input, options = {}) {\r\n\treturn unpackXlsxFile(input)\r\n\t\t.then((entries) => readXlsxFileContents(entries, xml, options))\r\n}"],"file":"readXlsxFileNode.js"}
1
+ {"version":3,"sources":["../../source/read/readXlsxFileNode.js"],"names":["xml","unpackXlsxFile","readXlsxFileContents","readXlsxFile","input","options","then","entries"],"mappings":"AAAA,OAAOA,GAAP,MAAgB,YAAhB;AAEA,OAAOC,cAAP,MAA2B,sBAA3B;AACA,OAAOC,oBAAP,MAAiC,wBAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,YAAT,CAAsBC,KAAtB,EAA2C;AAAA,MAAdC,OAAc,uEAAJ,EAAI;AACzD,SAAOJ,cAAc,CAACG,KAAD,CAAd,CACLE,IADK,CACA,UAACC,OAAD;AAAA,WAAaL,oBAAoB,CAACK,OAAD,EAAUP,GAAV,EAAeK,OAAf,CAAjC;AAAA,GADA,CAAP;AAEA","sourcesContent":["import xml from '../xml/xml'\r\n\r\nimport unpackXlsxFile from './unpackXlsxFileNode'\r\nimport readXlsxFileContents from './readXlsxFileContents'\r\n\r\n/**\r\n * Reads XLSX file into a 2D array of cells in a browser.\r\n * @param {(string|Stream|Buffer)} input - A Node.js readable stream or a `Buffer` or a path to a file.\r\n * @param {object?} options\r\n * @param {(number|string)?} options.sheet - Excel document sheet to read. Defaults to `1`. Will only read this sheet and skip others.\r\n * @return {Promise} Resolves to a 2D array of cells: an array of rows, each row being an array of cells.\r\n */\r\nexport default function readXlsxFile(input, options = {}) {\r\n\treturn unpackXlsxFile(input)\r\n\t\t.then((entries) => readXlsxFileContents(entries, xml, options))\r\n}"],"file":"readXlsxFileNode.js"}
@@ -0,0 +1,18 @@
1
+ import xml from '../xml/xml';
2
+ import unpackXlsxFile from './unpackXlsxFileBrowser';
3
+ import readXlsxFileContents from './readXlsxFileContents';
4
+ /**
5
+ * Reads XLSX file into a 2D array of cells in a web worker.
6
+ * @param {file} file - The file.
7
+ * @param {object?} options
8
+ * @param {(number|string)?} options.sheet - Excel document sheet to read. Defaults to `1`. Will only read this sheet and skip others.
9
+ * @return {Promise} Resolves to a 2D array of cells: an array of rows, each row being an array of cells.
10
+ */
11
+
12
+ export default function readXlsxFile(file) {
13
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
14
+ return unpackXlsxFile(file).then(function (entries) {
15
+ return readXlsxFileContents(entries, xml, options);
16
+ });
17
+ }
18
+ //# sourceMappingURL=readXlsxFileWebWorker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../source/read/readXlsxFileWebWorker.js"],"names":["xml","unpackXlsxFile","readXlsxFileContents","readXlsxFile","file","options","then","entries"],"mappings":"AAAA,OAAOA,GAAP,MAAgB,YAAhB;AAEA,OAAOC,cAAP,MAA2B,yBAA3B;AACA,OAAOC,oBAAP,MAAiC,wBAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,YAAT,CAAsBC,IAAtB,EAA0C;AAAA,MAAdC,OAAc,uEAAJ,EAAI;AACxD,SAAOJ,cAAc,CAACG,IAAD,CAAd,CACLE,IADK,CACA,UAACC,OAAD;AAAA,WAAaL,oBAAoB,CAACK,OAAD,EAAUP,GAAV,EAAeK,OAAf,CAAjC;AAAA,GADA,CAAP;AAEA","sourcesContent":["import xml from '../xml/xml'\r\n\r\nimport unpackXlsxFile from './unpackXlsxFileBrowser'\r\nimport readXlsxFileContents from './readXlsxFileContents'\r\n\r\n/**\r\n * Reads XLSX file into a 2D array of cells in a web worker.\r\n * @param {file} file - The file.\r\n * @param {object?} options\r\n * @param {(number|string)?} options.sheet - Excel document sheet to read. Defaults to `1`. Will only read this sheet and skip others.\r\n * @return {Promise} Resolves to a 2D array of cells: an array of rows, each row being an array of cells.\r\n */\r\nexport default function readXlsxFile(file, options = {}) {\r\n\treturn unpackXlsxFile(file)\r\n\t\t.then((entries) => readXlsxFileContents(entries, xml, options))\r\n}"],"file":"readXlsxFileWebWorker.js"}
@@ -4,4 +4,4 @@ export default {
4
4
  return new XMLDOM.DOMParser().parseFromString(content);
5
5
  }
6
6
  };
7
- //# sourceMappingURL=xmlNode.js.map
7
+ //# sourceMappingURL=xml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../source/xml/xml.js"],"names":["XMLDOM","createDocument","content","DOMParser","parseFromString"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,gBAAnB;AAEA,eAAe;AACdC,EAAAA,cADc,0BACCC,OADD,EACU;AACvB,WAAO,IAAIF,MAAM,CAACG,SAAX,GAAuBC,eAAvB,CAAuCF,OAAvC,CAAP;AACA;AAHa,CAAf","sourcesContent":["import XMLDOM from '@xmldom/xmldom'\r\n\r\nexport default {\r\n\tcreateDocument(content) {\r\n\t\treturn new XMLDOM.DOMParser().parseFromString(content)\r\n\t}\r\n}"],"file":"xml.js"}
package/node/package.json CHANGED
@@ -4,6 +4,6 @@
4
4
  "version": "1.0.0",
5
5
  "main": "index.commonjs.js",
6
6
  "module": "index.js",
7
- "types.test": "./index.d.ts.test",
7
+ "types": "./index.d.ts",
8
8
  "sideEffects": false
9
9
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "read-excel-file",
3
- "version": "5.2.21",
3
+ "version": "5.2.22",
4
4
  "description": "Read small to medium `*.xlsx` files in a browser or Node.js. Parse to JSON with a strict schema.",
5
5
  "module": "index.js",
6
6
  "sideEffects": false,
7
7
  "main": "index.commonjs.js",
8
- "types.test": "./index.d.ts.test",
8
+ "types": "./index.d.ts",
9
9
  "scripts": {
10
10
  "test": "mocha --require @babel/register --colors --bail --reporter spec --require ./test/setup.js \"./{,!(node_modules|commonjs|modules)/**/}*.test.js\" --recursive",
11
11
  "test-coverage": "istanbul cover -x \"commonjs/**\" -x \"modules/**\" -x \"*.test.js\" node_modules/mocha/bin/_mocha -- --compilers js:babel-core/register --colors --reporter dot --require ./test/setup.js \"./{,!(node_modules|commonjs|modules)/**/}*.test.js\" --recursive",
@@ -4,6 +4,6 @@
4
4
  "version": "1.0.0",
5
5
  "main": "index.commonjs.js",
6
6
  "module": "index.js",
7
- "types.test": "./index.d.ts.test",
7
+ "types": "./index.d.ts",
8
8
  "sideEffects": false
9
9
  }
@@ -0,0 +1,6 @@
1
+ exports = module.exports = require('../commonjs/read/readXlsxFileWebWorker').default
2
+ exports['default'] = require('../commonjs/read/readXlsxFileWebWorker').default
3
+ exports.parseExcelDate = require('../commonjs/read/parseDate').default
4
+ exports.Integer = require('../commonjs/types/Integer').default
5
+ exports.Email = require('../commonjs/types/Email').default
6
+ exports.URL = require('../commonjs/types/URL').default
@@ -0,0 +1 @@
1
+ export * from '../index.d';
@@ -0,0 +1,5 @@
1
+ export { default as default } from '../modules/read/readXlsxFileNode'
2
+ export { default as parseExcelDate } from '../modules/read/parseDate'
3
+ export { default as Integer } from '../modules/types/Integer'
4
+ export { default as Email } from '../modules/types/Email'
5
+ export { default as URL } from '../modules/types/URL'
@@ -0,0 +1,9 @@
1
+ {
2
+ "private": true,
3
+ "name": "read-excel-file/web-worker",
4
+ "version": "1.0.0",
5
+ "main": "index.commonjs.js",
6
+ "module": "index.js",
7
+ "types": "./index.d.ts",
8
+ "sideEffects": false
9
+ }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../source/xml/xmlNode.js"],"names":["createDocument","content","XMLDOM","DOMParser","parseFromString"],"mappings":";;;;;;;AAAA;;;;eAEe;AACdA,EAAAA,cADc,0BACCC,OADD,EACU;AACvB,WAAO,IAAIC,mBAAOC,SAAX,GAAuBC,eAAvB,CAAuCH,OAAvC,CAAP;AACA;AAHa,C","sourcesContent":["import XMLDOM from '@xmldom/xmldom'\r\n\r\nexport default {\r\n\tcreateDocument(content) {\r\n\t\treturn new XMLDOM.DOMParser().parseFromString(content)\r\n\t}\r\n}"],"file":"xmlNode.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../source/xml/xmlNode.js"],"names":["XMLDOM","createDocument","content","DOMParser","parseFromString"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,gBAAnB;AAEA,eAAe;AACdC,EAAAA,cADc,0BACCC,OADD,EACU;AACvB,WAAO,IAAIF,MAAM,CAACG,SAAX,GAAuBC,eAAvB,CAAuCF,OAAvC,CAAP;AACA;AAHa,CAAf","sourcesContent":["import XMLDOM from '@xmldom/xmldom'\r\n\r\nexport default {\r\n\tcreateDocument(content) {\r\n\t\treturn new XMLDOM.DOMParser().parseFromString(content)\r\n\t}\r\n}"],"file":"xmlNode.js"}