read-excel-file 5.8.8 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.md +223 -271
- package/bundle/read-excel-file.min.js +1 -1
- package/bundle/read-excel-file.min.js.map +1 -1
- package/commonjs/read/dropEmptyRows.js +3 -3
- package/commonjs/read/dropEmptyRows.js.map +1 -1
- package/commonjs/read/dropEmptyRows.test.js.map +1 -1
- package/commonjs/read/getData.js +18 -8
- package/commonjs/read/getData.js.map +1 -1
- package/commonjs/read/readXlsx.js +2 -2
- package/commonjs/read/readXlsx.js.map +1 -1
- package/commonjs/read/readXlsxFileContents.js +8 -9
- package/commonjs/read/readXlsxFileContents.js.map +1 -1
- package/commonjs/read/readXlsxFileNode.test.js.map +1 -1
- package/commonjs/read/schema/mapToObjects.js +100 -38
- package/commonjs/read/schema/mapToObjects.js.map +1 -1
- package/commonjs/read/schema/mapToObjects.test.js.map +1 -1
- package/index.d.ts +0 -2
- package/modules/read/dropEmptyRows.js +3 -3
- package/modules/read/dropEmptyRows.js.map +1 -1
- package/modules/read/dropEmptyRows.test.js.map +1 -1
- package/modules/read/getData.js +18 -8
- package/modules/read/getData.js.map +1 -1
- package/modules/read/readXlsx.js +2 -2
- package/modules/read/readXlsx.js.map +1 -1
- package/modules/read/readXlsxFileContents.js +8 -9
- package/modules/read/readXlsxFileContents.js.map +1 -1
- package/modules/read/readXlsxFileNode.test.js.map +1 -1
- package/modules/read/schema/mapToObjects.js +100 -38
- package/modules/read/schema/mapToObjects.js.map +1 -1
- package/modules/read/schema/mapToObjects.test.js.map +1 -1
- package/node/index.d.ts +0 -2
- package/package.json +5 -15
- package/types.d.ts +25 -39
- package/web-worker/index.d.ts +0 -2
- package/bundle/index.html +0 -261
- package/bundle/lib/prism.css +0 -125
- package/bundle/lib/prism.js +0 -7
- package/bundle/lib/promise-polyfill.min.js +0 -1
- package/commonjs/read/schema/convertMapToSchema.js +0 -27
- package/commonjs/read/schema/convertMapToSchema.js.map +0 -1
- package/commonjs/read/schema/convertMapToSchema.test.js.map +0 -1
- package/commonjs/read/schema/mapToObjects.legacy.js +0 -60
- package/commonjs/read/schema/mapToObjects.legacy.js.map +0 -1
- package/commonjs/read/schema/mapToObjects.legacy.test.js.map +0 -1
- package/commonjs/read/schema/mapToObjects.spreadsheet.js +0 -25
- package/commonjs/read/schema/mapToObjects.spreadsheet.js.map +0 -1
- package/commonjs/read/schema/mapToObjects.spreadsheet.test.js.map +0 -1
- package/map/index.cjs +0 -2
- package/map/index.cjs.js +0 -7
- package/map/index.d.ts +0 -15
- package/map/index.js +0 -1
- package/map/package.json +0 -17
- package/modules/read/schema/convertMapToSchema.js +0 -21
- package/modules/read/schema/convertMapToSchema.js.map +0 -1
- package/modules/read/schema/convertMapToSchema.test.js.map +0 -1
- package/modules/read/schema/mapToObjects.legacy.js +0 -53
- package/modules/read/schema/mapToObjects.legacy.js.map +0 -1
- package/modules/read/schema/mapToObjects.legacy.test.js.map +0 -1
- package/modules/read/schema/mapToObjects.spreadsheet.js +0 -19
- package/modules/read/schema/mapToObjects.spreadsheet.js.map +0 -1
- package/modules/read/schema/mapToObjects.spreadsheet.test.js.map +0 -1
- package/schema/index.cjs +0 -2
- package/schema/index.cjs.js +0 -7
- package/schema/index.d.ts +0 -11
- package/schema/index.js +0 -1
- package/schema/package.json +0 -17
- package/website/index.html +0 -261
- package/website/lib/prism.css +0 -125
- package/website/lib/prism.js +0 -7
- package/website/lib/promise-polyfill.min.js +0 -1
package/map/index.cjs.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// This file is deprecated.
|
|
2
|
-
// It's the same as `index.cjs`, just with an added `*.js` extension.
|
|
3
|
-
// It fixes the issue when some software doesn't see files with `*.cjs` file extensions
|
|
4
|
-
// when used as the `main` property value in `package.json`.
|
|
5
|
-
|
|
6
|
-
exports = module.exports = require('../commonjs/read/schema/mapToObjects.js').default
|
|
7
|
-
exports['default'] = require('../commonjs/read/schema/mapToObjects.js').default
|
package/map/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Row,
|
|
3
|
-
Schema,
|
|
4
|
-
Error,
|
|
5
|
-
MappingParameters
|
|
6
|
-
} from '../types.d.js';
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
MappingParameters
|
|
10
|
-
} from '../types.d.js'
|
|
11
|
-
|
|
12
|
-
export default function map<T>(data: Row[], schema: Schema<T>, options?: MappingParameters): {
|
|
13
|
-
rows: T[];
|
|
14
|
-
errors: Error[];
|
|
15
|
-
};
|
package/map/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as default } from '../modules/read/schema/mapToObjects.js'
|
package/map/package.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"private": true,
|
|
3
|
-
"name": "read-excel-file/schema",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"main": "index.cjs",
|
|
6
|
-
"module": "index.js",
|
|
7
|
-
"types": "./index.d.ts",
|
|
8
|
-
"type": "module",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./index.d.ts",
|
|
12
|
-
"import": "./index.js",
|
|
13
|
-
"require": "./index.cjs"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"sideEffects": false
|
|
17
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
export default function convertMapToSchema(map) {
|
|
3
|
-
var schema = {};
|
|
4
|
-
for (var _i = 0, _Object$keys = Object.keys(map); _i < _Object$keys.length; _i++) {
|
|
5
|
-
var key = _Object$keys[_i];
|
|
6
|
-
var prop = map[key];
|
|
7
|
-
var type = void 0;
|
|
8
|
-
if (_typeof(prop) === 'object') {
|
|
9
|
-
prop = Object.keys(map[key])[0];
|
|
10
|
-
type = convertMapToSchema(map[key][prop]);
|
|
11
|
-
}
|
|
12
|
-
schema[key] = {
|
|
13
|
-
prop: prop
|
|
14
|
-
};
|
|
15
|
-
if (type) {
|
|
16
|
-
schema[key].type = type;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return schema;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=convertMapToSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convertMapToSchema.js","names":["convertMapToSchema","map","schema","_i","_Object$keys","Object","keys","length","key","prop","type","_typeof"],"sources":["../../../source/read/schema/convertMapToSchema.js"],"sourcesContent":["export default function convertMapToSchema(map) {\r\n\tconst schema = {}\r\n\tfor (const key of Object.keys(map)) {\r\n\t\tlet prop = map[key]\r\n\t\tlet type\r\n\t\tif (typeof prop === 'object') {\r\n\t\t\tprop = Object.keys(map[key])[0]\r\n\t\t\ttype = convertMapToSchema(map[key][prop])\r\n\t\t}\r\n\t\tschema[key] = {\r\n\t\t\tprop\r\n\t\t}\r\n\t\tif (type) {\r\n\t\t\tschema[key].type = type\r\n\t\t}\r\n\t}\r\n\treturn schema\r\n}"],"mappings":";AAAA,eAAe,SAASA,kBAAkBA,CAACC,GAAG,EAAE;EAC/C,IAAMC,MAAM,GAAG,CAAC,CAAC;EACjB,SAAAC,EAAA,MAAAC,YAAA,GAAkBC,MAAM,CAACC,IAAI,CAACL,GAAG,CAAC,EAAAE,EAAA,GAAAC,YAAA,CAAAG,MAAA,EAAAJ,EAAA,IAAE;IAA/B,IAAMK,GAAG,GAAAJ,YAAA,CAAAD,EAAA;IACb,IAAIM,IAAI,GAAGR,GAAG,CAACO,GAAG,CAAC;IACnB,IAAIE,IAAI;IACR,IAAIC,OAAA,CAAOF,IAAI,MAAK,QAAQ,EAAE;MAC7BA,IAAI,GAAGJ,MAAM,CAACC,IAAI,CAACL,GAAG,CAACO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;MAC/BE,IAAI,GAAGV,kBAAkB,CAACC,GAAG,CAACO,GAAG,CAAC,CAACC,IAAI,CAAC,CAAC;IAC1C;IACAP,MAAM,CAACM,GAAG,CAAC,GAAG;MACbC,IAAI,EAAJA;IACD,CAAC;IACD,IAAIC,IAAI,EAAE;MACTR,MAAM,CAACM,GAAG,CAAC,CAACE,IAAI,GAAGA,IAAI;IACxB;EACD;EACA,OAAOR,MAAM;AACd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convertMapToSchema.test.js","names":["convertMapToSchema","describe","it","map","should","deep","equal","prop","type"],"sources":["../../../source/read/schema/convertMapToSchema.test.js"],"sourcesContent":["import convertMapToSchema from './convertMapToSchema.js'\r\n\r\ndescribe('convertMapToSchema', () => {\r\n\tit('should convert map to schema', () => {\r\n\t\tconst map = {\r\n\t\t\t'START DATE': 'date',\r\n\t\t\t'NUMBER OF STUDENTS': 'numberOfStudents',\r\n\t\t\t'COURSE': {\r\n\t\t\t\t'course': {\r\n\t\t\t\t\t'IS FREE': 'isFree',\r\n\t\t\t\t\t'COURSE TITLE': 'title'\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\t'CONTACT': 'contact',\r\n\t\t\t'STATUS': 'status'\r\n\t\t}\r\n\t\tconvertMapToSchema(map).should.deep.equal({\r\n\t\t\t'START DATE': {\r\n\t\t\t\tprop: 'date'\r\n\t\t\t},\r\n\t\t\t'NUMBER OF STUDENTS': {\r\n\t\t\t\tprop: 'numberOfStudents'\r\n\t\t\t},\r\n\t\t\t'COURSE': {\r\n\t\t\t\tprop: 'course',\r\n\t\t\t\ttype: {\r\n\t\t\t\t\t'IS FREE': {\r\n\t\t\t\t\t\tprop: 'isFree'\r\n\t\t\t\t\t},\r\n\t\t\t\t\t'COURSE TITLE': {\r\n\t\t\t\t\t\tprop: 'title'\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\t'CONTACT': {\r\n\t\t\t\tprop: 'contact'\r\n\t\t\t},\r\n\t\t\t'STATUS': {\r\n\t\t\t\tprop: 'status'\r\n\t\t\t}\r\n\t\t})\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,kBAAkB,MAAM,yBAAyB;AAExDC,QAAQ,CAAC,oBAAoB,EAAE,YAAM;EACpCC,EAAE,CAAC,8BAA8B,EAAE,YAAM;IACxC,IAAMC,GAAG,GAAG;MACX,YAAY,EAAE,MAAM;MACpB,oBAAoB,EAAE,kBAAkB;MACxC,QAAQ,EAAE;QACT,QAAQ,EAAE;UACT,SAAS,EAAE,QAAQ;UACnB,cAAc,EAAE;QACjB;MACD,CAAC;MACD,SAAS,EAAE,SAAS;MACpB,QAAQ,EAAE;IACX,CAAC;IACDH,kBAAkB,CAACG,GAAG,CAAC,CAACC,MAAM,CAACC,IAAI,CAACC,KAAK,CAAC;MACzC,YAAY,EAAE;QACbC,IAAI,EAAE;MACP,CAAC;MACD,oBAAoB,EAAE;QACrBA,IAAI,EAAE;MACP,CAAC;MACD,QAAQ,EAAE;QACTA,IAAI,EAAE,QAAQ;QACdC,IAAI,EAAE;UACL,SAAS,EAAE;YACVD,IAAI,EAAE;UACP,CAAC;UACD,cAAc,EAAE;YACfA,IAAI,EAAE;UACP;QACD;MACD,CAAC;MACD,SAAS,EAAE;QACVA,IAAI,EAAE;MACP,CAAC;MACD,QAAQ,EAAE;QACTA,IAAI,EAAE;MACP;IACD,CAAC,CAAC;EACH,CAAC,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
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
|
-
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
|
-
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
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
-
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); }
|
|
7
|
-
import mapToObjects from './mapToObjects.js';
|
|
8
|
-
export default function mapToObjectsLegacyBehavior(data, schema) {
|
|
9
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
10
|
-
var includeNullValues = options.includeNullValues,
|
|
11
|
-
ignoreEmptyRows = options.ignoreEmptyRows,
|
|
12
|
-
isColumnOriented = options.isColumnOriented,
|
|
13
|
-
rowMap = options.rowMap;
|
|
14
|
-
var defaultConversionOptions = {
|
|
15
|
-
schemaPropertyValueForMissingColumn: undefined,
|
|
16
|
-
schemaPropertyValueForUndefinedCellValue: undefined,
|
|
17
|
-
schemaPropertyValueForNullCellValue: undefined,
|
|
18
|
-
schemaPropertyShouldSkipRequiredValidationForMissingColumn: function schemaPropertyShouldSkipRequiredValidationForMissingColumn(column, _ref) {
|
|
19
|
-
var path = _ref.path;
|
|
20
|
-
return false;
|
|
21
|
-
},
|
|
22
|
-
getEmptyObjectValue: function getEmptyObjectValue(object, _ref2) {
|
|
23
|
-
var path = _ref2.path;
|
|
24
|
-
return path ? undefined : null;
|
|
25
|
-
},
|
|
26
|
-
getEmptyArrayValue: function getEmptyArrayValue() {
|
|
27
|
-
return null;
|
|
28
|
-
},
|
|
29
|
-
arrayValueSeparator: ','
|
|
30
|
-
};
|
|
31
|
-
if (includeNullValues) {
|
|
32
|
-
defaultConversionOptions.schemaPropertyValueForMissingColumn = null;
|
|
33
|
-
defaultConversionOptions.schemaPropertyValueForUndefinedCellValue = null;
|
|
34
|
-
defaultConversionOptions.schemaPropertyValueForNullCellValue = null;
|
|
35
|
-
defaultConversionOptions.getEmptyObjectValue = function (object, _ref3) {
|
|
36
|
-
var path = _ref3.path;
|
|
37
|
-
return null;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
var result = mapToObjects(data, schema, _objectSpread(_objectSpread({}, defaultConversionOptions), {}, {
|
|
41
|
-
rowIndexMap: rowMap,
|
|
42
|
-
isColumnOriented: isColumnOriented
|
|
43
|
-
}));
|
|
44
|
-
if (ignoreEmptyRows !== false) {
|
|
45
|
-
result.rows = result.rows.filter(function (_) {
|
|
46
|
-
return _ !== defaultConversionOptions.getEmptyObjectValue(_, {
|
|
47
|
-
path: undefined
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=mapToObjects.legacy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapToObjects.legacy.js","names":["mapToObjects","mapToObjectsLegacyBehavior","data","schema","options","arguments","length","undefined","includeNullValues","ignoreEmptyRows","isColumnOriented","rowMap","defaultConversionOptions","schemaPropertyValueForMissingColumn","schemaPropertyValueForUndefinedCellValue","schemaPropertyValueForNullCellValue","schemaPropertyShouldSkipRequiredValidationForMissingColumn","column","_ref","path","getEmptyObjectValue","object","_ref2","getEmptyArrayValue","arrayValueSeparator","_ref3","result","_objectSpread","rowIndexMap","rows","filter","_"],"sources":["../../../source/read/schema/mapToObjects.legacy.js"],"sourcesContent":["import mapToObjects from './mapToObjects.js'\r\n\r\nexport default function mapToObjectsLegacyBehavior(data, schema, options = {}) {\r\n\tconst {\r\n\t\tincludeNullValues,\r\n\t\tignoreEmptyRows,\r\n\t\tisColumnOriented,\r\n\t\trowMap\r\n\t} = options\r\n\tconst defaultConversionOptions = {\r\n\t\tschemaPropertyValueForMissingColumn: undefined,\r\n\t\tschemaPropertyValueForUndefinedCellValue: undefined,\r\n\t\tschemaPropertyValueForNullCellValue: undefined,\r\n\t\tschemaPropertyShouldSkipRequiredValidationForMissingColumn: (column, { path }) => false,\r\n\t\tgetEmptyObjectValue: (object, { path }) => path ? undefined : null,\r\n\t\tgetEmptyArrayValue: () => null,\r\n\t\tarrayValueSeparator: ','\r\n\t}\r\n\tif (includeNullValues) {\r\n\t\tdefaultConversionOptions.schemaPropertyValueForMissingColumn = null\r\n\t\tdefaultConversionOptions.schemaPropertyValueForUndefinedCellValue = null\r\n\t\tdefaultConversionOptions.schemaPropertyValueForNullCellValue = null\r\n\t\tdefaultConversionOptions.getEmptyObjectValue = (object, { path }) => null\r\n\t}\r\n\tconst result = mapToObjects(data, schema, {\r\n\t\t...defaultConversionOptions,\r\n\t\trowIndexMap: rowMap,\r\n\t\tisColumnOriented\r\n\t})\r\n\tif (ignoreEmptyRows !== false) {\r\n\t\tresult.rows = result.rows.filter(_ => _ !== defaultConversionOptions.getEmptyObjectValue(_, { path: undefined }))\r\n\t}\r\n\treturn result\r\n}"],"mappings":";;;;;;AAAA,OAAOA,YAAY,MAAM,mBAAmB;AAE5C,eAAe,SAASC,0BAA0BA,CAACC,IAAI,EAAEC,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B,EAChB,CAAC;EACF,IAAID,eAAe,KAAK,KAAK,EAAE;IAC9BiB,MAAM,CAACG,IAAI,GAAGH,MAAM,CAACG,IAAI,CAACC,MAAM,CAAC,UAAAC,CAAC;MAAA,OAAIA,CAAC,KAAKnB,wBAAwB,CAACQ,mBAAmB,CAACW,CAAC,EAAE;QAAEZ,IAAI,EAAEZ;MAAU,CAAC,CAAC;IAAA,EAAC;EAClH;EACA,OAAOmB,MAAM;AACd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapToObjects.legacy.test.js","names":["mapToObjects","Integer","describe","it","_mapToObjects","A","prop","type","String","B","C","CA","CB","includeNullValues","rows","should","deep","equal","a","b","c","_mapToObjects2","COLUMN_1","required","COLUMN_2","COLUMN_4","COLUMN_5","errors","column2","column4","_mapToObjects3","column1","column5","_mapToObjects4","NUMBER","Number","STRING","error","row","column","value","undefined","string","_mapToObjects5","_mapToObjects6","NAMES","names","_mapToObjects7","INTEGER","length","reason","_mapToObjects8"],"sources":["../../../source/read/schema/mapToObjects.legacy.test.js"],"sourcesContent":["import mapToObjects from './mapToObjects.legacy.js'\r\n\r\nimport Integer from '../../types/Integer.js'\r\n\r\ndescribe('mapToObjects (legacy behavior)', () => {\r\n\tit('should include `null` values when `includeNullValues: true` option is passed', function() {\r\n\t\tconst { rows } = mapToObjects(\r\n\t\t\t[\r\n\t\t\t\t['A', 'B', 'CA', 'CB'],\r\n\t\t\t\t['a', 'b', 'ca', null],\r\n\t\t\t\t['a', null]\r\n\t\t\t],\r\n\t\t\t{\r\n\t\t\t\tA: {\r\n\t\t\t\t\tprop: 'a',\r\n\t\t\t\t\ttype: String\r\n\t\t\t\t},\r\n\t\t\t\tB: {\r\n\t\t\t\t\tprop: 'b',\r\n\t\t\t\t\ttype: String\r\n\t\t\t\t},\r\n\t\t\t\tC: {\r\n\t\t\t\t\tprop: 'c',\r\n \t\t\ttype: {\r\n\t\t\t\t\t\tCA: {\r\n\t\t\t\t\t\t\tprop: 'a',\r\n\t\t\t\t\t\t\ttype: String\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t\tCB: {\r\n\t\t\t\t\t\t\tprop: 'b',\r\n\t\t\t\t\t\t\ttype: String\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tincludeNullValues: true\r\n\t\t\t}\r\n\t\t)\r\n\r\n\t\trows.should.deep.equal([\r\n\t\t\t{ a: 'a', b: 'b', c: { a: 'ca', b: null } },\r\n\t\t\t{ a: 'a', b: null, c: null },\r\n\t\t])\r\n\t})\r\n\r\n\tit('should handle missing columns / empty cells (default) (`required: false`)', () => {\r\n\t\tconst { rows, errors } = mapToObjects([\r\n\t\t\t[\r\n\t\t\t\t'COLUMN_2',\r\n\t\t\t\t'COLUMN_3',\r\n\t\t\t\t'COLUMN_4'\r\n\t\t\t], [\r\n\t\t\t\t'12',\r\n\t\t\t\t'13',\r\n\t\t\t\t'14'\r\n\t\t\t], [\r\n\t\t\t\t'22',\r\n\t\t\t\t'23',\r\n\t\t\t\tnull\r\n\t\t\t]\r\n\t\t], {\r\n\t\t\tCOLUMN_1: {\r\n\t\t\t\tprop: 'column1',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t},\r\n\t\t\tCOLUMN_2: {\r\n\t\t\t\tprop: 'column2',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t},\r\n\t\t\tCOLUMN_4: {\r\n\t\t\t\tprop: 'column4',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t},\r\n\t\t\tCOLUMN_5: {\r\n\t\t\t\tprop: 'column5',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\terrors.should.deep.equal([])\r\n\r\n\t\t// Legacy behavior.\r\n\t\trows.should.deep.equal([{\r\n\t\t\tcolumn2: '12',\r\n\t\t\tcolumn4: '14'\r\n\t\t}, {\r\n\t\t\tcolumn2: '22'\r\n\t\t}])\r\n\t})\r\n\r\n\tit('should handle missing columns / empty cells (`includeNullValues: true`) (`required: false`)', () => {\r\n\t\tconst { rows, errors } = mapToObjects([\r\n\t\t\t[\r\n\t\t\t\t'COLUMN_2',\r\n\t\t\t\t'COLUMN_3',\r\n\t\t\t\t'COLUMN_4'\r\n\t\t\t], [\r\n\t\t\t\t'12',\r\n\t\t\t\t'13',\r\n\t\t\t\t'14'\r\n\t\t\t], [\r\n\t\t\t\t'22',\r\n\t\t\t\t'23',\r\n\t\t\t\tnull\r\n\t\t\t]\r\n\t\t], {\r\n\t\t\tCOLUMN_1: {\r\n\t\t\t\tprop: 'column1',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t},\r\n\t\t\tCOLUMN_2: {\r\n\t\t\t\tprop: 'column2',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t},\r\n\t\t\tCOLUMN_4: {\r\n\t\t\t\tprop: 'column4',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t},\r\n\t\t\tCOLUMN_5: {\r\n\t\t\t\tprop: 'column5',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t}\r\n\t\t}, {\r\n\t\t\tincludeNullValues: true\r\n\t\t})\r\n\r\n\t\terrors.should.deep.equal([])\r\n\r\n\t\trows.should.deep.equal([{\r\n\t\t\tcolumn1: null,\r\n\t\t\tcolumn2: '12',\r\n\t\t\tcolumn4: '14',\r\n\t\t\tcolumn5: null\r\n\t\t}, {\r\n\t\t\tcolumn1: null,\r\n\t\t\tcolumn2: '22',\r\n\t\t\tcolumn4: null,\r\n\t\t\tcolumn5: null\r\n\t\t}])\r\n\t})\r\n\r\n\tit('should require fields when cell value is empty', () => {\r\n\t\tconst { rows, errors } = mapToObjects([\r\n\t\t\t[\r\n\t\t\t\t'NUMBER',\r\n\t\t\t\t'STRING'\r\n\t\t\t],\r\n\t\t\t[\r\n\t\t\t\tnull,\r\n\t\t\t\t'abc'\r\n\t\t\t]\r\n\t\t], {\r\n\t\t\tNUMBER: {\r\n\t\t\t\tprop: 'number',\r\n\t\t\t\ttype: Number,\r\n\t\t\t\trequired: true\r\n\t\t\t},\r\n\t\t\tSTRING: {\r\n\t\t\t\tprop: 'string',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: true\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\terrors.should.deep.equal([{\r\n\t\t\terror: 'required',\r\n\t\t\trow: 2,\r\n\t\t\tcolumn: 'NUMBER',\r\n\t\t\ttype: Number,\r\n\t\t\t// value: null,\r\n\t\t\tvalue: undefined\r\n\t\t}])\r\n\r\n\t\trows.should.deep.equal([{\r\n\t\t\tstring: 'abc'\r\n\t\t}])\r\n\t})\r\n\r\n\tit('shouldn\\'t require fields when cell value is empty and object is empty too', () => {\r\n\t\tconst { rows, errors } = mapToObjects([\r\n\t\t\t[\r\n\t\t\t\t'NUMBER'\r\n\t\t\t],\r\n\t\t\t[\r\n\t\t\t\tnull\r\n\t\t\t]\r\n\t\t], {\r\n\t\t\tNUMBER: {\r\n\t\t\t\tprop: 'number',\r\n\t\t\t\ttype: Number,\r\n\t\t\t\trequired: true\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\trows.should.deep.equal([])\r\n\t})\r\n\r\n\tit('should parse arrays (and remove `null` empty objects from result)', () => {\r\n\t\tconst { rows, errors } = mapToObjects([\r\n\t\t\t[\r\n\t\t\t\t'NAMES'\r\n\t\t\t], [\r\n\t\t\t\t'Barack Obama, \"String, with, colons\", Donald Trump'\r\n\t\t\t], [\r\n\t\t\t\tnull\r\n\t\t\t]\r\n\t\t], {\r\n\t\t\tNAMES: {\r\n\t\t\t\tprop: 'names',\r\n\t\t\t\ttype: [String]\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\terrors.should.deep.equal([])\r\n\r\n\t\trows.should.deep.equal([{\r\n\t\t\tnames: ['Barack Obama', 'String, with, colons', 'Donald Trump']\r\n\t\t}])\r\n\t})\r\n\r\n\tit('should parse integers (and drop `null` errored objects from result)', () =>\r\n\t{\r\n\t\tconst { rows, errors } = mapToObjects([\r\n\t\t\t[\r\n\t\t\t\t'INTEGER'\r\n\t\t\t], [\r\n\t\t\t\t'1'\r\n\t\t\t], [\r\n\t\t\t\t'1.2'\r\n\t\t\t]\r\n\t\t], {\r\n\t\t\tINTEGER: {\r\n\t\t\t\tprop: 'value',\r\n\t\t\t\ttype: Integer\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\terrors.length.should.equal(1)\r\n\t\terrors[0].should.deep.equal({\r\n\t\t\terror: 'invalid',\r\n\t\t\treason: 'not_an_integer',\r\n\t\t\trow: 3,\r\n\t\t\tcolumn: 'INTEGER',\r\n\t\t\ttype: Integer,\r\n\t\t\tvalue: '1.2'\r\n\t\t})\r\n\r\n\t\trows.should.deep.equal([{\r\n\t\t\tvalue: 1\r\n\t\t}])\r\n\t})\r\n\r\n\tit('should not include `null` values by default (and set `null` for an \"empty\" object)', function() {\r\n\t\tconst { rows } = mapToObjects(\r\n\t\t\t[\r\n\t\t\t\t['A', 'B', 'CA', 'CB'],\r\n\t\t\t\t['a', 'b', 'ca', null],\r\n\t\t\t\t['a', null]\r\n\t\t\t],\r\n\t\t\t{\r\n\t\t\t\tA: {\r\n\t\t\t\t\tprop: 'a',\r\n\t\t\t\t\ttype: String\r\n\t\t\t\t},\r\n\t\t\t\tB: {\r\n\t\t\t\t\tprop: 'b',\r\n\t\t\t\t\ttype: String\r\n\t\t\t\t},\r\n\t\t\t\tC: {\r\n\t\t\t\t\tprop: 'c',\r\n \t\t\ttype: {\r\n\t\t\t\t\t\tCA: {\r\n\t\t\t\t\t\t\tprop: 'a',\r\n\t\t\t\t\t\t\ttype: String\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t\tCB: {\r\n\t\t\t\t\t\t\tprop: 'b',\r\n\t\t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AC,EACtB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,EACtB,CAAC,GAAG,EAAE,IAAI,CAAC,CACX,EACD;QACCK,CAAC,EAAE;UACFC,IAAI,EAAE,GAAG;UACTC,IAAI,EAAEC;QACP,CAAC;QACDC,CAAC,EAAE;UACFH,IAAI,EAAE,GAAG;UACTC,IAAI,EAAEC;QACP,CAAC;QACDE,CAAC,EAAE;UACFJ,IAAI,EAAE,GAAG;UACPC,IAAI,EAAE;YACPI,EAAE,EAAE;cACHL,IAAI,EAAE,GAAG;cACTC,IAAI,EAAEC;YACP,CAAC;YACDI,EAAE,EAAE;cACHN,IAAI,EAAE,GAAG;cACTC,IAAI,EAAEC;YACP;UACD;QACD;MACD,CACD,CAAC;MA7BOM,IAAI,GAAAqC,cAAA,CAAJrC,IAAI;IA+BZA,IAAI,CAACC,MAAM,CAACC,IAAI,CAACC,KAAK,CAAC,CACtB;MAAEC,CAAC,EAAE,GAAG;MAAEC,CAAC,EAAE,GAAG;MAAEC,CAAC,EAAE;QAAEF,CAAC,EAAE;MAAK;IAAE,CAAC,EAClC;MAAEA,CAAC,EAAE;IAAI,CAAC,CACV,CAAC;EACH,CAAC,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
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 = ["schemaPropertyValueForEmptyCell"];
|
|
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; }
|
|
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; }
|
|
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; }
|
|
6
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
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; }
|
|
10
|
-
// Renames some of the `react-excel-file` options to `mapToObjects()` options.
|
|
11
|
-
export default function mapToObjectsSpreadsheetBehavior(mapToObjects, data, schema) {
|
|
12
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
13
|
-
var schemaPropertyValueForEmptyCell = options.schemaPropertyValueForEmptyCell,
|
|
14
|
-
restOptions = _objectWithoutProperties(options, _excluded);
|
|
15
|
-
return mapToObjects(data, schema, _objectSpread(_objectSpread({}, restOptions), {}, {
|
|
16
|
-
schemaPropertyValueForNullCellValue: schemaPropertyValueForEmptyCell
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=mapToObjects.spreadsheet.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapToObjects.spreadsheet.js","names":["mapToObjectsSpreadsheetBehavior","mapToObjects","data","schema","options","arguments","length","undefined","schemaPropertyValueForEmptyCell","restOptions","_objectWithoutProperties","_excluded","_objectSpread","schemaPropertyValueForNullCellValue"],"sources":["../../../source/read/schema/mapToObjects.spreadsheet.js"],"sourcesContent":["// Renames some of the `react-excel-file` options to `mapToObjects()` options.\r\nexport default function mapToObjectsSpreadsheetBehavior(mapToObjects, data, schema, options = {}) {\r\n\tconst {\r\n\t\tschemaPropertyValueForEmptyCell,\r\n\t\t...restOptions\r\n\t} = options\r\n\treturn mapToObjects(data, schema, {\r\n\t\t...restOptions,\r\n\t\tschemaPropertyValueForNullCellValue: schemaPropertyValueForEmptyCell\r\n\t})\r\n}"],"mappings":";;;;;;;;;AAAA;AACA,eAAe,SAASA,+BAA+BA,CAACC,YAAY,EAAEC,IAAI,EAAEC,MAAM,EAAgB;EAAA,IAAdC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC/F,IACCG,+BAA+B,GAE5BJ,OAAO,CAFVI,+BAA+B;IAC5BC,WAAW,GAAAC,wBAAA,CACXN,OAAO,EAAAO,SAAA;EACX,OAAOV,YAAY,CAACC,IAAI,EAAEC,MAAM,EAAAS,aAAA,CAAAA,aAAA,KAC5BH,WAAW;IACdI,mCAAmC,EAAEL;EAA+B,EACpE,CAAC;AACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapToObjects.spreadsheet.test.js","names":["mapToObjects_","mapToObjectsSpreadsheetBehavior","mapToObjects","data","schema","options","describe","it","_mapToObjects","COLUMN_1","prop","type","String","required","COLUMN_2","COLUMN_4","COLUMN_5","schemaPropertyValueForMissingColumn","rows","errors","should","deep","equal","column1","column2","column4","column5","_mapToObjects2","schemaPropertyValueForEmptyCell"],"sources":["../../../source/read/schema/mapToObjects.spreadsheet.test.js"],"sourcesContent":["import mapToObjects_ from './mapToObjects.js'\r\nimport mapToObjectsSpreadsheetBehavior from './mapToObjects.spreadsheet.js'\r\n\r\nfunction mapToObjects(data, schema, options) {\r\n\treturn mapToObjectsSpreadsheetBehavior(mapToObjects_, data, schema, options)\r\n}\r\n\r\ndescribe('mapToObjects (spreadsheet behavior)', () => {\r\n\tit('should handle missing columns / empty cells (`schemaPropertyValueForMissingColumn: null`) (`required: false`)', () => {\r\n\t\tconst { rows, errors } = mapToObjects([\r\n\t\t\t[\r\n\t\t\t\t'COLUMN_2',\r\n\t\t\t\t'COLUMN_3',\r\n\t\t\t\t'COLUMN_4'\r\n\t\t\t], [\r\n\t\t\t\t'12',\r\n\t\t\t\t'13',\r\n\t\t\t\t'14'\r\n\t\t\t], [\r\n\t\t\t\t'22',\r\n\t\t\t\t'23',\r\n\t\t\t\tnull\r\n\t\t\t]\r\n\t\t], {\r\n\t\t\tCOLUMN_1: {\r\n\t\t\t\tprop: 'column1',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t},\r\n\t\t\tCOLUMN_2: {\r\n\t\t\t\tprop: 'column2',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t},\r\n\t\t\tCOLUMN_4: {\r\n\t\t\t\tprop: 'column4',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t},\r\n\t\t\tCOLUMN_5: {\r\n\t\t\t\tprop: 'column5',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t}\r\n\t\t}, {\r\n\t\t\tschemaPropertyValueForMissingColumn: null\r\n\t\t})\r\n\r\n\t\terrors.should.deep.equal([])\r\n\r\n\t\trows.should.deep.equal([{\r\n\t\t\tcolumn1: null,\r\n\t\t\tcolumn2: '12',\r\n\t\t\tcolumn4: '14',\r\n\t\t\tcolumn5: null\r\n\t\t}, {\r\n\t\t\tcolumn1: null,\r\n\t\t\tcolumn2: '22',\r\n\t\t\t// column4: undefined,\r\n\t\t\tcolumn5: null\r\n\t\t}])\r\n\t})\r\n\r\n\tit('should handle missing columns / empty cells (`schemaPropertyValueForEmptyCell: null`) (`required: false`)', () => {\r\n\t\tconst { rows, errors } = mapToObjects([\r\n\t\t\t[\r\n\t\t\t\t'COLUMN_2',\r\n\t\t\t\t'COLUMN_3',\r\n\t\t\t\t'COLUMN_4'\r\n\t\t\t], [\r\n\t\t\t\t'12',\r\n\t\t\t\t'13',\r\n\t\t\t\t'14'\r\n\t\t\t], [\r\n\t\t\t\t'22',\r\n\t\t\t\t'23',\r\n\t\t\t\tnull\r\n\t\t\t]\r\n\t\t], {\r\n\t\t\tCOLUMN_1: {\r\n\t\t\t\tprop: 'column1',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t},\r\n\t\t\tCOLUMN_2: {\r\n\t\t\t\tprop: 'column2',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t},\r\n\t\t\tCOLUMN_4: {\r\n\t\t\t\tprop: 'column4',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t},\r\n\t\t\tCOLUMN_5: {\r\n\t\t\t\tprop: 'column5',\r\n\t\t\t\ttype: String,\r\n\t\t\t\trequired: false\r\n\t\t\t}\r\n\t\t}, {\r\n\t\t\tschemaPropertyValueForEmptyCell: null\r\n\t\t})\r\n\r\n\t\terrors.should.deep.equal([])\r\n\r\n\t\trows.should.deep.equal([{\r\n\t\t\t// column1: undefined,\r\n\t\t\tcolumn2: '12',\r\n\t\t\tcolumn4: '14',\r\n\t\t\t// column5: undefined\r\n\t\t}, {\r\n\t\t\t// column1: undefined,\r\n\t\t\tcolumn2: '22',\r\n\t\t\tcolumn4: null,\r\n\t\t\t// column5: undefined\r\n\t\t}])\r\n\t})\r\n})\r\n"],"mappings":"AAAA,OAAOA,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,+BAA+B,MAAM,+BAA+B;AAE3E,SAASC,YAAYA,CAACC,IAAI,EAAEC,MAAM,EAAEC,OAAO,EAAE;EAC5C,OAAOJ,+BAA+B,CAACD,aAAa,EAAEG,IAAI,EAAEC,MAAM,EAAEC,OAAO,CAAC;AAC7E;AAEAC,QAAQ,CAAC,qCAAqC,EAAE,YAAM;EACrDC,EAAE,CAAC,+GAA+G,EAAE,YAAM;IACzH,IAAAC,aAAA,GAAyBN,YAAY,CAAC,CACrC,CACC,UAAU,EACV,UAAU,EACV,UAAU,CACV,EAAE,CACF,IAAI,EACJ,IAAI,EACJ,IAAI,CACJ,EAAE,CACF,IAAI,EACJ,IAAI,EACJ,IAAI,CACJ,CACD,EAAE;QACFO,QAAQ,EAAE;UACTC,IAAI,EAAE,SAAS;UACfC,IAAI,EAAEC,MAAM;UACZC,QAAQ,EAAE;QACX,CAAC;QACDC,QAAQ,EAAE;UACTJ,IAAI,EAAE,SAAS;UACfC,IAAI,EAAEC,MAAM;UACZC,QAAQ,EAAE;QACX,CAAC;QACDE,QAAQ,EAAE;UACTL,IAAI,EAAE,SAAS;UACfC,IAAI,EAAEC,MAAM;UACZC,QAAQ,EAAE;QACX,CAAC;QACDG,QAAQ,EAAE;UACTN,IAAI,EAAE,SAAS;UACfC,IAAI,EAAEC,MAAM;UACZC,QAAQ,EAAE;QACX;MACD,CAAC,EAAE;QACFI,mCAAmC,EAAE;MACtC,CAAC,CAAC;MArCMC,IAAI,GAAAV,aAAA,CAAJU,IAAI;MAAEC,MAAM,GAAAX,aAAA,CAANW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KAAK,CAAC,CAAC;MACvB;MACAE,OAAO,EAAE,IAAI;MACbC,OAAO,EAAE;MACT;IACD,CAAC,EAAE;MACF;MACAD,OAAO,EAAE,IAAI;MACbC,OAAO,EAAE;MACT;IACD,CAAC,CAAC,CAAC;EACJ,CAAC,CAAC;AACH,CAAC,CAAC"}
|
package/schema/index.cjs
DELETED
package/schema/index.cjs.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// This file is deprecated.
|
|
2
|
-
// It's the same as `index.cjs`, just with an added `*.js` extension.
|
|
3
|
-
// It fixes the issue when some software doesn't see files with `*.cjs` file extensions
|
|
4
|
-
// when used as the `main` property value in `package.json`.
|
|
5
|
-
|
|
6
|
-
exports = module.exports = require('../commonjs/read/schema/mapToObjects.legacy.js').default
|
|
7
|
-
exports['default'] = require('../commonjs/read/schema/mapToObjects.legacy.js').default
|
package/schema/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Row,
|
|
3
|
-
Schema
|
|
4
|
-
} from '../types.d.js';
|
|
5
|
-
|
|
6
|
-
export default function mapWithLegacyBehavior<T>(data: Row[], schema: Schema<T>, options?: {
|
|
7
|
-
ignoreEmptyRows?: boolean,
|
|
8
|
-
includeNullValues?: boolean,
|
|
9
|
-
isColumnOriented?: boolean,
|
|
10
|
-
rowMap?: Record<string, number>
|
|
11
|
-
}): T[];
|
package/schema/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as default } from '../modules/read/schema/mapToObjects.legacy.js'
|
package/schema/package.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"private": true,
|
|
3
|
-
"name": "read-excel-file/schema",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"main": "index.cjs",
|
|
6
|
-
"module": "index.js",
|
|
7
|
-
"types": "./index.d.ts",
|
|
8
|
-
"type": "module",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./index.d.ts",
|
|
12
|
-
"import": "./index.js",
|
|
13
|
-
"require": "./index.cjs"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"sideEffects": false
|
|
17
|
-
}
|
package/website/index.html
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<title>read-excel-file</title>
|
|
4
|
-
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
|
|
7
|
-
<script src="./read-excel-file.min.js"></script>
|
|
8
|
-
|
|
9
|
-
<script src="./lib/promise-polyfill.min.js"></script>
|
|
10
|
-
|
|
11
|
-
<script src="./lib/prism.js"></script>
|
|
12
|
-
|
|
13
|
-
<style>
|
|
14
|
-
body
|
|
15
|
-
{
|
|
16
|
-
margin : 20px;
|
|
17
|
-
font-family : Arial, Helvetica;
|
|
18
|
-
background: #434343;
|
|
19
|
-
color: #dddddd;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
#input
|
|
23
|
-
{
|
|
24
|
-
margin-top : 20px;
|
|
25
|
-
margin-bottom : 10px;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
#result-table table
|
|
30
|
-
{
|
|
31
|
-
width : 100%;
|
|
32
|
-
border-collapse : collapse;
|
|
33
|
-
margin-top : 2.5em;
|
|
34
|
-
margin-bottom : 2.5em;
|
|
35
|
-
font-size : 12px;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
#result-table table td
|
|
39
|
-
{
|
|
40
|
-
border : 1px solid black;
|
|
41
|
-
padding : 0.5em;
|
|
42
|
-
|
|
43
|
-
text-overflow : ellipsis;
|
|
44
|
-
overflow : hidden;
|
|
45
|
-
max-width : 10em;
|
|
46
|
-
white-space : nowrap;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
#main-link
|
|
50
|
-
{
|
|
51
|
-
display : block;
|
|
52
|
-
font-size : 24px;
|
|
53
|
-
color : #fd8900;
|
|
54
|
-
font-family : monospace;
|
|
55
|
-
text-decoration : none;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
a
|
|
59
|
-
{
|
|
60
|
-
color: #fd8900;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.file-upload
|
|
64
|
-
{
|
|
65
|
-
text-transform: uppercase;
|
|
66
|
-
letter-spacing: 1px;
|
|
67
|
-
font-size: 0.75rem;
|
|
68
|
-
color: #fd8900;
|
|
69
|
-
border: 1px solid currentColor;
|
|
70
|
-
border-radius: 4px;
|
|
71
|
-
display: inline-block;
|
|
72
|
-
padding: 6px 12px;
|
|
73
|
-
cursor: pointer;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.file-upload:active
|
|
77
|
-
{
|
|
78
|
-
color: black;
|
|
79
|
-
font-weight: bolder;
|
|
80
|
-
background-color: #fd8900;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
input[type="file"]
|
|
84
|
-
{
|
|
85
|
-
display: none;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
#result,
|
|
89
|
-
#error,
|
|
90
|
-
#loading
|
|
91
|
-
{
|
|
92
|
-
display: none;
|
|
93
|
-
margin-top: 2.5rem;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
#error
|
|
97
|
-
{
|
|
98
|
-
color: #ff7979;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/* Loading Indicator */
|
|
102
|
-
/* https://loading.io/css/ */
|
|
103
|
-
.lds-ellipsis {
|
|
104
|
-
display: inline-block;
|
|
105
|
-
position: relative;
|
|
106
|
-
width: 40px;
|
|
107
|
-
height: 40px;
|
|
108
|
-
}
|
|
109
|
-
.lds-ellipsis div {
|
|
110
|
-
position: absolute;
|
|
111
|
-
top: 16px;
|
|
112
|
-
width: 7px;
|
|
113
|
-
height: 7px;
|
|
114
|
-
border-radius: 50%;
|
|
115
|
-
background: #fff;
|
|
116
|
-
animation-timing-function: cubic-bezier(0, 1, 1, 0);
|
|
117
|
-
}
|
|
118
|
-
.lds-ellipsis div:nth-child(1) {
|
|
119
|
-
left: 4px;
|
|
120
|
-
animation: lds-ellipsis1 0.6s infinite;
|
|
121
|
-
}
|
|
122
|
-
.lds-ellipsis div:nth-child(2) {
|
|
123
|
-
left: 4px;
|
|
124
|
-
animation: lds-ellipsis2 0.6s infinite;
|
|
125
|
-
}
|
|
126
|
-
.lds-ellipsis div:nth-child(3) {
|
|
127
|
-
left: 16px;
|
|
128
|
-
animation: lds-ellipsis2 0.6s infinite;
|
|
129
|
-
}
|
|
130
|
-
.lds-ellipsis div:nth-child(4) {
|
|
131
|
-
left: 28px;
|
|
132
|
-
animation: lds-ellipsis3 0.6s infinite;
|
|
133
|
-
}
|
|
134
|
-
@keyframes lds-ellipsis1 {
|
|
135
|
-
0% {
|
|
136
|
-
transform: scale(0);
|
|
137
|
-
}
|
|
138
|
-
100% {
|
|
139
|
-
transform: scale(1);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
@keyframes lds-ellipsis3 {
|
|
143
|
-
0% {
|
|
144
|
-
transform: scale(1);
|
|
145
|
-
}
|
|
146
|
-
100% {
|
|
147
|
-
transform: scale(0);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
@keyframes lds-ellipsis2 {
|
|
151
|
-
0% {
|
|
152
|
-
transform: translate(0, 0);
|
|
153
|
-
}
|
|
154
|
-
100% {
|
|
155
|
-
transform: translate(12px, 0);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
</style>
|
|
159
|
-
|
|
160
|
-
<link href="lib/prism.css" rel="stylesheet" />
|
|
161
|
-
</head>
|
|
162
|
-
|
|
163
|
-
<body>
|
|
164
|
-
<a id="main-link" href="https://gitlab.com/catamphetamine/read-excel-file">
|
|
165
|
-
read-excel-file
|
|
166
|
-
</a>
|
|
167
|
-
|
|
168
|
-
<br/>
|
|
169
|
-
|
|
170
|
-
<div style="line-height: 1.35em">
|
|
171
|
-
Read small to medium <code>*.xlsx</code> files in a browser or Node.js.
|
|
172
|
-
</div>
|
|
173
|
-
<div style="line-height: 1.35em; margin-top: 0.35em">
|
|
174
|
-
Parse file data to an array of JSON objects using a schema.
|
|
175
|
-
</div>
|
|
176
|
-
|
|
177
|
-
<br/>
|
|
178
|
-
|
|
179
|
-
<label for="input" class="file-upload">
|
|
180
|
-
Click here to choose an <code>*.xlsx</code> file
|
|
181
|
-
</label>
|
|
182
|
-
<input type="file" id="input" />
|
|
183
|
-
|
|
184
|
-
<div id="loading">
|
|
185
|
-
<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>
|
|
186
|
-
</div>
|
|
187
|
-
|
|
188
|
-
<div id="error">
|
|
189
|
-
</div>
|
|
190
|
-
|
|
191
|
-
<div id="result">
|
|
192
|
-
<h2>
|
|
193
|
-
File Data
|
|
194
|
-
</h2>
|
|
195
|
-
|
|
196
|
-
<div style="margin-top: 1rem">
|
|
197
|
-
Also supports parsing file data to an array of JSON objects using a schema. <a target="_blank" href="https://gitlab.com/catamphetamine/read-excel-file#json" style="text-decoration: none">Read more</a>
|
|
198
|
-
</div>
|
|
199
|
-
|
|
200
|
-
<br/>
|
|
201
|
-
|
|
202
|
-
<div id="result-table"></div>
|
|
203
|
-
|
|
204
|
-
<pre><code class="language-js" id="result-data"></code></pre>
|
|
205
|
-
</div>
|
|
206
|
-
|
|
207
|
-
<script>
|
|
208
|
-
var input = document.getElementById('input')
|
|
209
|
-
|
|
210
|
-
input.addEventListener('change', function() {
|
|
211
|
-
document.getElementById('result').style.display = 'none'
|
|
212
|
-
document.getElementById('error').style.display = 'none'
|
|
213
|
-
document.getElementById('loading').style.display = 'block'
|
|
214
|
-
|
|
215
|
-
if (!input.files[0]) {
|
|
216
|
-
return document.getElementById('loading').style.display = 'none'
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
readXlsxFile(input.files[0]).then(function(data) {
|
|
220
|
-
// `data` is an array of rows
|
|
221
|
-
// each row being an array of cells.
|
|
222
|
-
// document.getElementById('result').innerText = JSON.stringify(data, null, 2)
|
|
223
|
-
document.getElementById('loading').style.display = 'none'
|
|
224
|
-
document.getElementById('result').style.display = 'block'
|
|
225
|
-
document.getElementById('result-data').innerHTML = Prism.highlight(
|
|
226
|
-
JSON.stringify(data, null, 2),
|
|
227
|
-
Prism.languages.javascript,
|
|
228
|
-
'javascript'
|
|
229
|
-
)
|
|
230
|
-
|
|
231
|
-
// Applying `innerHTML` hangs the browser when there're a lot of rows/columns.
|
|
232
|
-
// For example, for a file having 2000 rows and 20 columns on a modern
|
|
233
|
-
// mid-tier CPU it parses the file (using a "schema") for 3 seconds
|
|
234
|
-
// (blocking) with 100% single CPU core usage.
|
|
235
|
-
// Then applying `innerHTML` hangs the browser.
|
|
236
|
-
|
|
237
|
-
// document.getElementById('result-table').innerHTML =
|
|
238
|
-
// '<table>' +
|
|
239
|
-
// '<tbody>' +
|
|
240
|
-
// data.map(function (row) {
|
|
241
|
-
// return '<tr>' +
|
|
242
|
-
// row.map(function (cell) {
|
|
243
|
-
// return '<td>' +
|
|
244
|
-
// (cell === null ? '' : cell) +
|
|
245
|
-
// '</td>'
|
|
246
|
-
// }).join('') +
|
|
247
|
-
// '</tr>'
|
|
248
|
-
// }).join('') +
|
|
249
|
-
// '</tbody>' +
|
|
250
|
-
// '</table>'
|
|
251
|
-
}, function (error) {
|
|
252
|
-
console.error(error)
|
|
253
|
-
// alert("Error while parsing Excel file. See console output for the error stack trace.")
|
|
254
|
-
document.getElementById('loading').style.display = 'none'
|
|
255
|
-
document.getElementById('error').style.display = 'block'
|
|
256
|
-
document.getElementById('error').innerText = error.message
|
|
257
|
-
})
|
|
258
|
-
})
|
|
259
|
-
</script>
|
|
260
|
-
</body>
|
|
261
|
-
</html>
|
package/website/lib/prism.css
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/* PrismJS 1.23.0
|
|
2
|
-
https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript */
|
|
3
|
-
/**
|
|
4
|
-
* prism.js tomorrow night eighties for JavaScript, CoffeeScript, CSS and HTML
|
|
5
|
-
* Based on https://github.com/chriskempson/tomorrow-theme
|
|
6
|
-
* @author Rose Pritchard
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
code[class*="language-"],
|
|
10
|
-
pre[class*="language-"] {
|
|
11
|
-
color: #ccc;
|
|
12
|
-
background: none;
|
|
13
|
-
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
14
|
-
font-size: 1em;
|
|
15
|
-
text-align: left;
|
|
16
|
-
white-space: pre;
|
|
17
|
-
word-spacing: normal;
|
|
18
|
-
word-break: normal;
|
|
19
|
-
word-wrap: normal;
|
|
20
|
-
line-height: 1.5;
|
|
21
|
-
|
|
22
|
-
-moz-tab-size: 4;
|
|
23
|
-
-o-tab-size: 4;
|
|
24
|
-
tab-size: 4;
|
|
25
|
-
|
|
26
|
-
-webkit-hyphens: none;
|
|
27
|
-
-moz-hyphens: none;
|
|
28
|
-
-ms-hyphens: none;
|
|
29
|
-
hyphens: none;
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/* Code blocks */
|
|
34
|
-
pre[class*="language-"] {
|
|
35
|
-
padding: 1em;
|
|
36
|
-
margin: .5em 0;
|
|
37
|
-
overflow: auto;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
:not(pre) > code[class*="language-"],
|
|
41
|
-
pre[class*="language-"] {
|
|
42
|
-
background: #2d2d2d;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/* Inline code */
|
|
46
|
-
:not(pre) > code[class*="language-"] {
|
|
47
|
-
padding: .1em;
|
|
48
|
-
border-radius: .3em;
|
|
49
|
-
white-space: normal;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.token.comment,
|
|
53
|
-
.token.block-comment,
|
|
54
|
-
.token.prolog,
|
|
55
|
-
.token.doctype,
|
|
56
|
-
.token.cdata {
|
|
57
|
-
color: #999;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.token.punctuation {
|
|
61
|
-
color: #ccc;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.token.tag,
|
|
65
|
-
.token.attr-name,
|
|
66
|
-
.token.namespace,
|
|
67
|
-
.token.deleted {
|
|
68
|
-
color: #e2777a;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.token.function-name {
|
|
72
|
-
color: #6196cc;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.token.boolean,
|
|
76
|
-
.token.number,
|
|
77
|
-
.token.function {
|
|
78
|
-
color: #f08d49;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.token.property,
|
|
82
|
-
.token.class-name,
|
|
83
|
-
.token.constant,
|
|
84
|
-
.token.symbol {
|
|
85
|
-
color: #f8c555;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.token.selector,
|
|
89
|
-
.token.important,
|
|
90
|
-
.token.atrule,
|
|
91
|
-
.token.keyword,
|
|
92
|
-
.token.builtin {
|
|
93
|
-
color: #cc99cd;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.token.string,
|
|
97
|
-
.token.char,
|
|
98
|
-
.token.attr-value,
|
|
99
|
-
.token.regex,
|
|
100
|
-
.token.variable {
|
|
101
|
-
color: #7ec699;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.token.operator,
|
|
105
|
-
.token.entity,
|
|
106
|
-
.token.url {
|
|
107
|
-
color: #67cdcc;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.token.important,
|
|
111
|
-
.token.bold {
|
|
112
|
-
font-weight: bold;
|
|
113
|
-
}
|
|
114
|
-
.token.italic {
|
|
115
|
-
font-style: italic;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.token.entity {
|
|
119
|
-
cursor: help;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.token.inserted {
|
|
123
|
-
color: green;
|
|
124
|
-
}
|
|
125
|
-
|