read-excel-file 5.7.1 → 5.8.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 +10 -0
- package/README.md +45 -19
- package/bundle/read-excel-file.min.js +1 -1
- package/bundle/read-excel-file.min.js.map +1 -1
- package/commonjs/read/coordinates.js +7 -10
- package/commonjs/read/coordinates.js.map +1 -1
- package/commonjs/read/dropEmptyColumns.js +6 -18
- package/commonjs/read/dropEmptyColumns.js.map +1 -1
- package/commonjs/read/dropEmptyColumns.test.js.map +1 -1
- package/commonjs/read/dropEmptyRows.js +11 -23
- package/commonjs/read/dropEmptyRows.js.map +1 -1
- package/commonjs/read/dropEmptyRows.test.js.map +1 -1
- package/commonjs/read/getData.js +31 -43
- package/commonjs/read/getData.js.map +1 -1
- package/commonjs/read/isDateTimestamp.js +51 -40
- package/commonjs/read/isDateTimestamp.js.map +1 -1
- package/commonjs/read/parseCell.js +3 -10
- package/commonjs/read/parseCell.js.map +1 -1
- package/commonjs/read/parseCellValue.js +28 -59
- package/commonjs/read/parseCellValue.js.map +1 -1
- package/commonjs/read/parseCells.js +3 -7
- package/commonjs/read/parseCells.js.map +1 -1
- package/commonjs/read/parseDate.js +5 -5
- package/commonjs/read/parseDate.js.map +1 -1
- package/commonjs/read/parseDate.test.js.map +1 -1
- package/commonjs/read/parseDimensions.js +6 -18
- package/commonjs/read/parseDimensions.js.map +1 -1
- package/commonjs/read/parseFilePaths.js +4 -11
- package/commonjs/read/parseFilePaths.js.map +1 -1
- package/commonjs/read/parseProperties.js +6 -8
- package/commonjs/read/parseProperties.js.map +1 -1
- package/commonjs/read/parseSharedStrings.js +0 -3
- package/commonjs/read/parseSharedStrings.js.map +1 -1
- package/commonjs/read/parseSheet.js +3 -7
- package/commonjs/read/parseSheet.js.map +1 -1
- package/commonjs/read/parseStyles.js +13 -21
- package/commonjs/read/parseStyles.js.map +1 -1
- package/commonjs/read/readSheetNamesBrowser.js +0 -3
- package/commonjs/read/readSheetNamesBrowser.js.map +1 -1
- package/commonjs/read/readSheetNamesNode.js +0 -3
- package/commonjs/read/readSheetNamesNode.js.map +1 -1
- package/commonjs/read/readSheetNamesNode.test.js.map +1 -1
- package/commonjs/read/readSheetNamesWebWorker.js +0 -3
- package/commonjs/read/readSheetNamesWebWorker.js.map +1 -1
- package/commonjs/read/readXlsx.js +34 -42
- package/commonjs/read/readXlsx.js.map +1 -1
- package/commonjs/read/readXlsxFileBrowser.js +0 -5
- package/commonjs/read/readXlsxFileBrowser.js.map +1 -1
- package/commonjs/read/readXlsxFileContents.js +12 -22
- package/commonjs/read/readXlsxFileContents.js.map +1 -1
- package/commonjs/read/readXlsxFileNode.js +0 -5
- package/commonjs/read/readXlsxFileNode.js.map +1 -1
- package/commonjs/read/readXlsxFileNode.test.js.map +1 -1
- package/commonjs/read/readXlsxFileWebWorker.js +0 -5
- package/commonjs/read/readXlsxFileWebWorker.js.map +1 -1
- package/commonjs/read/schema/convertMapToSchema.js +1 -8
- package/commonjs/read/schema/convertMapToSchema.js.map +1 -1
- package/commonjs/read/schema/convertMapToSchema.test.js.map +1 -1
- package/commonjs/read/schema/convertToJson.js +143 -142
- package/commonjs/read/schema/convertToJson.js.map +1 -1
- package/commonjs/read/schema/convertToJson.legacy.js +60 -0
- package/commonjs/read/schema/convertToJson.legacy.js.map +1 -0
- package/commonjs/read/schema/convertToJson.legacy.test.js.map +1 -0
- package/commonjs/read/schema/convertToJson.spreadsheet.js +25 -0
- package/commonjs/read/schema/convertToJson.spreadsheet.js.map +1 -0
- package/commonjs/read/schema/convertToJson.spreadsheet.test.js.map +1 -0
- package/commonjs/read/schema/convertToJson.test.js.map +1 -1
- package/commonjs/read/unpackXlsxFileBrowser.js +3 -9
- package/commonjs/read/unpackXlsxFileBrowser.js.map +1 -1
- package/commonjs/read/unpackXlsxFileNode.js +9 -15
- package/commonjs/read/unpackXlsxFileNode.js.map +1 -1
- package/commonjs/types/Boolean.js +0 -4
- package/commonjs/types/Boolean.js.map +1 -1
- package/commonjs/types/Date.js +0 -12
- package/commonjs/types/Date.js.map +1 -1
- package/commonjs/types/Email.js +0 -7
- package/commonjs/types/Email.js.map +1 -1
- package/commonjs/types/Email.test.js.map +1 -1
- package/commonjs/types/Integer.js +0 -7
- package/commonjs/types/Integer.js.map +1 -1
- package/commonjs/types/Integer.test.js.map +1 -1
- package/commonjs/types/InvalidError.js +8 -28
- package/commonjs/types/InvalidError.js.map +1 -1
- package/commonjs/types/Number.js +2 -10
- package/commonjs/types/Number.js.map +1 -1
- package/commonjs/types/String.js +4 -11
- package/commonjs/types/String.js.map +1 -1
- package/commonjs/types/URL.js +5 -8
- package/commonjs/types/URL.js.map +1 -1
- package/commonjs/types/URL.test.js.map +1 -1
- package/commonjs/xml/dom.js +6 -25
- package/commonjs/xml/dom.js.map +1 -1
- package/commonjs/xml/xlsx.js +1 -24
- package/commonjs/xml/xlsx.js.map +1 -1
- package/commonjs/xml/xml.js +1 -4
- package/commonjs/xml/xml.js.map +1 -1
- package/commonjs/xml/xmlBrowser.js +1 -2
- package/commonjs/xml/xmlBrowser.js.map +1 -1
- package/commonjs/xml/xpath/xlsx-xpath.js +3 -16
- package/commonjs/xml/xpath/xlsx-xpath.js.map +1 -1
- package/commonjs/xml/xpath/xpathBrowser.js +3 -5
- package/commonjs/xml/xpath/xpathBrowser.js.map +1 -1
- package/commonjs/xml/xpath/xpathNode.js +1 -5
- package/commonjs/xml/xpath/xpathNode.js.map +1 -1
- package/map/index.cjs +2 -0
- package/map/index.cjs.js +7 -0
- package/map/index.d.ts +11 -0
- package/map/index.js +1 -0
- package/map/package.json +17 -0
- package/modules/read/coordinates.js +7 -8
- package/modules/read/coordinates.js.map +1 -1
- package/modules/read/dropEmptyColumns.js +6 -17
- package/modules/read/dropEmptyColumns.js.map +1 -1
- package/modules/read/dropEmptyColumns.test.js.map +1 -1
- package/modules/read/dropEmptyRows.js +11 -22
- package/modules/read/dropEmptyRows.js.map +1 -1
- package/modules/read/dropEmptyRows.test.js.map +1 -1
- package/modules/read/getData.js +31 -39
- package/modules/read/getData.js.map +1 -1
- package/modules/read/isDateTimestamp.js +52 -39
- package/modules/read/isDateTimestamp.js.map +1 -1
- package/modules/read/parseCell.js +6 -6
- package/modules/read/parseCell.js.map +1 -1
- package/modules/read/parseCellValue.js +30 -55
- package/modules/read/parseCellValue.js.map +1 -1
- package/modules/read/parseCells.js +3 -3
- package/modules/read/parseCells.js.map +1 -1
- package/modules/read/parseDate.js +5 -4
- package/modules/read/parseDate.js.map +1 -1
- package/modules/read/parseDate.test.js.map +1 -1
- package/modules/read/parseDimensions.js +9 -17
- package/modules/read/parseDimensions.js.map +1 -1
- package/modules/read/parseFilePaths.js +5 -10
- package/modules/read/parseFilePaths.js.map +1 -1
- package/modules/read/parseProperties.js +8 -7
- package/modules/read/parseProperties.js.map +1 -1
- package/modules/read/parseSharedStrings.js +0 -1
- package/modules/read/parseSharedStrings.js.map +1 -1
- package/modules/read/parseSheet.js +3 -2
- package/modules/read/parseSheet.js.map +1 -1
- package/modules/read/parseStyles.js +16 -21
- package/modules/read/parseStyles.js.map +1 -1
- package/modules/read/readSheetNamesBrowser.js +1 -1
- package/modules/read/readSheetNamesBrowser.js.map +1 -1
- package/modules/read/readSheetNamesNode.js +1 -1
- package/modules/read/readSheetNamesNode.js.map +1 -1
- package/modules/read/readSheetNamesNode.test.js.map +1 -1
- package/modules/read/readSheetNamesWebWorker.js +1 -1
- package/modules/read/readSheetNamesWebWorker.js.map +1 -1
- package/modules/read/readXlsx.js +37 -35
- package/modules/read/readXlsx.js.map +1 -1
- package/modules/read/readXlsxFileBrowser.js +1 -1
- package/modules/read/readXlsxFileBrowser.js.map +1 -1
- package/modules/read/readXlsxFileContents.js +12 -17
- package/modules/read/readXlsxFileContents.js.map +1 -1
- package/modules/read/readXlsxFileNode.js +1 -1
- package/modules/read/readXlsxFileNode.js.map +1 -1
- package/modules/read/readXlsxFileNode.test.js.map +1 -1
- package/modules/read/readXlsxFileWebWorker.js +1 -1
- package/modules/read/readXlsxFileWebWorker.js.map +1 -1
- package/modules/read/schema/convertMapToSchema.js +1 -7
- package/modules/read/schema/convertMapToSchema.js.map +1 -1
- package/modules/read/schema/convertMapToSchema.test.js.map +1 -1
- package/modules/read/schema/convertToJson.js +143 -133
- package/modules/read/schema/convertToJson.js.map +1 -1
- package/modules/read/schema/convertToJson.legacy.js +53 -0
- package/modules/read/schema/convertToJson.legacy.js.map +1 -0
- package/modules/read/schema/convertToJson.legacy.test.js.map +1 -0
- package/modules/read/schema/convertToJson.spreadsheet.js +19 -0
- package/modules/read/schema/convertToJson.spreadsheet.js.map +1 -0
- package/modules/read/schema/convertToJson.spreadsheet.test.js.map +1 -0
- package/modules/read/schema/convertToJson.test.js.map +1 -1
- package/modules/read/unpackXlsxFileBrowser.js +4 -7
- package/modules/read/unpackXlsxFileBrowser.js.map +1 -1
- package/modules/read/unpackXlsxFileNode.js +9 -7
- package/modules/read/unpackXlsxFileNode.js.map +1 -1
- package/modules/types/Boolean.js +0 -1
- package/modules/types/Boolean.js.map +1 -1
- package/modules/types/Date.js +0 -8
- package/modules/types/Date.js.map +1 -1
- package/modules/types/Email.js +0 -2
- package/modules/types/Email.js.map +1 -1
- package/modules/types/Email.test.js.map +1 -1
- package/modules/types/Integer.js +0 -2
- package/modules/types/Integer.js.map +1 -1
- package/modules/types/Integer.test.js.map +1 -1
- package/modules/types/InvalidError.js +7 -25
- package/modules/types/InvalidError.js.map +1 -1
- package/modules/types/Number.js +2 -7
- package/modules/types/Number.js.map +1 -1
- package/modules/types/String.js +4 -8
- package/modules/types/String.js.map +1 -1
- package/modules/types/URL.js +5 -4
- package/modules/types/URL.js.map +1 -1
- package/modules/types/URL.test.js.map +1 -1
- package/modules/xml/dom.js +6 -18
- package/modules/xml/dom.js.map +1 -1
- package/modules/xml/xlsx.js +4 -13
- package/modules/xml/xlsx.js.map +1 -1
- package/modules/xml/xml.js.map +1 -1
- package/modules/xml/xmlBrowser.js.map +1 -1
- package/modules/xml/xpath/xlsx-xpath.js +2 -1
- package/modules/xml/xpath/xlsx-xpath.js.map +1 -1
- package/modules/xml/xpath/xpathBrowser.js +3 -4
- package/modules/xml/xpath/xpathBrowser.js.map +1 -1
- package/modules/xml/xpath/xpathNode.js +1 -0
- package/modules/xml/xpath/xpathNode.js.map +1 -1
- package/package.json +6 -1
- package/schema/index.cjs +2 -2
- package/schema/index.cjs.js +2 -2
- package/schema/index.d.ts +7 -2
- package/schema/index.js +1 -1
- package/types.d.ts +25 -2
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
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); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = unpackXlsxFile;
|
|
9
|
-
|
|
10
8
|
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
-
|
|
12
9
|
var _stream = _interopRequireWildcard(require("stream"));
|
|
13
|
-
|
|
14
10
|
var _unzipper = _interopRequireDefault(require("unzipper"));
|
|
15
|
-
|
|
16
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
-
|
|
18
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
-
|
|
22
14
|
/**
|
|
23
15
|
* Reads XLSX file in Node.js.
|
|
24
16
|
* @param {(string|Stream)} input - A Node.js readable stream or a path to a file.
|
|
@@ -32,15 +24,17 @@ function unpackXlsxFile(input) {
|
|
|
32
24
|
var stream = input instanceof _stream["default"] ? input : input instanceof Buffer ? _stream.Readable.from(input) : _fs["default"].createReadStream(input);
|
|
33
25
|
return new Promise(function (resolve, reject) {
|
|
34
26
|
var entryPromises = [];
|
|
35
|
-
stream
|
|
36
|
-
|
|
27
|
+
stream
|
|
28
|
+
// This first "error" listener is for the original stream errors.
|
|
29
|
+
.on('error', reject).pipe(_unzipper["default"].Parse())
|
|
30
|
+
// This second "error" listener is for the unzip stream errors.
|
|
37
31
|
.on('error', reject).on('close', function () {
|
|
38
32
|
return Promise.all(entryPromises).then(function () {
|
|
39
33
|
return resolve(entries);
|
|
40
34
|
});
|
|
41
35
|
}).on('entry', function (entry) {
|
|
42
|
-
var contents = '';
|
|
43
|
-
|
|
36
|
+
var contents = '';
|
|
37
|
+
// To ignore an entry: `entry.autodrain()`.
|
|
44
38
|
entryPromises.push(new Promise(function (resolve) {
|
|
45
39
|
// It's not clear what encoding are the files inside XLSX in.
|
|
46
40
|
// https://stackoverflow.com/questions/45194771/are-xlsx-files-utf-8-encoded-by-definition
|
|
@@ -54,8 +48,8 @@ function unpackXlsxFile(input) {
|
|
|
54
48
|
// If the `entry.setEncoding('utf8')` line would be commented out,
|
|
55
49
|
// there's a `nonAsciiCharacterEncoding` test that wouldn't pass.
|
|
56
50
|
//
|
|
57
|
-
entry.setEncoding('utf8');
|
|
58
|
-
|
|
51
|
+
entry.setEncoding('utf8');
|
|
52
|
+
//
|
|
59
53
|
entry.on('data', function (data) {
|
|
60
54
|
return contents += data.toString();
|
|
61
55
|
}).on('end', function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unpackXlsxFileNode.js","names":["unpackXlsxFile","input","entries","stream","Stream","Buffer","Readable","from","fs","createReadStream","Promise","resolve","reject","entryPromises","on","pipe","unzip","Parse","all","then","entry","contents","push","setEncoding","data","toString","path"],"sources":["../../source/read/unpackXlsxFileNode.js"],"sourcesContent":["import fs from 'fs'\r\nimport Stream, { Readable } from 'stream'\r\nimport unzip from 'unzipper'\r\n\r\n/**\r\n * Reads XLSX file in Node.js.\r\n * @param {(string|Stream)} input - A Node.js readable stream or a path to a file.\r\n * @return {Promise} Resolves to an object holding XLSX file entries.\r\n */\r\nexport default function unpackXlsxFile(input) {\r\n // XLSX file is a zip archive.\r\n // The `entries` object stores the files\r\n // and their contents from this XLSX zip archive.\r\n const entries = {}\r\n\r\n const stream = input instanceof Stream\r\n ? input\r\n : (\r\n input instanceof Buffer\r\n ? Readable.from(input)\r\n : fs.createReadStream(input)\r\n )\r\n\r\n return new Promise((resolve, reject) => {\r\n const entryPromises = []\r\n\r\n stream\r\n // This first \"error\" listener is for the original stream errors.\r\n .on('error', reject)\r\n .pipe(unzip.Parse())\r\n // This second \"error\" listener is for the unzip stream errors.\r\n .on('error', reject)\r\n .on('close', () => Promise.all(entryPromises).then(() => resolve(entries)))\r\n .on('entry', (entry) => {\r\n let contents = ''\r\n // To ignore an entry: `entry.autodrain()`.\r\n entryPromises.push(new Promise((resolve) => {\r\n // It's not clear what encoding are the files inside XLSX in.\r\n // https://stackoverflow.com/questions/45194771/are-xlsx-files-utf-8-encoded-by-definition\r\n // For example, for XML files, encoding is specified at the top node:\r\n // `<?xml version=\"1.0\" encoding=\"UTF-8\"/>`.\r\n //\r\n // `unzipper` supports setting encoding when reading an `entry`.\r\n // https://github.com/ZJONSSON/node-unzipper/issues/35\r\n // https://gitlab.com/catamphetamine/read-excel-file/-/issues/54\r\n //\r\n // If the `entry.setEncoding('utf8')` line would be commented out,\r\n // there's a `nonAsciiCharacterEncoding` test that wouldn't pass.\r\n //\r\n entry.setEncoding('utf8')\r\n //\r\n entry\r\n .on('data', data => contents += data.toString())\r\n .on('end', () => resolve(entries[entry.path] = contents))\r\n }))\r\n })\r\n })\r\n}\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"unpackXlsxFileNode.js","names":["_fs","_interopRequireDefault","require","_stream","_interopRequireWildcard","_unzipper","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","unpackXlsxFile","input","entries","stream","Stream","Buffer","Readable","from","fs","createReadStream","Promise","resolve","reject","entryPromises","on","pipe","unzip","Parse","all","then","entry","contents","push","setEncoding","data","toString","path"],"sources":["../../source/read/unpackXlsxFileNode.js"],"sourcesContent":["import fs from 'fs'\r\nimport Stream, { Readable } from 'stream'\r\nimport unzip from 'unzipper'\r\n\r\n/**\r\n * Reads XLSX file in Node.js.\r\n * @param {(string|Stream)} input - A Node.js readable stream or a path to a file.\r\n * @return {Promise} Resolves to an object holding XLSX file entries.\r\n */\r\nexport default function unpackXlsxFile(input) {\r\n // XLSX file is a zip archive.\r\n // The `entries` object stores the files\r\n // and their contents from this XLSX zip archive.\r\n const entries = {}\r\n\r\n const stream = input instanceof Stream\r\n ? input\r\n : (\r\n input instanceof Buffer\r\n ? Readable.from(input)\r\n : fs.createReadStream(input)\r\n )\r\n\r\n return new Promise((resolve, reject) => {\r\n const entryPromises = []\r\n\r\n stream\r\n // This first \"error\" listener is for the original stream errors.\r\n .on('error', reject)\r\n .pipe(unzip.Parse())\r\n // This second \"error\" listener is for the unzip stream errors.\r\n .on('error', reject)\r\n .on('close', () => Promise.all(entryPromises).then(() => resolve(entries)))\r\n .on('entry', (entry) => {\r\n let contents = ''\r\n // To ignore an entry: `entry.autodrain()`.\r\n entryPromises.push(new Promise((resolve) => {\r\n // It's not clear what encoding are the files inside XLSX in.\r\n // https://stackoverflow.com/questions/45194771/are-xlsx-files-utf-8-encoded-by-definition\r\n // For example, for XML files, encoding is specified at the top node:\r\n // `<?xml version=\"1.0\" encoding=\"UTF-8\"/>`.\r\n //\r\n // `unzipper` supports setting encoding when reading an `entry`.\r\n // https://github.com/ZJONSSON/node-unzipper/issues/35\r\n // https://gitlab.com/catamphetamine/read-excel-file/-/issues/54\r\n //\r\n // If the `entry.setEncoding('utf8')` line would be commented out,\r\n // there's a `nonAsciiCharacterEncoding` test that wouldn't pass.\r\n //\r\n entry.setEncoding('utf8')\r\n //\r\n entry\r\n .on('data', data => contents += data.toString())\r\n .on('end', () => resolve(entries[entry.path] = contents))\r\n }))\r\n })\r\n })\r\n}\r\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,SAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAA4B,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,uCAAAA,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,cAAAN,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;AAAA,SAAAhB,uBAAAU,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAE5B;AACA;AACA;AACA;AACA;AACe,SAASiB,cAAcA,CAACC,KAAK,EAAE;EAC5C;EACA;EACA;EACA,IAAMC,OAAO,GAAG,CAAC,CAAC;EAElB,IAAMC,MAAM,GAAGF,KAAK,YAAYG,kBAAM,GAClCH,KAAK,GAELA,KAAK,YAAYI,MAAM,GACnBC,gBAAQ,CAACC,IAAI,CAACN,KAAK,CAAC,GACpBO,cAAE,CAACC,gBAAgB,CAACR,KAAK,CAC9B;EAEH,OAAO,IAAIS,OAAO,CAAC,UAACC,OAAO,EAAEC,MAAM,EAAK;IACtC,IAAMC,aAAa,GAAG,EAAE;IAExBV;IACE;IAAA,CACCW,EAAE,CAAC,OAAO,EAAEF,MAAM,CAAC,CACnBG,IAAI,CAACC,oBAAK,CAACC,KAAK,CAAC,CAAC;IACnB;IAAA,CACCH,EAAE,CAAC,OAAO,EAAEF,MAAM,CAAC,CACnBE,EAAE,CAAC,OAAO,EAAE;MAAA,OAAOJ,OAAO,CAACQ,GAAG,CAACL,aAAa,CAAC,CAACM,IAAI,CAAC;QAAA,OAAMR,OAAO,CAACT,OAAO,CAAC;MAAA,EAAC;IAAA,EAAC,CAC3EY,EAAE,CAAC,OAAO,EAAE,UAACM,KAAK,EAAK;MACtB,IAAIC,QAAQ,GAAG,EAAE;MACjB;MACAR,aAAa,CAACS,IAAI,CAAC,IAAIZ,OAAO,CAAC,UAACC,OAAO,EAAK;QAC1C;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACAS,KAAK,CAACG,WAAW,CAAC,MAAM,CAAC;QACzB;QACAH,KAAK,CACFN,EAAE,CAAC,MAAM,EAAE,UAAAU,IAAI;UAAA,OAAIH,QAAQ,IAAIG,IAAI,CAACC,QAAQ,CAAC,CAAC;QAAA,EAAC,CAC/CX,EAAE,CAAC,KAAK,EAAE;UAAA,OAAMH,OAAO,CAACT,OAAO,CAACkB,KAAK,CAACM,IAAI,CAAC,GAAGL,QAAQ,CAAC;QAAA,EAAC;MAC7D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;EACN,CAAC,CAAC;AACJ"}
|
|
@@ -4,16 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = BooleanType;
|
|
7
|
-
|
|
8
7
|
var _InvalidError = _interopRequireDefault(require("./InvalidError.js"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
9
|
function BooleanType(value) {
|
|
13
10
|
if (typeof value === 'boolean') {
|
|
14
11
|
return value;
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
throw new _InvalidError["default"]('not_a_boolean');
|
|
18
14
|
}
|
|
19
15
|
//# sourceMappingURL=Boolean.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Boolean.js","names":["BooleanType","value","InvalidError"],"sources":["../../source/types/Boolean.js"],"sourcesContent":["import InvalidError from './InvalidError.js'\r\n\r\nexport default function BooleanType(value) {\r\n\tif (typeof value === 'boolean') {\r\n return value\r\n }\r\n throw new InvalidError('not_a_boolean')\r\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Boolean.js","names":["_InvalidError","_interopRequireDefault","require","obj","__esModule","BooleanType","value","InvalidError"],"sources":["../../source/types/Boolean.js"],"sourcesContent":["import InvalidError from './InvalidError.js'\r\n\r\nexport default function BooleanType(value) {\r\n\tif (typeof value === 'boolean') {\r\n return value\r\n }\r\n throw new InvalidError('not_a_boolean')\r\n}"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAE7B,SAASE,WAAWA,CAACC,KAAK,EAAE;EAC1C,IAAI,OAAOA,KAAK,KAAK,SAAS,EAAE;IAC7B,OAAOA,KAAK;EACd;EACA,MAAM,IAAIC,wBAAY,CAAC,eAAe,CAAC;AACzC"}
|
package/commonjs/types/Date.js
CHANGED
|
@@ -4,16 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = DateType;
|
|
7
|
-
|
|
8
7
|
var _parseDate = _interopRequireDefault(require("../read/parseDate.js"));
|
|
9
|
-
|
|
10
8
|
var _InvalidError = _interopRequireDefault(require("./InvalidError.js"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
10
|
function DateType(value, _ref) {
|
|
15
11
|
var properties = _ref.properties;
|
|
16
|
-
|
|
17
12
|
// XLSX has no specific format for dates.
|
|
18
13
|
// Sometimes a date can be heuristically detected.
|
|
19
14
|
// https://github.com/catamphetamine/read-excel-file/issues/3#issuecomment-395770777
|
|
@@ -21,28 +16,21 @@ function DateType(value, _ref) {
|
|
|
21
16
|
if (isNaN(value.valueOf())) {
|
|
22
17
|
throw new _InvalidError["default"]('out_of_bounds');
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
return value;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
if (typeof value === 'number') {
|
|
29
22
|
if (isNaN(value)) {
|
|
30
23
|
throw new _InvalidError["default"]('invalid_number');
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
if (!isFinite(value)) {
|
|
34
26
|
throw new _InvalidError["default"]('out_of_bounds');
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
var date = (0, _parseDate["default"])(value, properties);
|
|
38
|
-
|
|
39
29
|
if (isNaN(date.valueOf())) {
|
|
40
30
|
throw new _InvalidError["default"]('out_of_bounds');
|
|
41
31
|
}
|
|
42
|
-
|
|
43
32
|
return date;
|
|
44
33
|
}
|
|
45
|
-
|
|
46
34
|
throw new _InvalidError["default"]('not_a_date');
|
|
47
35
|
}
|
|
48
36
|
//# sourceMappingURL=Date.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Date.js","names":["DateType","value","properties","Date","isNaN","valueOf","InvalidError","isFinite","date","parseDate"],"sources":["../../source/types/Date.js"],"sourcesContent":["import parseDate from '../read/parseDate.js'\r\nimport InvalidError from './InvalidError.js'\r\n\r\nexport default function DateType(value, { properties }) {\r\n\t// XLSX has no specific format for dates.\r\n // Sometimes a date can be heuristically detected.\r\n // https://github.com/catamphetamine/read-excel-file/issues/3#issuecomment-395770777\r\n if (value instanceof Date) {\r\n if (isNaN(value.valueOf())) {\r\n throw new InvalidError('out_of_bounds')\r\n }\r\n return value\r\n }\r\n if (typeof value === 'number') {\r\n if (isNaN(value)) {\r\n throw new InvalidError('invalid_number')\r\n }\r\n if (!isFinite(value)) {\r\n throw new InvalidError('out_of_bounds')\r\n }\r\n const date = parseDate(value, properties)\r\n if (isNaN(date.valueOf())) {\r\n throw new InvalidError('out_of_bounds')\r\n }\r\n return date\r\n }\r\n throw new InvalidError('not_a_date')\r\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Date.js","names":["_parseDate","_interopRequireDefault","require","_InvalidError","obj","__esModule","DateType","value","_ref","properties","Date","isNaN","valueOf","InvalidError","isFinite","date","parseDate"],"sources":["../../source/types/Date.js"],"sourcesContent":["import parseDate from '../read/parseDate.js'\r\nimport InvalidError from './InvalidError.js'\r\n\r\nexport default function DateType(value, { properties }) {\r\n\t// XLSX has no specific format for dates.\r\n // Sometimes a date can be heuristically detected.\r\n // https://github.com/catamphetamine/read-excel-file/issues/3#issuecomment-395770777\r\n if (value instanceof Date) {\r\n if (isNaN(value.valueOf())) {\r\n throw new InvalidError('out_of_bounds')\r\n }\r\n return value\r\n }\r\n if (typeof value === 'number') {\r\n if (isNaN(value)) {\r\n throw new InvalidError('invalid_number')\r\n }\r\n if (!isFinite(value)) {\r\n throw new InvalidError('out_of_bounds')\r\n }\r\n const date = parseDate(value, properties)\r\n if (isNaN(date.valueOf())) {\r\n throw new InvalidError('out_of_bounds')\r\n }\r\n return date\r\n }\r\n throw new InvalidError('not_a_date')\r\n}"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA4C,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAE7B,SAASE,QAAQA,CAACC,KAAK,EAAAC,IAAA,EAAkB;EAAA,IAAdC,UAAU,GAAAD,IAAA,CAAVC,UAAU;EACnD;EACC;EACA;EACA,IAAIF,KAAK,YAAYG,IAAI,EAAE;IACzB,IAAIC,KAAK,CAACJ,KAAK,CAACK,OAAO,CAAC,CAAC,CAAC,EAAE;MAC1B,MAAM,IAAIC,wBAAY,CAAC,eAAe,CAAC;IACzC;IACA,OAAON,KAAK;EACd;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,IAAII,KAAK,CAACJ,KAAK,CAAC,EAAE;MAChB,MAAM,IAAIM,wBAAY,CAAC,gBAAgB,CAAC;IAC1C;IACA,IAAI,CAACC,QAAQ,CAACP,KAAK,CAAC,EAAE;MACpB,MAAM,IAAIM,wBAAY,CAAC,eAAe,CAAC;IACzC;IACA,IAAME,IAAI,GAAG,IAAAC,qBAAS,EAACT,KAAK,EAAEE,UAAU,CAAC;IACzC,IAAIE,KAAK,CAACI,IAAI,CAACH,OAAO,CAAC,CAAC,CAAC,EAAE;MACzB,MAAM,IAAIC,wBAAY,CAAC,eAAe,CAAC;IACzC;IACA,OAAOE,IAAI;EACb;EACA,MAAM,IAAIF,wBAAY,CAAC,YAAY,CAAC;AACtC"}
|
package/commonjs/types/Email.js
CHANGED
|
@@ -5,25 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = Email;
|
|
7
7
|
exports.isEmail = isEmail;
|
|
8
|
-
|
|
9
8
|
var _InvalidError = _interopRequireDefault(require("./InvalidError.js"));
|
|
10
|
-
|
|
11
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
-
|
|
13
10
|
function Email(value) {
|
|
14
11
|
if (typeof value === 'string') {
|
|
15
12
|
if (isEmail(value)) {
|
|
16
13
|
return value;
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
throw new _InvalidError["default"]('not_an_email');
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
throw new _InvalidError["default"]('not_a_string');
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
var regexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
|
|
26
|
-
|
|
27
20
|
function isEmail(value) {
|
|
28
21
|
return regexp.test(value);
|
|
29
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Email.js","names":["Email","value","isEmail","InvalidError","regexp","test"],"sources":["../../source/types/Email.js"],"sourcesContent":["import InvalidError from './InvalidError.js'\r\n\r\nexport default function Email(value) {\r\n if (typeof value === 'string') {\r\n if (isEmail(value)) {\r\n return value\r\n }\r\n throw new InvalidError('not_an_email')\r\n }\r\n throw new InvalidError('not_a_string')\r\n}\r\n\r\nconst regexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}$/i\r\n\r\nexport function isEmail(value) {\r\n\treturn regexp.test(value)\r\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Email.js","names":["_InvalidError","_interopRequireDefault","require","obj","__esModule","Email","value","isEmail","InvalidError","regexp","test"],"sources":["../../source/types/Email.js"],"sourcesContent":["import InvalidError from './InvalidError.js'\r\n\r\nexport default function Email(value) {\r\n if (typeof value === 'string') {\r\n if (isEmail(value)) {\r\n return value\r\n }\r\n throw new InvalidError('not_an_email')\r\n }\r\n throw new InvalidError('not_a_string')\r\n}\r\n\r\nconst regexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}$/i\r\n\r\nexport function isEmail(value) {\r\n\treturn regexp.test(value)\r\n}"],"mappings":";;;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAE7B,SAASE,KAAKA,CAACC,KAAK,EAAE;EACnC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,IAAIC,OAAO,CAACD,KAAK,CAAC,EAAE;MAClB,OAAOA,KAAK;IACd;IACA,MAAM,IAAIE,wBAAY,CAAC,cAAc,CAAC;EACxC;EACA,MAAM,IAAIA,wBAAY,CAAC,cAAc,CAAC;AACxC;AAEA,IAAMC,MAAM,GAAG,0CAA0C;AAElD,SAASF,OAAOA,CAACD,KAAK,EAAE;EAC9B,OAAOG,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC;AAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Email.test.js","names":["describe","it","isEmail","should","equal"],"sources":["../../source/types/Email.test.js"],"sourcesContent":["import { isEmail } from './Email.js'\r\n\r\ndescribe('Email', () => {\r\n\tit('should validate an Email', () => {\r\n\t\tisEmail('123').should.equal(false)\r\n\t\tisEmail('vladimir.putin@kremlin.ru').should.equal(true)\r\n\t})\r\n})"],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"Email.test.js","names":["_Email","require","describe","it","isEmail","should","equal"],"sources":["../../source/types/Email.test.js"],"sourcesContent":["import { isEmail } from './Email.js'\r\n\r\ndescribe('Email', () => {\r\n\tit('should validate an Email', () => {\r\n\t\tisEmail('123').should.equal(false)\r\n\t\tisEmail('vladimir.putin@kremlin.ru').should.equal(true)\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,OAAO,EAAE,YAAM;EACvBC,EAAE,CAAC,0BAA0B,EAAE,YAAM;IACpC,IAAAC,cAAO,EAAC,KAAK,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,KAAK,CAAC;IAClC,IAAAF,cAAO,EAAC,2BAA2B,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,IAAI,CAAC;EACxD,CAAC,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -5,23 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = Integer;
|
|
7
7
|
exports.isInteger = isInteger;
|
|
8
|
-
|
|
9
8
|
var _InvalidError = _interopRequireDefault(require("./InvalidError.js"));
|
|
10
|
-
|
|
11
9
|
var _Number = _interopRequireDefault(require("./Number.js"));
|
|
12
|
-
|
|
13
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
-
|
|
15
11
|
function Integer(value) {
|
|
16
12
|
value = (0, _Number["default"])(value);
|
|
17
|
-
|
|
18
13
|
if (!isInteger(value)) {
|
|
19
14
|
throw new _InvalidError["default"]('not_an_integer');
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
return value;
|
|
23
17
|
}
|
|
24
|
-
|
|
25
18
|
function isInteger(x) {
|
|
26
19
|
// https://stackoverflow.com/questions/14636536/how-to-check-if-a-variable-is-an-integer-in-javascript
|
|
27
20
|
return (x | 0) === x;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Integer.js","names":["Integer","value","NumberType","isInteger","InvalidError","x"],"sources":["../../source/types/Integer.js"],"sourcesContent":["import InvalidError from './InvalidError.js'\r\nimport NumberType from './Number.js'\r\n\r\nexport default function Integer(value) {\r\n\tvalue = NumberType(value)\r\n if (!isInteger(value)) {\r\n throw new InvalidError('not_an_integer')\r\n }\r\n return value\r\n}\r\n\r\nexport function isInteger(x) {\r\n\t// https://stackoverflow.com/questions/14636536/how-to-check-if-a-variable-is-an-integer-in-javascript\r\n\treturn (x | 0) === x\r\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Integer.js","names":["_InvalidError","_interopRequireDefault","require","_Number","obj","__esModule","Integer","value","NumberType","isInteger","InvalidError","x"],"sources":["../../source/types/Integer.js"],"sourcesContent":["import InvalidError from './InvalidError.js'\r\nimport NumberType from './Number.js'\r\n\r\nexport default function Integer(value) {\r\n\tvalue = NumberType(value)\r\n if (!isInteger(value)) {\r\n throw new InvalidError('not_an_integer')\r\n }\r\n return value\r\n}\r\n\r\nexport function isInteger(x) {\r\n\t// https://stackoverflow.com/questions/14636536/how-to-check-if-a-variable-is-an-integer-in-javascript\r\n\treturn (x | 0) === x\r\n}"],"mappings":";;;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAErB,SAASE,OAAOA,CAACC,KAAK,EAAE;EACtCA,KAAK,GAAG,IAAAC,kBAAU,EAACD,KAAK,CAAC;EACxB,IAAI,CAACE,SAAS,CAACF,KAAK,CAAC,EAAE;IACrB,MAAM,IAAIG,wBAAY,CAAC,gBAAgB,CAAC;EAC1C;EACA,OAAOH,KAAK;AACd;AAEO,SAASE,SAASA,CAACE,CAAC,EAAE;EAC5B;EACA,OAAO,CAACA,CAAC,GAAG,CAAC,MAAMA,CAAC;AACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Integer.test.js","names":["describe","it","isInteger","should","equal"],"sources":["../../source/types/Integer.test.js"],"sourcesContent":["import { isInteger } from './Integer.js'\r\n\r\ndescribe('Integer', () => {\r\n\tit('should validate an Integer', () => {\r\n\t\t// isInteger('1.2').should.equal(false)\r\n\t\t// isInteger('1').should.equal(true)\r\n\t\tisInteger(1.2).should.equal(false)\r\n\t\tisInteger(1).should.equal(true)\r\n\t})\r\n})"],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"Integer.test.js","names":["_Integer","require","describe","it","isInteger","should","equal"],"sources":["../../source/types/Integer.test.js"],"sourcesContent":["import { isInteger } from './Integer.js'\r\n\r\ndescribe('Integer', () => {\r\n\tit('should validate an Integer', () => {\r\n\t\t// isInteger('1.2').should.equal(false)\r\n\t\t// isInteger('1').should.equal(true)\r\n\t\tisInteger(1.2).should.equal(false)\r\n\t\tisInteger(1).should.equal(true)\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,SAAS,EAAE,YAAM;EACzBC,EAAE,CAAC,4BAA4B,EAAE,YAAM;IACtC;IACA;IACA,IAAAC,kBAAS,EAAC,GAAG,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,KAAK,CAAC;IAClC,IAAAF,kBAAS,EAAC,CAAC,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,IAAI,CAAC;EAChC,CAAC,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,55 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
4
|
-
|
|
3
|
+
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); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
|
-
|
|
8
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
-
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
11
|
+
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); }
|
|
14
12
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
13
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
17
|
-
|
|
18
14
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
19
|
-
|
|
20
15
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
21
|
-
|
|
22
16
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
23
|
-
|
|
24
17
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
25
|
-
|
|
26
|
-
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
27
|
-
|
|
18
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
28
19
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
29
|
-
|
|
30
20
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
35
|
-
|
|
36
|
-
var InvalidError = /*#__PURE__*/function (_Error) {
|
|
21
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
22
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
|
+
var InvalidError = exports["default"] = /*#__PURE__*/function (_Error) {
|
|
37
24
|
_inherits(InvalidError, _Error);
|
|
38
|
-
|
|
39
25
|
var _super = _createSuper(InvalidError);
|
|
40
|
-
|
|
41
26
|
function InvalidError(reason) {
|
|
42
27
|
var _this;
|
|
43
|
-
|
|
44
28
|
_classCallCheck(this, InvalidError);
|
|
45
|
-
|
|
46
29
|
_this = _super.call(this, 'invalid');
|
|
47
30
|
_this.reason = reason;
|
|
48
31
|
return _this;
|
|
49
32
|
}
|
|
50
|
-
|
|
51
33
|
return _createClass(InvalidError);
|
|
52
34
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
53
|
-
|
|
54
|
-
exports["default"] = InvalidError;
|
|
55
35
|
//# sourceMappingURL=InvalidError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvalidError.js","names":["InvalidError","reason","Error"],"sources":["../../source/types/InvalidError.js"],"sourcesContent":["export default class InvalidError extends Error {\r\n constructor(reason) {\r\n super('invalid')\r\n this.reason = reason\r\n }\r\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"InvalidError.js","names":["InvalidError","exports","_Error","_inherits","_super","_createSuper","reason","_this","_classCallCheck","call","_createClass","_wrapNativeSuper","Error"],"sources":["../../source/types/InvalidError.js"],"sourcesContent":["export default class InvalidError extends Error {\r\n constructor(reason) {\r\n super('invalid')\r\n this.reason = reason\r\n }\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;IAAqBA,YAAY,GAAAC,OAAA,qCAAAC,MAAA;EAAAC,SAAA,CAAAH,YAAA,EAAAE,MAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAL,YAAA;EAC/B,SAAAA,aAAYM,MAAM,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAR,YAAA;IAClBO,KAAA,GAAAH,MAAA,CAAAK,IAAA,OAAM,SAAS;IACfF,KAAA,CAAKD,MAAM,GAAGA,MAAM;IAAA,OAAAC,KAAA;EACtB;EAAC,OAAAG,YAAA,CAAAV,YAAA;AAAA,gBAAAW,gBAAA,CAJuCC,KAAK"}
|
package/commonjs/types/Number.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = NumberType;
|
|
7
|
-
|
|
8
7
|
var _InvalidError = _interopRequireDefault(require("./InvalidError.js"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
9
|
function NumberType(value) {
|
|
13
10
|
// An XLSX file editing software might not always correctly
|
|
14
11
|
// detect numeric values in string-type cells. Users won't bother
|
|
@@ -21,19 +18,17 @@ function NumberType(value) {
|
|
|
21
18
|
if (typeof value === 'string') {
|
|
22
19
|
var stringifiedValue = value;
|
|
23
20
|
value = Number(value);
|
|
24
|
-
|
|
25
21
|
if (String(value) !== stringifiedValue) {
|
|
26
22
|
throw new _InvalidError["default"]('not_a_number');
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
if (typeof value !== 'number') {
|
|
31
26
|
throw new _InvalidError["default"]('not_a_number');
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
if (isNaN(value)) {
|
|
35
29
|
throw new _InvalidError["default"]('invalid_number');
|
|
36
|
-
}
|
|
30
|
+
}
|
|
31
|
+
// At this point, `value` can only be a number.
|
|
37
32
|
//
|
|
38
33
|
// The global `isFinite()` function filters out:
|
|
39
34
|
// * NaN
|
|
@@ -42,12 +37,9 @@ function NumberType(value) {
|
|
|
42
37
|
//
|
|
43
38
|
// All other values pass (including non-numbers).
|
|
44
39
|
//
|
|
45
|
-
|
|
46
|
-
|
|
47
40
|
if (!isFinite(value)) {
|
|
48
41
|
throw new _InvalidError["default"]('out_of_bounds');
|
|
49
42
|
}
|
|
50
|
-
|
|
51
43
|
return value;
|
|
52
44
|
}
|
|
53
45
|
//# sourceMappingURL=Number.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Number.js","names":["NumberType","value","stringifiedValue","Number","String","InvalidError","isNaN","isFinite"],"sources":["../../source/types/Number.js"],"sourcesContent":["import InvalidError from './InvalidError.js'\r\n\r\nexport default function NumberType(value) {\r\n // An XLSX file editing software might not always correctly\r\n // detect numeric values in string-type cells. Users won't bother\r\n // manually selecting a cell type, so the editing software has to guess\r\n // based on the user's input. One can assume that such auto-detection\r\n // might not always work.\r\n //\r\n // So, if a cell is supposed to be a numeric one, convert a string value to a number.\r\n //\r\n if (typeof value === 'string') {\r\n const stringifiedValue = value\r\n value = Number(value)\r\n if (String(value) !== stringifiedValue) {\r\n throw new InvalidError('not_a_number')\r\n }\r\n }\r\n if (typeof value !== 'number') {\r\n throw new InvalidError('not_a_number')\r\n }\r\n if (isNaN(value)) {\r\n throw new InvalidError('invalid_number')\r\n }\r\n // At this point, `value` can only be a number.\r\n //\r\n // The global `isFinite()` function filters out:\r\n // * NaN\r\n // * -Infinity\r\n // * Infinity\r\n //\r\n // All other values pass (including non-numbers).\r\n //\r\n if (!isFinite(value)) {\r\n throw new InvalidError('out_of_bounds')\r\n }\r\n return value\r\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Number.js","names":["_InvalidError","_interopRequireDefault","require","obj","__esModule","NumberType","value","stringifiedValue","Number","String","InvalidError","isNaN","isFinite"],"sources":["../../source/types/Number.js"],"sourcesContent":["import InvalidError from './InvalidError.js'\r\n\r\nexport default function NumberType(value) {\r\n // An XLSX file editing software might not always correctly\r\n // detect numeric values in string-type cells. Users won't bother\r\n // manually selecting a cell type, so the editing software has to guess\r\n // based on the user's input. One can assume that such auto-detection\r\n // might not always work.\r\n //\r\n // So, if a cell is supposed to be a numeric one, convert a string value to a number.\r\n //\r\n if (typeof value === 'string') {\r\n const stringifiedValue = value\r\n value = Number(value)\r\n if (String(value) !== stringifiedValue) {\r\n throw new InvalidError('not_a_number')\r\n }\r\n }\r\n if (typeof value !== 'number') {\r\n throw new InvalidError('not_a_number')\r\n }\r\n if (isNaN(value)) {\r\n throw new InvalidError('invalid_number')\r\n }\r\n // At this point, `value` can only be a number.\r\n //\r\n // The global `isFinite()` function filters out:\r\n // * NaN\r\n // * -Infinity\r\n // * Infinity\r\n //\r\n // All other values pass (including non-numbers).\r\n //\r\n if (!isFinite(value)) {\r\n throw new InvalidError('out_of_bounds')\r\n }\r\n return value\r\n}"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAE7B,SAASE,UAAUA,CAACC,KAAK,EAAE;EACxC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,IAAMC,gBAAgB,GAAGD,KAAK;IAC9BA,KAAK,GAAGE,MAAM,CAACF,KAAK,CAAC;IACrB,IAAIG,MAAM,CAACH,KAAK,CAAC,KAAKC,gBAAgB,EAAE;MACtC,MAAM,IAAIG,wBAAY,CAAC,cAAc,CAAC;IACxC;EACF;EACA,IAAI,OAAOJ,KAAK,KAAK,QAAQ,EAAE;IAC7B,MAAM,IAAII,wBAAY,CAAC,cAAc,CAAC;EACxC;EACA,IAAIC,KAAK,CAACL,KAAK,CAAC,EAAE;IAChB,MAAM,IAAII,wBAAY,CAAC,gBAAgB,CAAC;EAC1C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAI,CAACE,QAAQ,CAACN,KAAK,CAAC,EAAE;IACpB,MAAM,IAAII,wBAAY,CAAC,eAAe,CAAC;EACzC;EACA,OAAOJ,KAAK;AACd"}
|
package/commonjs/types/String.js
CHANGED
|
@@ -4,15 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = StringType;
|
|
7
|
-
|
|
8
7
|
var _InvalidError = _interopRequireDefault(require("./InvalidError.js"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
9
|
function StringType(value) {
|
|
13
10
|
if (typeof value === 'string') {
|
|
14
11
|
return value;
|
|
15
|
-
}
|
|
12
|
+
}
|
|
13
|
+
// Excel tends to perform a forced automatic convertion of string-type values
|
|
16
14
|
// to number-type ones when the user has input them. Otherwise, users wouldn't
|
|
17
15
|
// be able to perform formula calculations on those cell values because users
|
|
18
16
|
// won't bother manually choosing a "numeric" cell type for each cell, and
|
|
@@ -22,27 +20,22 @@ function StringType(value) {
|
|
|
22
20
|
// So, if a cell value is supposed to be a string and Excel has automatically
|
|
23
21
|
// converted it to a number, perform a backwards conversion.
|
|
24
22
|
//
|
|
25
|
-
|
|
26
|
-
|
|
27
23
|
if (typeof value === 'number') {
|
|
28
24
|
if (isNaN(value)) {
|
|
29
25
|
throw new _InvalidError["default"]('invalid_number');
|
|
30
|
-
}
|
|
26
|
+
}
|
|
27
|
+
// The global `isFinite()` function filters out:
|
|
31
28
|
// * NaN
|
|
32
29
|
// * -Infinity
|
|
33
30
|
// * Infinity
|
|
34
31
|
//
|
|
35
32
|
// All other values pass (including non-numbers).
|
|
36
33
|
//
|
|
37
|
-
|
|
38
|
-
|
|
39
34
|
if (!isFinite(value)) {
|
|
40
35
|
throw new _InvalidError["default"]('out_of_bounds');
|
|
41
36
|
}
|
|
42
|
-
|
|
43
37
|
return String(value);
|
|
44
38
|
}
|
|
45
|
-
|
|
46
39
|
throw new _InvalidError["default"]('not_a_string');
|
|
47
40
|
}
|
|
48
41
|
//# sourceMappingURL=String.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"String.js","names":["StringType","value","isNaN","InvalidError","isFinite","String"],"sources":["../../source/types/String.js"],"sourcesContent":["import InvalidError from './InvalidError.js'\r\n\r\nexport default function StringType(value) {\r\n if (typeof value === 'string') {\r\n return value\r\n }\r\n // Excel tends to perform a forced automatic convertion of string-type values\r\n // to number-type ones when the user has input them. Otherwise, users wouldn't\r\n // be able to perform formula calculations on those cell values because users\r\n // won't bother manually choosing a \"numeric\" cell type for each cell, and\r\n // even if they did, choosing a \"numeric\" cell type every time wouldn't be an\r\n // acceptable \"user experience\".\r\n //\r\n // So, if a cell value is supposed to be a string and Excel has automatically\r\n // converted it to a number, perform a backwards conversion.\r\n //\r\n if (typeof value === 'number') {\r\n if (isNaN(value)) {\r\n throw new InvalidError('invalid_number')\r\n }\r\n // The global `isFinite()` function filters out:\r\n // * NaN\r\n // * -Infinity\r\n // * Infinity\r\n //\r\n // All other values pass (including non-numbers).\r\n //\r\n if (!isFinite(value)) {\r\n throw new InvalidError('out_of_bounds')\r\n }\r\n return String(value)\r\n }\r\n throw new InvalidError('not_a_string')\r\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"String.js","names":["_InvalidError","_interopRequireDefault","require","obj","__esModule","StringType","value","isNaN","InvalidError","isFinite","String"],"sources":["../../source/types/String.js"],"sourcesContent":["import InvalidError from './InvalidError.js'\r\n\r\nexport default function StringType(value) {\r\n if (typeof value === 'string') {\r\n return value\r\n }\r\n // Excel tends to perform a forced automatic convertion of string-type values\r\n // to number-type ones when the user has input them. Otherwise, users wouldn't\r\n // be able to perform formula calculations on those cell values because users\r\n // won't bother manually choosing a \"numeric\" cell type for each cell, and\r\n // even if they did, choosing a \"numeric\" cell type every time wouldn't be an\r\n // acceptable \"user experience\".\r\n //\r\n // So, if a cell value is supposed to be a string and Excel has automatically\r\n // converted it to a number, perform a backwards conversion.\r\n //\r\n if (typeof value === 'number') {\r\n if (isNaN(value)) {\r\n throw new InvalidError('invalid_number')\r\n }\r\n // The global `isFinite()` function filters out:\r\n // * NaN\r\n // * -Infinity\r\n // * Infinity\r\n //\r\n // All other values pass (including non-numbers).\r\n //\r\n if (!isFinite(value)) {\r\n throw new InvalidError('out_of_bounds')\r\n }\r\n return String(value)\r\n }\r\n throw new InvalidError('not_a_string')\r\n}"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAE7B,SAASE,UAAUA,CAACC,KAAK,EAAE;EACxC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAOA,KAAK;EACd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,IAAIC,KAAK,CAACD,KAAK,CAAC,EAAE;MAChB,MAAM,IAAIE,wBAAY,CAAC,gBAAgB,CAAC;IAC1C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,CAACC,QAAQ,CAACH,KAAK,CAAC,EAAE;MACpB,MAAM,IAAIE,wBAAY,CAAC,eAAe,CAAC;IACzC;IACA,OAAOE,MAAM,CAACJ,KAAK,CAAC;EACtB;EACA,MAAM,IAAIE,wBAAY,CAAC,cAAc,CAAC;AACxC"}
|
package/commonjs/types/URL.js
CHANGED
|
@@ -5,22 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = URL;
|
|
7
7
|
exports.isURL = isURL;
|
|
8
|
-
|
|
9
8
|
var _InvalidError = _interopRequireDefault(require("./InvalidError.js"));
|
|
10
|
-
|
|
11
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
-
|
|
13
10
|
function URL(value) {
|
|
14
11
|
if (typeof value === 'string') {
|
|
15
12
|
if (isURL(value)) {
|
|
16
13
|
return value;
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
throw new _InvalidError["default"]('not_a_url');
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
throw new _InvalidError["default"]('not_a_string');
|
|
23
|
-
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// URL regexp explanation:
|
|
24
21
|
//
|
|
25
22
|
// /^
|
|
26
23
|
//
|
|
@@ -75,9 +72,9 @@ function URL(value) {
|
|
|
75
72
|
//
|
|
76
73
|
// $/i
|
|
77
74
|
|
|
75
|
+
var regexp = /^(?:(?:(?:https?|ftp):)?\/\/)(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)*(?:[a-z\u00a1-\uffff]{2,}))(?::\d{2,5})?(?:[/?#]\S*)?$/i;
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
// https://stackoverflow.com/questions/8667070/javascript-regular-expression-to-validate-url
|
|
81
78
|
function isURL(value) {
|
|
82
79
|
return regexp.test(value);
|
|
83
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"URL.js","names":["URL","value","isURL","InvalidError","regexp","test"],"sources":["../../source/types/URL.js"],"sourcesContent":["import InvalidError from './InvalidError.js'\r\n\r\nexport default function URL(value) {\r\n if (typeof value === 'string') {\r\n if (isURL(value)) {\r\n return value\r\n }\r\n throw new InvalidError('not_a_url')\r\n }\r\n throw new InvalidError('not_a_string')\r\n}\r\n\r\n// URL regexp explanation:\r\n//\r\n// /^\r\n//\r\n// \t(?:\r\n// \t // Matches optional \"http(s):\" or \"ftp:\":\r\n// \t\t(?:\r\n// \t\t\t(?:https?|ftp):\r\n// \t\t)?\r\n//\r\n// \t // Matches \"//\" (required):\r\n// \t\t\\/\\/\r\n// \t)\r\n//\r\n// \t// Matches a valid non-local IP address:\r\n// \t(?:\r\n// \t\t(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])\r\n// \t\t(?:\r\n// \t\t\t\\.\r\n// \t\t\t(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])\r\n// \t\t){2}\r\n// \t\t(?:\r\n// \t\t\t\\.\r\n// \t\t\t(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4])\r\n// \t\t)\r\n//\r\n// \t // Or,\r\n// \t\t|\r\n//\r\n// \t // Matches an alpha-numeric domain name.\r\n// \t\t(?:\r\n// \t\t\t(?:\r\n// \t\t\t\t[a-z0-9\\u00a1-\\uffff]\r\n// \t\t\t\t[a-z0-9\\u00a1-\\uffff_-]{0,62}\r\n// \t\t\t)?\r\n// \t\t\t[a-z0-9\\u00a1-\\uffff]\r\n// \t\t\t\\.\r\n// \t\t)*\r\n// \t\t(?:\r\n// \t // Domain zone: \"com\", \"net\", etc (required):\r\n// \t\t\t[a-z\\u00a1-\\uffff]{2,}\r\n// \t\t)\r\n// \t)\r\n//\r\n// \t// Matches a colon and a port number:\r\n// \t(?::\\d{2,5})?\r\n//\r\n// \t// Matches everything after the \"origin\":\r\n// \t// * pathname\r\n// \t// * query\r\n// \t// * hash\r\n// \t(?:[/?#]\\S*)?\r\n//\r\n// $/i\r\n\r\nconst regexp = /^(?:(?:(?:https?|ftp):)?\\/\\/)(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)*(?:[a-z\\u00a1-\\uffff]{2,}))(?::\\d{2,5})?(?:[/?#]\\S*)?$/i\r\n\r\n// https://stackoverflow.com/questions/8667070/javascript-regular-expression-to-validate-url\r\nexport function isURL(value) {\r\n\treturn regexp.test(value)\r\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"URL.js","names":["_InvalidError","_interopRequireDefault","require","obj","__esModule","URL","value","isURL","InvalidError","regexp","test"],"sources":["../../source/types/URL.js"],"sourcesContent":["import InvalidError from './InvalidError.js'\r\n\r\nexport default function URL(value) {\r\n if (typeof value === 'string') {\r\n if (isURL(value)) {\r\n return value\r\n }\r\n throw new InvalidError('not_a_url')\r\n }\r\n throw new InvalidError('not_a_string')\r\n}\r\n\r\n// URL regexp explanation:\r\n//\r\n// /^\r\n//\r\n// \t(?:\r\n// \t // Matches optional \"http(s):\" or \"ftp:\":\r\n// \t\t(?:\r\n// \t\t\t(?:https?|ftp):\r\n// \t\t)?\r\n//\r\n// \t // Matches \"//\" (required):\r\n// \t\t\\/\\/\r\n// \t)\r\n//\r\n// \t// Matches a valid non-local IP address:\r\n// \t(?:\r\n// \t\t(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])\r\n// \t\t(?:\r\n// \t\t\t\\.\r\n// \t\t\t(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])\r\n// \t\t){2}\r\n// \t\t(?:\r\n// \t\t\t\\.\r\n// \t\t\t(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4])\r\n// \t\t)\r\n//\r\n// \t // Or,\r\n// \t\t|\r\n//\r\n// \t // Matches an alpha-numeric domain name.\r\n// \t\t(?:\r\n// \t\t\t(?:\r\n// \t\t\t\t[a-z0-9\\u00a1-\\uffff]\r\n// \t\t\t\t[a-z0-9\\u00a1-\\uffff_-]{0,62}\r\n// \t\t\t)?\r\n// \t\t\t[a-z0-9\\u00a1-\\uffff]\r\n// \t\t\t\\.\r\n// \t\t)*\r\n// \t\t(?:\r\n// \t // Domain zone: \"com\", \"net\", etc (required):\r\n// \t\t\t[a-z\\u00a1-\\uffff]{2,}\r\n// \t\t)\r\n// \t)\r\n//\r\n// \t// Matches a colon and a port number:\r\n// \t(?::\\d{2,5})?\r\n//\r\n// \t// Matches everything after the \"origin\":\r\n// \t// * pathname\r\n// \t// * query\r\n// \t// * hash\r\n// \t(?:[/?#]\\S*)?\r\n//\r\n// $/i\r\n\r\nconst regexp = /^(?:(?:(?:https?|ftp):)?\\/\\/)(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)*(?:[a-z\\u00a1-\\uffff]{2,}))(?::\\d{2,5})?(?:[/?#]\\S*)?$/i\r\n\r\n// https://stackoverflow.com/questions/8667070/javascript-regular-expression-to-validate-url\r\nexport function isURL(value) {\r\n\treturn regexp.test(value)\r\n}"],"mappings":";;;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAE7B,SAASE,GAAGA,CAACC,KAAK,EAAE;EACjC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,IAAIC,KAAK,CAACD,KAAK,CAAC,EAAE;MAChB,OAAOA,KAAK;IACd;IACA,MAAM,IAAIE,wBAAY,CAAC,WAAW,CAAC;EACrC;EACA,MAAM,IAAIA,wBAAY,CAAC,cAAc,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMC,MAAM,GAAG,+RAA+R;;AAE9S;AACO,SAASF,KAAKA,CAACD,KAAK,EAAE;EAC5B,OAAOG,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC;AAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"URL.test.js","names":["describe","it","isURL","should","equal"],"sources":["../../source/types/URL.test.js"],"sourcesContent":["import { isURL } from './URL.js'\r\n\r\ndescribe('URL', () => {\r\n\tit('should validate a URL', () => {\r\n\t\tisURL('123').should.equal(false)\r\n\t\tisURL('https://stackoverflow.com/questions/8667070/javascript-regular-expression-to-validate-url').should.equal(true)\r\n\t})\r\n})"],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"URL.test.js","names":["_URL","require","describe","it","isURL","should","equal"],"sources":["../../source/types/URL.test.js"],"sourcesContent":["import { isURL } from './URL.js'\r\n\r\ndescribe('URL', () => {\r\n\tit('should validate a URL', () => {\r\n\t\tisURL('123').should.equal(false)\r\n\t\tisURL('https://stackoverflow.com/questions/8667070/javascript-regular-expression-to-validate-url').should.equal(true)\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,KAAK,EAAE,YAAM;EACrBC,EAAE,CAAC,uBAAuB,EAAE,YAAM;IACjC,IAAAC,UAAK,EAAC,KAAK,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,KAAK,CAAC;IAChC,IAAAF,UAAK,EAAC,2FAA2F,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,IAAI,CAAC;EACtH,CAAC,CAAC;AACH,CAAC,CAAC"}
|