@transferwise/neptune-validation 3.0.12 → 3.1.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/LICENSE.md CHANGED
@@ -1,13 +1,13 @@
1
1
  Copyright 2019 Wise Ltd.
2
-
2
+
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
5
5
  You may obtain a copy of the License at
6
-
6
+
7
7
  http://www.apache.org/licenses/LICENSE-2.0
8
-
8
+
9
9
  Unless required by applicable law or agreed to in writing, software
10
10
  distributed under the License is distributed on an "AS IS" BASIS,
11
11
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  See the License for the specific language governing permissions and
13
- limitations under the License.
13
+ limitations under the License.
@@ -0,0 +1,62 @@
1
+ const isString = value => typeof value === 'string';
2
+ const isNumber = value => typeof value === 'number' && !Number.isNaN(value);
3
+ const isInteger = value => {
4
+ return isNumber(value) && Math.floor(value) === value;
5
+ };
6
+ const isBoolean = value => typeof value === 'boolean';
7
+ const isObject = value => !isNull(value) && !isUndefined(value) && value.constructor === Object;
8
+ const isArray = value => Array.isArray(value);
9
+ const isNull = value => value === null;
10
+ const isUndefined = value => typeof value === 'undefined';
11
+
12
+ /**
13
+ * Checks empty values for arrays,objects and strings.
14
+ *
15
+ * @param {object | Array | string} value
16
+ */
17
+ const isEmpty = value => isString(value) && value.length === 0 || (isObject(value) || isArray(value)) && Object.keys(value).length === 0;
18
+
19
+ const keyMap = {
20
+ SPACE: {
21
+ key: [' ', 'Spacebar'],
22
+ keyCode: 32
23
+ },
24
+ ENTER: {
25
+ key: 'Enter',
26
+ keyCode: 13
27
+ },
28
+ TAB: {
29
+ key: 'Tab',
30
+ keyCode: 9
31
+ },
32
+ ESCAPE: {
33
+ key: 'Escape',
34
+ keyCode: 27
35
+ }
36
+ };
37
+
38
+ const isKey = ({
39
+ keyType,
40
+ event
41
+ }) => {
42
+ if (!keyType || !event) {
43
+ return false;
44
+ }
45
+ const upperCaseKeyType = keyType.toUpperCase();
46
+ const keyDef = keyMap[upperCaseKeyType];
47
+ if (!keyDef) {
48
+ return false;
49
+ }
50
+ const {
51
+ key,
52
+ keyCode
53
+ } = event;
54
+ if (key) {
55
+ return isArray(keyDef.key) ? keyDef.key.includes(key) : key === keyDef.key;
56
+ }
57
+ return keyCode === keyDef.keyCode;
58
+ };
59
+ var isKey$1 = isKey;
60
+
61
+ export { isArray, isBoolean, isEmpty, isInteger, isKey$1 as isKey, isNull, isNumber, isObject, isString, isUndefined };
62
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/type-validators/index.js","../src/value-validators/index.js","../src/common/keyMap.js","../src/event-validators/isKey.js"],"sourcesContent":["const isString = (value) => typeof value === 'string';\nconst isNumber = (value) => typeof value === 'number' && !Number.isNaN(value);\nconst isInteger = (value) => {\n return isNumber(value) && Math.floor(value) === value;\n};\nconst isBoolean = (value) => typeof value === 'boolean';\n\nconst isObject = (value) => !isNull(value) && !isUndefined(value) && value.constructor === Object;\nconst isArray = (value) => Array.isArray(value);\nconst isNull = (value) => value === null;\nconst isUndefined = (value) => typeof value === 'undefined';\n\nexport { isString, isNumber, isInteger, isBoolean, isObject, isArray, isNull, isUndefined };\n","import { isString, isObject, isArray } from '../type-validators';\n\n/**\n * Checks empty values for arrays,objects and strings.\n *\n * @param {object | Array | string} value\n */\nconst isEmpty = (value) =>\n (isString(value) && value.length === 0) ||\n ((isObject(value) || isArray(value)) && Object.keys(value).length === 0);\n\nexport { isEmpty };\n","export const keyMap = {\n SPACE: { key: [' ', 'Spacebar'], keyCode: 32 },\n ENTER: { key: 'Enter', keyCode: 13 },\n TAB: { key: 'Tab', keyCode: 9 },\n ESCAPE: { key: 'Escape', keyCode: 27 },\n};\n","import { keyMap } from '../common/keyMap';\nimport { isArray } from '../type-validators';\n\nconst isKey = ({ keyType, event }) => {\n if (!keyType || !event) {\n return false;\n }\n\n const upperCaseKeyType = keyType.toUpperCase();\n const keyDef = keyMap[upperCaseKeyType];\n if (!keyDef) {\n return false;\n }\n\n const { key, keyCode } = event;\n\n if (key) {\n return isArray(keyDef.key) ? keyDef.key.includes(key) : key === keyDef.key;\n }\n\n return keyCode === keyDef.keyCode;\n};\n\nexport default isKey;\n"],"names":["isString","value","isNumber","Number","isNaN","isInteger","Math","floor","isBoolean","isObject","isNull","isUndefined","constructor","Object","isArray","Array","isEmpty","length","keys","keyMap","SPACE","key","keyCode","ENTER","TAB","ESCAPE","isKey","keyType","event","upperCaseKeyType","toUpperCase","keyDef","includes"],"mappings":"AAAA,MAAMA,QAAQ,GAAIC,KAAK,IAAK,OAAOA,KAAK,KAAK,SAAQ;AACrD,MAAMC,QAAQ,GAAID,KAAK,IAAK,OAAOA,KAAK,KAAK,QAAQ,IAAI,CAACE,MAAM,CAACC,KAAK,CAACH,KAAK,EAAC;AACvEI,MAAAA,SAAS,GAAIJ,KAAK,IAAK;AAC3B,EAAA,OAAOC,QAAQ,CAACD,KAAK,CAAC,IAAIK,IAAI,CAACC,KAAK,CAACN,KAAK,CAAC,KAAKA,KAAK,CAAA;AACvD,EAAC;AACD,MAAMO,SAAS,GAAIP,KAAK,IAAK,OAAOA,KAAK,KAAK,UAAS;AAEjDQ,MAAAA,QAAQ,GAAIR,KAAK,IAAK,CAACS,MAAM,CAACT,KAAK,CAAC,IAAI,CAACU,WAAW,CAACV,KAAK,CAAC,IAAIA,KAAK,CAACW,WAAW,KAAKC,OAAM;AAC3FC,MAAAA,OAAO,GAAIb,KAAK,IAAKc,KAAK,CAACD,OAAO,CAACb,KAAK,EAAC;AAC/C,MAAMS,MAAM,GAAIT,KAAK,IAAKA,KAAK,KAAK,KAAI;AACxC,MAAMU,WAAW,GAAIV,KAAK,IAAK,OAAOA,KAAK,KAAK;;ACRhD;AACA;AACA;AACA;AACA;AACA,MAAMe,OAAO,GAAIf,KAAK,IACnBD,QAAQ,CAACC,KAAK,CAAC,IAAIA,KAAK,CAACgB,MAAM,KAAK,CAAC,IACrC,CAACR,QAAQ,CAACR,KAAK,CAAC,IAAIa,OAAO,CAACb,KAAK,CAAC,KAAKY,MAAM,CAACK,IAAI,CAACjB,KAAK,CAAC,CAACgB,MAAM,KAAK;;ACTjE,MAAME,MAAM,GAAG;AACpBC,EAAAA,KAAK,EAAE;AAAEC,IAAAA,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,CAAC;AAAEC,IAAAA,OAAO,EAAE,EAAA;GAAI;AAC9CC,EAAAA,KAAK,EAAE;AAAEF,IAAAA,GAAG,EAAE,OAAO;AAAEC,IAAAA,OAAO,EAAE,EAAA;GAAI;AACpCE,EAAAA,GAAG,EAAE;AAAEH,IAAAA,GAAG,EAAE,KAAK;AAAEC,IAAAA,OAAO,EAAE,CAAA;GAAG;AAC/BG,EAAAA,MAAM,EAAE;AAAEJ,IAAAA,GAAG,EAAE,QAAQ;AAAEC,IAAAA,OAAO,EAAE,EAAA;AAAG,GAAA;AACvC,CAAC;;ACFD,MAAMI,KAAK,GAAGA,CAAC;EAAEC,OAAO;AAAEC,EAAAA,KAAAA;AAAM,CAAC,KAAK;AACpC,EAAA,IAAI,CAACD,OAAO,IAAI,CAACC,KAAK,EAAE;AACtB,IAAA,OAAO,KAAK,CAAA;AACd,GAAA;AAEA,EAAA,MAAMC,gBAAgB,GAAGF,OAAO,CAACG,WAAW,EAAE,CAAA;AAC9C,EAAA,MAAMC,MAAM,GAAGZ,MAAM,CAACU,gBAAgB,CAAC,CAAA;EACvC,IAAI,CAACE,MAAM,EAAE;AACX,IAAA,OAAO,KAAK,CAAA;AACd,GAAA;EAEA,MAAM;IAAEV,GAAG;AAAEC,IAAAA,OAAAA;AAAQ,GAAC,GAAGM,KAAK,CAAA;AAE9B,EAAA,IAAIP,GAAG,EAAE;IACP,OAAOP,OAAO,CAACiB,MAAM,CAACV,GAAG,CAAC,GAAGU,MAAM,CAACV,GAAG,CAACW,QAAQ,CAACX,GAAG,CAAC,GAAGA,GAAG,KAAKU,MAAM,CAACV,GAAG,CAAA;AAC5E,GAAA;AAEA,EAAA,OAAOC,OAAO,KAAKS,MAAM,CAACT,OAAO,CAAA;AACnC,CAAC,CAAA;AAED,cAAeI,KAAK;;;;"}
package/dist/index.js ADDED
@@ -0,0 +1,73 @@
1
+ 'use strict';
2
+
3
+ const isString = value => typeof value === 'string';
4
+ const isNumber = value => typeof value === 'number' && !Number.isNaN(value);
5
+ const isInteger = value => {
6
+ return isNumber(value) && Math.floor(value) === value;
7
+ };
8
+ const isBoolean = value => typeof value === 'boolean';
9
+ const isObject = value => !isNull(value) && !isUndefined(value) && value.constructor === Object;
10
+ const isArray = value => Array.isArray(value);
11
+ const isNull = value => value === null;
12
+ const isUndefined = value => typeof value === 'undefined';
13
+
14
+ /**
15
+ * Checks empty values for arrays,objects and strings.
16
+ *
17
+ * @param {object | Array | string} value
18
+ */
19
+ const isEmpty = value => isString(value) && value.length === 0 || (isObject(value) || isArray(value)) && Object.keys(value).length === 0;
20
+
21
+ const keyMap = {
22
+ SPACE: {
23
+ key: [' ', 'Spacebar'],
24
+ keyCode: 32
25
+ },
26
+ ENTER: {
27
+ key: 'Enter',
28
+ keyCode: 13
29
+ },
30
+ TAB: {
31
+ key: 'Tab',
32
+ keyCode: 9
33
+ },
34
+ ESCAPE: {
35
+ key: 'Escape',
36
+ keyCode: 27
37
+ }
38
+ };
39
+
40
+ const isKey = ({
41
+ keyType,
42
+ event
43
+ }) => {
44
+ if (!keyType || !event) {
45
+ return false;
46
+ }
47
+ const upperCaseKeyType = keyType.toUpperCase();
48
+ const keyDef = keyMap[upperCaseKeyType];
49
+ if (!keyDef) {
50
+ return false;
51
+ }
52
+ const {
53
+ key,
54
+ keyCode
55
+ } = event;
56
+ if (key) {
57
+ return isArray(keyDef.key) ? keyDef.key.includes(key) : key === keyDef.key;
58
+ }
59
+ return keyCode === keyDef.keyCode;
60
+ };
61
+ var isKey$1 = isKey;
62
+
63
+ exports.isArray = isArray;
64
+ exports.isBoolean = isBoolean;
65
+ exports.isEmpty = isEmpty;
66
+ exports.isInteger = isInteger;
67
+ exports.isKey = isKey$1;
68
+ exports.isNull = isNull;
69
+ exports.isNumber = isNumber;
70
+ exports.isObject = isObject;
71
+ exports.isString = isString;
72
+ exports.isUndefined = isUndefined;
73
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/type-validators/index.js","../src/value-validators/index.js","../src/common/keyMap.js","../src/event-validators/isKey.js"],"sourcesContent":["const isString = (value) => typeof value === 'string';\nconst isNumber = (value) => typeof value === 'number' && !Number.isNaN(value);\nconst isInteger = (value) => {\n return isNumber(value) && Math.floor(value) === value;\n};\nconst isBoolean = (value) => typeof value === 'boolean';\n\nconst isObject = (value) => !isNull(value) && !isUndefined(value) && value.constructor === Object;\nconst isArray = (value) => Array.isArray(value);\nconst isNull = (value) => value === null;\nconst isUndefined = (value) => typeof value === 'undefined';\n\nexport { isString, isNumber, isInteger, isBoolean, isObject, isArray, isNull, isUndefined };\n","import { isString, isObject, isArray } from '../type-validators';\n\n/**\n * Checks empty values for arrays,objects and strings.\n *\n * @param {object | Array | string} value\n */\nconst isEmpty = (value) =>\n (isString(value) && value.length === 0) ||\n ((isObject(value) || isArray(value)) && Object.keys(value).length === 0);\n\nexport { isEmpty };\n","export const keyMap = {\n SPACE: { key: [' ', 'Spacebar'], keyCode: 32 },\n ENTER: { key: 'Enter', keyCode: 13 },\n TAB: { key: 'Tab', keyCode: 9 },\n ESCAPE: { key: 'Escape', keyCode: 27 },\n};\n","import { keyMap } from '../common/keyMap';\nimport { isArray } from '../type-validators';\n\nconst isKey = ({ keyType, event }) => {\n if (!keyType || !event) {\n return false;\n }\n\n const upperCaseKeyType = keyType.toUpperCase();\n const keyDef = keyMap[upperCaseKeyType];\n if (!keyDef) {\n return false;\n }\n\n const { key, keyCode } = event;\n\n if (key) {\n return isArray(keyDef.key) ? keyDef.key.includes(key) : key === keyDef.key;\n }\n\n return keyCode === keyDef.keyCode;\n};\n\nexport default isKey;\n"],"names":["isString","value","isNumber","Number","isNaN","isInteger","Math","floor","isBoolean","isObject","isNull","isUndefined","constructor","Object","isArray","Array","isEmpty","length","keys","keyMap","SPACE","key","keyCode","ENTER","TAB","ESCAPE","isKey","keyType","event","upperCaseKeyType","toUpperCase","keyDef","includes"],"mappings":";;AAAA,MAAMA,QAAQ,GAAIC,KAAK,IAAK,OAAOA,KAAK,KAAK,SAAQ;AACrD,MAAMC,QAAQ,GAAID,KAAK,IAAK,OAAOA,KAAK,KAAK,QAAQ,IAAI,CAACE,MAAM,CAACC,KAAK,CAACH,KAAK,EAAC;AACvEI,MAAAA,SAAS,GAAIJ,KAAK,IAAK;AAC3B,EAAA,OAAOC,QAAQ,CAACD,KAAK,CAAC,IAAIK,IAAI,CAACC,KAAK,CAACN,KAAK,CAAC,KAAKA,KAAK,CAAA;AACvD,EAAC;AACD,MAAMO,SAAS,GAAIP,KAAK,IAAK,OAAOA,KAAK,KAAK,UAAS;AAEjDQ,MAAAA,QAAQ,GAAIR,KAAK,IAAK,CAACS,MAAM,CAACT,KAAK,CAAC,IAAI,CAACU,WAAW,CAACV,KAAK,CAAC,IAAIA,KAAK,CAACW,WAAW,KAAKC,OAAM;AAC3FC,MAAAA,OAAO,GAAIb,KAAK,IAAKc,KAAK,CAACD,OAAO,CAACb,KAAK,EAAC;AAC/C,MAAMS,MAAM,GAAIT,KAAK,IAAKA,KAAK,KAAK,KAAI;AACxC,MAAMU,WAAW,GAAIV,KAAK,IAAK,OAAOA,KAAK,KAAK;;ACRhD;AACA;AACA;AACA;AACA;AACA,MAAMe,OAAO,GAAIf,KAAK,IACnBD,QAAQ,CAACC,KAAK,CAAC,IAAIA,KAAK,CAACgB,MAAM,KAAK,CAAC,IACrC,CAACR,QAAQ,CAACR,KAAK,CAAC,IAAIa,OAAO,CAACb,KAAK,CAAC,KAAKY,MAAM,CAACK,IAAI,CAACjB,KAAK,CAAC,CAACgB,MAAM,KAAK;;ACTjE,MAAME,MAAM,GAAG;AACpBC,EAAAA,KAAK,EAAE;AAAEC,IAAAA,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,CAAC;AAAEC,IAAAA,OAAO,EAAE,EAAA;GAAI;AAC9CC,EAAAA,KAAK,EAAE;AAAEF,IAAAA,GAAG,EAAE,OAAO;AAAEC,IAAAA,OAAO,EAAE,EAAA;GAAI;AACpCE,EAAAA,GAAG,EAAE;AAAEH,IAAAA,GAAG,EAAE,KAAK;AAAEC,IAAAA,OAAO,EAAE,CAAA;GAAG;AAC/BG,EAAAA,MAAM,EAAE;AAAEJ,IAAAA,GAAG,EAAE,QAAQ;AAAEC,IAAAA,OAAO,EAAE,EAAA;AAAG,GAAA;AACvC,CAAC;;ACFD,MAAMI,KAAK,GAAGA,CAAC;EAAEC,OAAO;AAAEC,EAAAA,KAAAA;AAAM,CAAC,KAAK;AACpC,EAAA,IAAI,CAACD,OAAO,IAAI,CAACC,KAAK,EAAE;AACtB,IAAA,OAAO,KAAK,CAAA;AACd,GAAA;AAEA,EAAA,MAAMC,gBAAgB,GAAGF,OAAO,CAACG,WAAW,EAAE,CAAA;AAC9C,EAAA,MAAMC,MAAM,GAAGZ,MAAM,CAACU,gBAAgB,CAAC,CAAA;EACvC,IAAI,CAACE,MAAM,EAAE;AACX,IAAA,OAAO,KAAK,CAAA;AACd,GAAA;EAEA,MAAM;IAAEV,GAAG;AAAEC,IAAAA,OAAAA;AAAQ,GAAC,GAAGM,KAAK,CAAA;AAE9B,EAAA,IAAIP,GAAG,EAAE;IACP,OAAOP,OAAO,CAACiB,MAAM,CAACV,GAAG,CAAC,GAAGU,MAAM,CAACV,GAAG,CAACW,QAAQ,CAACX,GAAG,CAAC,GAAGA,GAAG,KAAKU,MAAM,CAACV,GAAG,CAAA;AAC5E,GAAA;AAEA,EAAA,OAAOC,OAAO,KAAKS,MAAM,CAACT,OAAO,CAAA;AACnC,CAAC,CAAA;AAED,cAAeI,KAAK;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,13 +1,8 @@
1
1
  {
2
2
  "name": "@transferwise/neptune-validation",
3
- "version": "3.0.12",
3
+ "version": "3.1.0",
4
4
  "description": "Neptune Web validation",
5
5
  "license": "Apache-2.0",
6
- "main": "./build/umd/polyfill/main.js",
7
- "module": "./build/es/polyfill/index.js",
8
- "files": [
9
- "build"
10
- ],
11
6
  "keywords": [
12
7
  "wise",
13
8
  "neptune-web-validation"
@@ -17,30 +12,53 @@
17
12
  "fullname": "transferwise/neptune-web",
18
13
  "url": "git+https://github.com/transferwise/neptune-web.git"
19
14
  },
20
- "scripts": {
21
- "test": "jest --env=node --maxWorkers=4 --config=../../node_modules/@transferwise/test-config/jest.config.js",
22
- "test:watch": "jest --watch --env=node --config=../../node_modules/@transferwise/test-config/jest.config.js",
23
- "lint": "jest --maxWorkers=4 --config ../../node_modules/@transferwise/test-config/test/jest.lint.js",
24
- "lint:fix": "eslint 'src/**/*.js' --fix",
25
- "build": "npm-run-all build:*",
26
- "build:clean": "rm -rf build",
27
- "build:umd": "NODE_ENV=umd rollup -c",
28
- "build:es": "NODE_ENV=es babel src -d build/es/polyfill --ignore '**/*.spec.js','**/*.story.js'"
29
- },
15
+ "author": "Wise Payments Ltd.",
16
+ "sideEffects": [
17
+ "*.css"
18
+ ],
19
+ "main": "./dist/index.js",
20
+ "module": "./dist/index.esm.js",
21
+ "types": "./dist/index.d.ts",
22
+ "files": [
23
+ "dist/",
24
+ "src/",
25
+ "!**/*.tsbuildinfo"
26
+ ],
30
27
  "dependencies": {
31
- "@babel/runtime": "^7.18.3",
28
+ "@babel/runtime": "^7.22.15",
32
29
  "core-js": "^3.8.0"
33
30
  },
34
31
  "devDependencies": {
35
- "@rollup/plugin-babel": "^5.2.2",
36
- "@rollup/plugin-commonjs": "^11.0.2",
37
- "@rollup/plugin-node-resolve": "^7.1.3",
38
- "@transferwise/test-config": "^5.0.2",
39
- "rollup": "^2.34.0",
40
- "rollup-plugin-uglify": "^6.0.4"
32
+ "@babel/core": "^7.22.15",
33
+ "@babel/plugin-transform-runtime": "^7.22.15",
34
+ "@babel/preset-env": "^7.22.15",
35
+ "@babel/preset-react": "^7.22.15",
36
+ "@babel/preset-typescript": "^7.22.15",
37
+ "@rollup/plugin-babel": "^6.0.3",
38
+ "@rollup/plugin-node-resolve": "^15.2.1",
39
+ "@rollup/plugin-typescript": "^11.1.3",
40
+ "@transferwise/eslint-config": "^7.4.0",
41
+ "@tsconfig/recommended": "^1.0.2",
42
+ "@types/babel__core": "^7.20.1",
43
+ "@types/jest": "^27.5.2",
44
+ "jest": "^27.0.6",
45
+ "rollup": "^3.28.1"
41
46
  },
42
47
  "publishConfig": {
43
48
  "access": "public"
44
49
  },
45
- "gitHead": "6439551ab2f62ec2206adbf4a49761bdcbbe2127"
46
- }
50
+ "scripts": {
51
+ "test": "jest --env=node --maxWorkers=4",
52
+ "test:watch": "jest --watch --env=node",
53
+ "lint": "pnpm run lint:check",
54
+ "lint:check": "npm-run-all --parallel lint:check:*",
55
+ "lint:check:format": "prettier --check --ignore-path ../../.prettierignore .",
56
+ "lint:check:js+ts": "eslint --ext .js,.jsx,.mjs,.ts,.tsx,.mts --ignore-path ../../.gitignore .",
57
+ "lint:fix": "npm-run-all --serial lint:fix:*",
58
+ "lint:fix:format": "prettier --write --ignore-path ../../../.prettierignore .",
59
+ "lint:fix:js+ts": "pnpm run lint:check:js+ts --fix",
60
+ "build": "npm-run-all build:*",
61
+ "build:clean": "rm -rf dist",
62
+ "build:js": "rollup --config --sourcemap"
63
+ }
64
+ }
@@ -0,0 +1,6 @@
1
+ export const keyMap = {
2
+ SPACE: { key: [' ', 'Spacebar'], keyCode: 32 },
3
+ ENTER: { key: 'Enter', keyCode: 13 },
4
+ TAB: { key: 'Tab', keyCode: 9 },
5
+ ESCAPE: { key: 'Escape', keyCode: 27 },
6
+ };
@@ -0,0 +1 @@
1
+ export { default } from './isKey';
@@ -0,0 +1,24 @@
1
+ import { keyMap } from '../common/keyMap';
2
+ import { isArray } from '../type-validators';
3
+
4
+ const isKey = ({ keyType, event }) => {
5
+ if (!keyType || !event) {
6
+ return false;
7
+ }
8
+
9
+ const upperCaseKeyType = keyType.toUpperCase();
10
+ const keyDef = keyMap[upperCaseKeyType];
11
+ if (!keyDef) {
12
+ return false;
13
+ }
14
+
15
+ const { key, keyCode } = event;
16
+
17
+ if (key) {
18
+ return isArray(keyDef.key) ? keyDef.key.includes(key) : key === keyDef.key;
19
+ }
20
+
21
+ return keyCode === keyDef.keyCode;
22
+ };
23
+
24
+ export default isKey;
@@ -0,0 +1,58 @@
1
+ /* eslint-disable no-console */
2
+ import { keyMap } from '../common/keyMap';
3
+
4
+ import isKey from '.';
5
+
6
+ const { TAB, ESCAPE } = keyMap;
7
+
8
+ describe('isKey', () => {
9
+ it('returns true if eventKey is equal to key', () => {
10
+ const event = { key: 'Tab', keyCode: TAB.keyCode };
11
+ expect(isKey({ keyType: TAB.key, event })).toBe(true);
12
+ });
13
+
14
+ it('returns true if eventKey is equal to empty key', () => {
15
+ const event = { key: ' ' };
16
+ expect(isKey({ keyType: 'Space', event })).toBe(true);
17
+ });
18
+
19
+ it('returns true if eventKey is equal to Spacebar', () => {
20
+ const event = { key: 'Spacebar' };
21
+ expect(isKey({ keyType: 'Space', event })).toBe(true);
22
+ });
23
+
24
+ it('returns true if eventKey is equal to Tab', () => {
25
+ const event = { key: 'Tab' };
26
+ expect(isKey({ keyType: TAB.key, event })).toBe(true);
27
+ });
28
+
29
+ it('returns true if eventKeyCode is equal to key', () => {
30
+ const event = { keyCode: TAB.keyCode };
31
+ expect(isKey({ keyType: TAB.key, event })).toBe(true);
32
+ });
33
+
34
+ it('returns false if key is not defined', () => {
35
+ const event = { keyCode: TAB.keyCode };
36
+ expect(isKey({ event })).toBe(false);
37
+ });
38
+
39
+ it('returns false if event is not defined', () => {
40
+ const event = null;
41
+ expect(isKey({ event })).toBe(false);
42
+ });
43
+
44
+ it('returns false if eventKey or eventKeyCode are not defined', () => {
45
+ const event = {};
46
+ expect(isKey({ keyType: TAB.key, event })).toBe(false);
47
+ });
48
+
49
+ it('returns false if eventKey is equal to key', () => {
50
+ const event = { key: 'Escape', keyCode: ESCAPE.keyCode };
51
+ expect(isKey({ keyType: TAB.key, event })).toBe(false);
52
+ });
53
+
54
+ it('returns false if eventKeyCode is equal to key', () => {
55
+ const event = { keyCode: ESCAPE.keyCode };
56
+ expect(isKey({ keyType: TAB.key, event })).toBe(false);
57
+ });
58
+ });
package/src/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './type-validators';
2
+ export * from './value-validators';
3
+ export { default as isKey } from './event-validators';
@@ -0,0 +1,13 @@
1
+ const isString = (value) => typeof value === 'string';
2
+ const isNumber = (value) => typeof value === 'number' && !Number.isNaN(value);
3
+ const isInteger = (value) => {
4
+ return isNumber(value) && Math.floor(value) === value;
5
+ };
6
+ const isBoolean = (value) => typeof value === 'boolean';
7
+
8
+ const isObject = (value) => !isNull(value) && !isUndefined(value) && value.constructor === Object;
9
+ const isArray = (value) => Array.isArray(value);
10
+ const isNull = (value) => value === null;
11
+ const isUndefined = (value) => typeof value === 'undefined';
12
+
13
+ export { isString, isNumber, isInteger, isBoolean, isObject, isArray, isNull, isUndefined };
@@ -0,0 +1,140 @@
1
+ import {
2
+ isString,
3
+ isNumber,
4
+ isInteger,
5
+ isBoolean,
6
+ isArray,
7
+ isObject,
8
+ isNull,
9
+ isUndefined,
10
+ } from '.';
11
+
12
+ describe('given a library for validating data types', () => {
13
+ describe('when validating a string', () => {
14
+ it('should return true when the value is a string', () => {
15
+ expect(isString('a')).toBe(true);
16
+ expect(isString('')).toBe(true);
17
+ });
18
+ it('should return false when the value is not string', () => {
19
+ expect(isString(1)).toBe(false);
20
+ expect(isString(true)).toBe(false);
21
+ expect(isString([])).toBe(false);
22
+ expect(isString({})).toBe(false);
23
+ expect(isString(undefined)).toBe(false);
24
+ expect(isString(null)).toBe(false);
25
+ expect(isString(NaN)).toBe(false);
26
+ });
27
+ });
28
+
29
+ describe('when validating a number', () => {
30
+ it('should return true when the value is a number', () => {
31
+ expect(isNumber(1)).toBe(true);
32
+ expect(isNumber(0)).toBe(true);
33
+ expect(isNumber(1.23)).toBe(true);
34
+ expect(isNumber(-1)).toBe(true);
35
+ });
36
+ it('should return false when the value is not number', () => {
37
+ expect(isNumber('a')).toBe(false);
38
+ expect(isNumber(true)).toBe(false);
39
+ expect(isNumber([])).toBe(false);
40
+ expect(isNumber({})).toBe(false);
41
+ expect(isNumber(undefined)).toBe(false);
42
+ expect(isNumber(null)).toBe(false);
43
+ expect(isNumber(NaN)).toBe(false);
44
+ });
45
+ });
46
+
47
+ describe('when validating an integer', () => {
48
+ it('should return true when the value is a integer', () => {
49
+ expect(isInteger(1)).toBe(true);
50
+ expect(isInteger(0)).toBe(true);
51
+ expect(isInteger(-1)).toBe(true);
52
+ });
53
+ it('should return false when the value is not an integer', () => {
54
+ expect(isInteger(1.23)).toBe(false);
55
+ expect(isInteger('a')).toBe(false);
56
+ expect(isInteger(true)).toBe(false);
57
+ expect(isInteger([])).toBe(false);
58
+ expect(isInteger({})).toBe(false);
59
+ expect(isInteger(undefined)).toBe(false);
60
+ expect(isInteger(null)).toBe(false);
61
+ expect(isInteger(NaN)).toBe(false);
62
+ });
63
+ });
64
+
65
+ describe('when validating a boolean', () => {
66
+ it('should return true when the value is a boolean', () => {
67
+ expect(isBoolean(true)).toBe(true);
68
+ expect(isBoolean(false)).toBe(true);
69
+ });
70
+ it('should return false when the value is not a boolean', () => {
71
+ expect(isBoolean(1)).toBe(false);
72
+ expect(isBoolean('a')).toBe(false);
73
+ expect(isBoolean([])).toBe(false);
74
+ expect(isBoolean({})).toBe(false);
75
+ expect(isBoolean(undefined)).toBe(false);
76
+ expect(isBoolean(null)).toBe(false);
77
+ expect(isBoolean(NaN)).toBe(false);
78
+ });
79
+ });
80
+
81
+ describe('when validating an array', () => {
82
+ it('should return true when the value is an array', () => {
83
+ expect(isArray([1])).toBe(true);
84
+ expect(isArray([])).toBe(true);
85
+ });
86
+ it('should return false when the value is not an array', () => {
87
+ expect(isArray(1)).toBe(false);
88
+ expect(isArray('a')).toBe(false);
89
+ expect(isArray(true)).toBe(false);
90
+ expect(isArray({})).toBe(false);
91
+ expect(isArray(undefined)).toBe(false);
92
+ expect(isArray(null)).toBe(false);
93
+ expect(isArray(NaN)).toBe(false);
94
+ });
95
+ });
96
+
97
+ describe('when validating an object', () => {
98
+ it('should return true when the value is an object', () => {
99
+ expect(isObject({ a: 1 })).toBe(true);
100
+ expect(isObject({})).toBe(true);
101
+ });
102
+ it('should return false when the value is not an object', () => {
103
+ expect(isObject(1)).toBe(false);
104
+ expect(isObject('a')).toBe(false);
105
+ expect(isObject(true)).toBe(false);
106
+ expect(isObject([])).toBe(false);
107
+ expect(isObject(undefined)).toBe(false);
108
+ expect(isObject(null)).toBe(false);
109
+ expect(isObject(NaN)).toBe(false);
110
+ });
111
+ });
112
+
113
+ describe('when validating a null', () => {
114
+ it('should return true when the value is null', () => {
115
+ expect(isNull(null)).toBe(true);
116
+ });
117
+ it('should return false when the value is not null', () => {
118
+ expect(isNull(0)).toBe(false);
119
+ expect(isNull(false)).toBe(false);
120
+ expect(isNull([])).toBe(false);
121
+ expect(isNull({})).toBe(false);
122
+ expect(isNull(undefined)).toBe(false);
123
+ expect(isNull(NaN)).toBe(false);
124
+ });
125
+ });
126
+
127
+ describe('when validating an undefined', () => {
128
+ it('should return true when the value is undefined', () => {
129
+ expect(isUndefined(undefined)).toBe(true);
130
+ });
131
+ it('should return false when the value is not undefined', () => {
132
+ expect(isUndefined(0)).toBe(false);
133
+ expect(isUndefined(false)).toBe(false);
134
+ expect(isUndefined([])).toBe(false);
135
+ expect(isUndefined({})).toBe(false);
136
+ expect(isUndefined(null)).toBe(false);
137
+ expect(isUndefined(NaN)).toBe(false);
138
+ });
139
+ });
140
+ });
@@ -0,0 +1,12 @@
1
+ import { isString, isObject, isArray } from '../type-validators';
2
+
3
+ /**
4
+ * Checks empty values for arrays,objects and strings.
5
+ *
6
+ * @param {object | Array | string} value
7
+ */
8
+ const isEmpty = (value) =>
9
+ (isString(value) && value.length === 0) ||
10
+ ((isObject(value) || isArray(value)) && Object.keys(value).length === 0);
11
+
12
+ export { isEmpty };
@@ -0,0 +1,23 @@
1
+ import { isEmpty } from '.';
2
+
3
+ describe('given a library for validating values', () => {
4
+ describe('when checking for empty values', () => {
5
+ it('should return true for empty strings', () => {
6
+ expect(isEmpty('')).toBe(true);
7
+ expect(isEmpty('a')).toBe(false);
8
+ });
9
+ it('should return true for empty array', () => {
10
+ expect(isEmpty([])).toBe(true);
11
+ expect(isEmpty(['a'])).toBe(false);
12
+ });
13
+ it('should return true for empty object', () => {
14
+ expect(isEmpty({})).toBe(true);
15
+ expect(isEmpty({ a: 'a' })).toBe(false);
16
+ });
17
+ it('should return false when the value is not a string, array, or object', () => {
18
+ expect(isEmpty(1)).toBe(false);
19
+ expect(isEmpty(null)).toBe(false);
20
+ expect(isEmpty(undefined)).toBe(false);
21
+ });
22
+ });
23
+ });
@@ -1 +0,0 @@
1
- export var keyMap={SPACE:{key:[" ","Spacebar"],keyCode:32},ENTER:{key:"Enter",keyCode:13},TAB:{key:"Tab",keyCode:9},ESCAPE:{key:"Escape",keyCode:27}};
@@ -1 +0,0 @@
1
- export{default}from"./isKey";
@@ -1 +0,0 @@
1
- import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.js";import{keyMap}from"../common/keyMap";import{isArray}from"../type-validators";var isKey=function(a){var b=a.keyType,c=a.event;if(!b||!c)return!1;var d=b.toUpperCase(),e=keyMap[d];if(!e)return!1;var f=c.key,g=c.keyCode;return f?isArray(e.key)?e.key.includes(f):f===e.key:g===e.keyCode};export default isKey;
@@ -1 +0,0 @@
1
- export*from"./type-validators";export*from"./value-validators";export{default as isKey}from"./event-validators";
@@ -1 +0,0 @@
1
- import"core-js/modules/es.number.is-nan.js";import"core-js/modules/es.number.constructor.js";var isString=function(a){return"string"==typeof a},isNumber=function(a){return"number"==typeof a&&!Number.isNaN(a)},isInteger=function(a){return isNumber(a)&&Math.floor(a)===a},isBoolean=function(a){return"boolean"==typeof a},isObject=function(a){return!isNull(a)&&!isUndefined(a)&&a.constructor===Object},isArray=function(a){return Array.isArray(a)},isNull=function(a){return null===a},isUndefined=function(a){return"undefined"==typeof a};export{isString,isNumber,isInteger,isBoolean,isObject,isArray,isNull,isUndefined};
@@ -1 +0,0 @@
1
- import{isString,isNumber,isInteger,isBoolean,isArray,isObject,isNull,isUndefined}from".";describe("Given a library for validating data types",function(){describe("when validating a string",function(){it("should return true when the value is a string",function(){expect(isString("a")).toBe(!0),expect(isString("")).toBe(!0)}),it("should return false when the value is not string",function(){expect(isString(1)).toBe(!1),expect(isString(!0)).toBe(!1),expect(isString([])).toBe(!1),expect(isString({})).toBe(!1),expect(isString(void 0)).toBe(!1),expect(isString(null)).toBe(!1),expect(isString(NaN)).toBe(!1)})}),describe("when validating a number",function(){it("should return true when the value is a number",function(){expect(isNumber(1)).toBe(!0),expect(isNumber(0)).toBe(!0),expect(isNumber(1.23)).toBe(!0),expect(isNumber(-1)).toBe(!0)}),it("should return false when the value is not number",function(){expect(isNumber("a")).toBe(!1),expect(isNumber(!0)).toBe(!1),expect(isNumber([])).toBe(!1),expect(isNumber({})).toBe(!1),expect(isNumber(void 0)).toBe(!1),expect(isNumber(null)).toBe(!1),expect(isNumber(NaN)).toBe(!1)})}),describe("when validating an integer",function(){it("should return true when the value is a integer",function(){expect(isInteger(1)).toBe(!0),expect(isInteger(0)).toBe(!0),expect(isInteger(-1)).toBe(!0)}),it("should return false when the value is not an integer",function(){expect(isInteger(1.23)).toBe(!1),expect(isInteger("a")).toBe(!1),expect(isInteger(!0)).toBe(!1),expect(isInteger([])).toBe(!1),expect(isInteger({})).toBe(!1),expect(isInteger(void 0)).toBe(!1),expect(isInteger(null)).toBe(!1),expect(isInteger(NaN)).toBe(!1)})}),describe("when validating a boolean",function(){it("should return true when the value is a boolean",function(){expect(isBoolean(!0)).toBe(!0),expect(isBoolean(!1)).toBe(!0)}),it("should return false when the value is not a boolean",function(){expect(isBoolean(1)).toBe(!1),expect(isBoolean("a")).toBe(!1),expect(isBoolean([])).toBe(!1),expect(isBoolean({})).toBe(!1),expect(isBoolean(void 0)).toBe(!1),expect(isBoolean(null)).toBe(!1),expect(isBoolean(NaN)).toBe(!1)})}),describe("when validating an array",function(){it("should return true when the value is an array",function(){expect(isArray([1])).toBe(!0),expect(isArray([])).toBe(!0)}),it("should return false when the value is not an array",function(){expect(isArray(1)).toBe(!1),expect(isArray("a")).toBe(!1),expect(isArray(!0)).toBe(!1),expect(isArray({})).toBe(!1),expect(isArray(void 0)).toBe(!1),expect(isArray(null)).toBe(!1),expect(isArray(NaN)).toBe(!1)})}),describe("when validating an object",function(){it("should return true when the value is an object",function(){expect(isObject({a:1})).toBe(!0),expect(isObject({})).toBe(!0)}),it("should return false when the value is not an object",function(){expect(isObject(1)).toBe(!1),expect(isObject("a")).toBe(!1),expect(isObject(!0)).toBe(!1),expect(isObject([])).toBe(!1),expect(isObject(void 0)).toBe(!1),expect(isObject(null)).toBe(!1),expect(isObject(NaN)).toBe(!1)})}),describe("when validating a null",function(){it("should return true when the value is null",function(){expect(isNull(null)).toBe(!0)}),it("should return false when the value is not null",function(){expect(isNull(0)).toBe(!1),expect(isNull(!1)).toBe(!1),expect(isNull([])).toBe(!1),expect(isNull({})).toBe(!1),expect(isNull(void 0)).toBe(!1),expect(isNull(NaN)).toBe(!1)})}),describe("when validating an undefined",function(){it("should return true when the value is undefined",function(){expect(isUndefined(void 0)).toBe(!0)}),it("should return false when the value is not undefined",function(){expect(isUndefined(0)).toBe(!1),expect(isUndefined(!1)).toBe(!1),expect(isUndefined([])).toBe(!1),expect(isUndefined({})).toBe(!1),expect(isUndefined(null)).toBe(!1),expect(isUndefined(NaN)).toBe(!1)})})});
@@ -1,5 +0,0 @@
1
- import"core-js/modules/es.object.keys.js";import{isString,isObject,isArray}from"../type-validators";/**
2
- * Checks empty values for arrays,objects and strings.
3
- *
4
- * @param {object | Array | string} value
5
- */var isEmpty=function(a){return isString(a)&&0===a.length||(isObject(a)||isArray(a))&&0===Object.keys(a).length};export{isEmpty};
@@ -1 +0,0 @@
1
- import{isEmpty}from".";describe("Given a library for validating values",function(){describe("when checking for empty values",function(){it("should return true for empty strings",function(){expect(isEmpty("")).toBe(!0),expect(isEmpty("a")).toBe(!1)}),it("should return true for empty array",function(){expect(isEmpty([])).toBe(!0),expect(isEmpty(["a"])).toBe(!1)}),it("should return true for empty object",function(){expect(isEmpty({})).toBe(!0),expect(isEmpty({a:"a"})).toBe(!1)}),it("should return false when the value is not a string, array, or object",function(){expect(isEmpty(1)).toBe(!1),expect(isEmpty(null)).toBe(!1),expect(isEmpty(void 0)).toBe(!1)})})});
@@ -1 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["@transferwise/neptune-validation"]={})}(this,function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(t,e){return t(e={exports:{}},e.exports),e.exports}function f(t){try{return!!t()}catch(t){return!0}}function r(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}function o(t){return C(k(t),8,-1)}function i(t){if("Function"===o(t))return A(t)}function u(t){return null==t}function c(t){if(u(t))throw L("Can't call method on "+t);return t}function a(t){return x(c(t))}function l(t,e){return arguments.length<2?(n=O[t],R(n)?n:void 0):O[t]&&O[t][e];var n}function s(t){if(R(t))return t;throw K(function(t){try{return Y(t)}catch(t){return"Object"}}(t)+" is not a function")}function p(e,n){try{q(O,e,{value:n,configurable:!0,writable:!0})}catch(t){O[e]=n}return n}function y(t){return Q(c(t))}function b(t){return"Symbol("+(void 0===t?"":t)+")_"+rt(++et+nt,36)}function g(t,e){if(!U(t)||H(t))return t;var n=function(t,e){e=t[e];return u(e)?void 0:s(e)}(t,at);if(n){if(n=E(n,t,e=void 0===e?"default":e),!U(n)||H(n))return n;throw ft("Can't convert object to primitive value")}return function(t,e){var n,r;if("string"===e&&R(n=t.toString)&&!U(r=E(n,t)))return r;if(R(n=t.valueOf)&&!U(r=E(n,t)))return r;if("string"!==e&&R(n=t.toString)&&!U(r=E(n,t)))return r;throw $("Can't convert object to primitive value")}(t,e=void 0===e?"number":e)}function d(t){return t=g(t,"string"),H(t)?t:t+""}function h(t){return st?lt.createElement(t):{}}function v(t){if(U(t))return t;throw dt(gt(t)+" is not an object")}var m=function(t){return t&&t.Math==Math&&t},O=m("object"==typeof globalThis&&globalThis)||m("object"==typeof window&&window)||m("object"==typeof self&&self)||m("object"==typeof e&&e)||function(){return this}()||Function("return this")(),S=!f(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),j=!f(function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}),w=Function.prototype.call,E=j?w.bind(w):function(){return w.apply(w,arguments)},T={}.propertyIsEnumerable,N=Object.getOwnPropertyDescriptor,I={f:N&&!T.call({1:2},1)?function(t){t=N(this,t);return!!t&&t.enumerable}:T},P=Function.prototype,_=P.call,m=j&&P.bind.bind(_,_),A=j?m:function(t){return function(){return _.apply(t,arguments)}},k=A({}.toString),C=A("".slice),M=Object,F=i("".split),x=f(function(){return!M("z").propertyIsEnumerable(0)})?function(t){return"String"==o(t)?F(t,""):M(t)}:M,L=TypeError,e="object"==typeof document&&document.all,T={all:e,IS_HTMLDDA:void 0===e&&void 0!==e},D=T.all,R=T.IS_HTMLDDA?function(t){return"function"==typeof t||t===D}:function(t){return"function"==typeof t},z=T.all,U=T.IS_HTMLDDA?function(t){return"object"==typeof t?null!==t:R(t)||t===z}:function(t){return"object"==typeof t?null!==t:R(t)},G=i({}.isPrototypeOf),P=l("navigator","userAgent")||"",j=O.process,m=O.Deno,e=j&&j.versions||m&&m.version,T=e&&e.v8,V=Nt=!(Nt=T?0<(Tt=T.split("."))[0]&&Tt[0]<4?1:+(Tt[0]+Tt[1]):Nt)&&P&&(!(Tt=P.match(/Edge\/(\d+)/))||74<=Tt[1])&&(Tt=P.match(/Chrome\/(\d+)/))?+Tt[1]:Nt,W=!!Object.getOwnPropertySymbols&&!f(function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&V&&V<41}),B=W&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,X=Object,H=B?function(t){return"symbol"==typeof t}:function(t){var e=l("Symbol");return R(e)&&G(e.prototype,X(t))},Y=String,K=TypeError,$=TypeError,q=Object.defineProperty,j="__core-js_shared__",J=O[j]||p(j,{}),m=n(function(t){(t.exports=function(t,e){return J[t]||(J[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.26.0",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.0/LICENSE",source:"https://github.com/zloirock/core-js"})}),Q=Object,Z=i({}.hasOwnProperty),tt=Object.hasOwn||function(t,e){return Z(y(t),e)},et=0,nt=Math.random(),rt=i(1..toString),ot=m("wks"),it=O.Symbol,ut=it&&it.for,ct=B?it:it&&it.withoutSetter||b,e=function(t){var e;return tt(ot,t)&&(W||"string"==typeof ot[t])||(e="Symbol."+t,W&&tt(it,t)?ot[t]=it[t]:ot[t]=(B&&ut?ut:ct)(e)),ot[t]},ft=TypeError,at=e("toPrimitive"),lt=O.document,st=U(lt)&&U(lt.createElement),pt=!S&&!f(function(){return 7!=Object.defineProperty(h("div"),"a",{get:function(){return 7}}).a}),yt=Object.getOwnPropertyDescriptor,bt={f:S?yt:function(t,e){if(t=a(t),e=d(e),pt)try{return yt(t,e)}catch(t){}if(tt(t,e))return r(!E(I.f,t,e),t[e])}},T=S&&f(function(){return 42!=Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype}),gt=String,dt=TypeError,ht=TypeError,vt=Object.defineProperty,mt=Object.getOwnPropertyDescriptor,Ot="enumerable",St="configurable",jt="writable",wt={f:S?T?function(t,e,n){var r;return v(t),e=d(e),v(n),"function"==typeof t&&"prototype"===e&&"value"in n&&jt in n&&!n[jt]&&((r=mt(t,e))&&r[jt]&&(t[e]=n.value,n={configurable:(St in n?n:r)[St],enumerable:(Ot in n?n:r)[Ot],writable:!1})),vt(t,e,n)}:vt:function(t,e,n){if(v(t),e=d(e),v(n),pt)try{return vt(t,e,n)}catch(t){}if("get"in n||"set"in n)throw ht("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},Et=S?function(t,e,n){return wt.f(t,e,r(1,n))}:function(t,e,n){return t[e]=n,t},P=Function.prototype,Tt=S&&Object.getOwnPropertyDescriptor,Nt=tt(P,"name"),It={EXISTS:Nt,PROPER:Nt&&"something"===function(){}.name,CONFIGURABLE:Nt&&(!S||S&&Tt(P,"name").configurable)},Pt=i(Function.toString);R(J.inspectSource)||(J.inspectSource=function(t){return Pt(t)});function _t(t,e,n,r){var o=(r=r||{}).enumerable,i=void 0!==r.name?r.name:e;if(R(n)&&Bt(n,i,r),r.global)o?t[e]=n:p(e,n);else{try{r.unsafe?t[e]&&(o=!0):delete t[e]}catch(t){}o?t[e]=n:wt.f(t,e,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return t}function At(t){return(t=+t)!=t||0==t?0:Yt(t)}function kt(t){return 0<(t=t.length)?qt(At(t),9007199254740991):0}function Ct(t,e){var n,r=a(t),o=0,i=[];for(n in r)!tt(zt,n)&&tt(r,n)&&Qt(i,n);for(;e.length>o;)tt(r,n=e[o++])&&(~Jt(i,n)||Qt(i,n));return i}var Mt,Ft,xt,Lt,Dt=J.inspectSource,j=O.WeakMap,Nt=R(j)&&/native code/.test(String(j)),Rt=m("keys"),Tt=function(t){return Rt[t]||(Rt[t]=b(t))},zt={},Ut="Object already initialized",Gt=O.TypeError,P=O.WeakMap,Vt=Nt||J.state?((xt=J.state||(J.state=new P)).get=xt.get,xt.has=xt.has,xt.set=xt.set,Mt=function(t,e){if(xt.has(t))throw Gt(Ut);return e.facade=t,xt.set(t,e),e},Ft=function(t){return xt.get(t)||{}},function(t){return xt.has(t)}):(Lt=Tt("state"),zt[Lt]=!0,Mt=function(t,e){if(tt(t,Lt))throw Gt(Ut);return e.facade=t,Et(t,Lt,e),e},Ft=function(t){return tt(t,Lt)?t[Lt]:{}},function(t){return tt(t,Lt)}),Wt={set:Mt,get:Ft,has:Vt,enforce:function(t){return Vt(t)?Ft(t):Mt(t,{})},getterFor:function(n){return function(t){var e;if(!U(t)||(e=Ft(t)).type!==n)throw Gt("Incompatible receiver, "+n+" required");return e}}},Bt=n(function(t){var r=It.CONFIGURABLE,o=Wt.enforce,e=Wt.get,i=Object.defineProperty,u=S&&!f(function(){return 8!==i(function(){},"length",{value:8}).length}),c=String(String).split("String"),t=t.exports=function(t,e,n){"Symbol("===String(e).slice(0,7)&&(e="["+String(e).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(e="get "+e),n&&n.setter&&(e="set "+e),(!tt(t,"name")||r&&t.name!==e)&&(S?i(t,"name",{value:e,configurable:!0}):t.name=e),u&&n&&tt(n,"arity")&&t.length!==n.arity&&i(t,"length",{value:n.arity});try{n&&tt(n,"constructor")&&n.constructor?S&&i(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}n=o(t);return tt(n,"source")||(n.source=c.join("string"==typeof e?e:"")),t};Function.prototype.toString=t(function(){return R(this)&&e(this).source||Dt(this)},"toString")}),Xt=Math.ceil,Ht=Math.floor,Yt=Math.trunc||function(t){t=+t;return(0<t?Ht:Xt)(t)},Kt=Math.max,$t=Math.min,qt=Math.min,j=function(c){return function(t,e,n){var r,o=a(t),i=kt(o),u=function(t,e){t=At(t);return t<0?Kt(t+e,0):$t(t,e)}(n,i);if(c&&e!=e){for(;u<i;)if((r=o[u++])!=r)return!0}else for(;u<i;u++)if((c||u in o)&&o[u]===e)return c||u||0;return!c&&-1}},m={includes:j(!0),indexOf:j(!1)},Jt=m.indexOf,Qt=i([].push),Zt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],te=Zt.concat("length","prototype"),ee={f:Object.getOwnPropertyNames||function(t){return Ct(t,te)}},ne={f:Object.getOwnPropertySymbols},re=i([].concat),oe=l("Reflect","ownKeys")||function(t){var e=ee.f(v(t)),n=ne.f;return n?re(e,n(t)):e},ie=/#|\.prototype\./,Nt=function(t,e){t=ce[ue(t)];return t==ae||t!=fe&&(R(e)?f(e):!!e)},ue=Nt.normalize=function(t){return String(t).replace(ie,".").toLowerCase()},ce=Nt.data={},fe=Nt.NATIVE="N",ae=Nt.POLYFILL="P",le=Nt,se=bt.f,P=function(t,e){var n,r,o,i=t.target,u=t.global,c=t.stat,f=u?O:c?O[i]||p(i,{}):(O[i]||{}).prototype;if(f)for(n in e){if(r=e[n],o=t.dontCallGetSet?(o=se(f,n))&&o.value:f[n],!le(u?n:i+(c?".":"#")+n,t.forced)&&void 0!==o){if(typeof r==typeof o)continue;!function(t,e,n){for(var r=oe(e),o=wt.f,i=bt.f,u=0;u<r.length;u++){var c=r[u];tt(t,c)||n&&tt(n,c)||o(t,c,i(e,c))}}(r,o)}(t.sham||o&&o.sham)&&Et(r,"sham",!0),_t(f,n,r,t)}};P({target:"Number",stat:!0},{isNaN:function(t){return t!=t}});var pe=String,ye=TypeError,be=Object.setPrototypeOf||("__proto__"in{}?function(){var n,r=!1,t={};try{(n=i(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(t,[]),r=t instanceof Array}catch(t){}return function(t,e){return v(t),function(t){if("object"==typeof t||R(t))return;throw ye("Can't set "+pe(t)+" as a prototype")}(e),r?n(t,e):t.__proto__=e,t}}():void 0),ge=i(1..valueOf),j={};j[e("toStringTag")]="z";function de(t){if("Symbol"===Oe(t))throw TypeError("Cannot convert a Symbol value to a string");return Se(t)}var Nt="[object z]"===String(j),he=e("toStringTag"),ve=Object,me="Arguments"==o(function(){return arguments}()),Oe=Nt?o:function(t){var e;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(t=function(t,e){try{return t[e]}catch(t){}}(e=ve(t),he))?t:me?o(e):"Object"==(t=o(e))&&R(e.callee)?"Arguments":t},Se=String,je=i("".replace),j="[\t\n\v\f\r                 \u2028\u2029\ufeff]",we=RegExp("^"+j+j+"*"),Ee=RegExp(j+j+"*$"),Nt=function(e){return function(t){t=de(c(t));return 1&e&&(t=je(t,we,"")),t=2&e?je(t,Ee,""):t}},j={start:Nt(1),end:Nt(2),trim:Nt(3)},Nt=ee.f,Te=bt.f,Ne=wt.f,Ie=j.trim,j="Number",Pe=O[j],_e=Pe.prototype,Ae=O.TypeError,ke=i("".slice),Ce=i("".charCodeAt),Me=function(t){var e,n,r,o,i,u,c,f=g(t,"number");if(H(f))throw Ae("Cannot convert a Symbol value to a number");if("string"==typeof f&&2<f.length)if(f=Ie(f),43===(e=Ce(f,0))||45===e){if(88===(t=Ce(f,2))||120===t)return NaN}else if(48===e){switch(Ce(f,1)){case 66:case 98:n=2,r=49;break;case 79:case 111:n=8,r=55;break;default:return+f}for(i=(o=ke(f,2)).length,u=0;u<i;u++)if((c=Ce(o,u))<48||r<c)return NaN;return parseInt(o,n)}return+f};if(le(j,!Pe(" 0o1")||!Pe("0b1")||Pe("+0x1"))){for(var Fe,xe=function(t){var e,n,r,o,i=arguments.length<1?0:Pe(function(t){t=g(t,"number");return"bigint"==typeof t?t:Me(t)}(t)),u=this;return G(_e,u)&&f(function(){ge(u)})?(e=Object(i),n=u,t=xe,be&&R(r=n.constructor)&&r!==t&&U(o=r.prototype)&&o!==t.prototype&&be(e,o),e):i},Le=S?Nt(Pe):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),De=0;Le.length>De;De++)tt(Pe,Fe=Le[De])&&!tt(xe,Fe)&&Ne(xe,Fe,Te(Pe,Fe));(xe.prototype=_e).constructor=xe,_t(O,j,xe,{constructor:!0})}function Re(t){return"string"==typeof t}function ze(t){return"number"==typeof t&&!Number.isNaN(t)}function Ue(t){return!Ve(t)&&!We(t)&&t.constructor===Object}function Ge(t){return Array.isArray(t)}var Ve=function(t){return null===t},We=function(t){return void 0===t},Be=Object.keys||function(t){return Ct(t,Zt)};P({target:"Object",stat:!0,forced:f(function(){Be(1)})},{keys:function(t){return Be(y(t))}});function Xe(){}function He(t){return"<script>"+t+"</"+Qe+">"}function Ye(t){t.write(He("")),t.close();var e=t.parentWindow.Object;return t=null,e}var Ke,$e={f:S&&!T?Object.defineProperties:function(t,e){v(t);for(var n,r=a(e),o=Be(e),i=o.length,u=0;u<i;)wt.f(t,n=o[u++],r[n]);return t}},qe=l("document","documentElement"),Je="prototype",Qe="script",Ze=Tt("IE_PROTO"),tn=function(){try{Ke=new ActiveXObject("htmlfile")}catch(t){}var t;tn="undefined"==typeof document||document.domain&&Ke?Ye(Ke):((t=h("iframe")).style.display="none",qe.appendChild(t),t.src=String("javascript:"),(t=t.contentWindow.document).open(),t.write(He("document.F=Object")),t.close(),t.F);for(var e=Zt.length;e--;)delete tn[Je][Zt[e]];return tn()};zt[Ze]=!0;var T=Object.create||function(t,e){var n;return null!==t?(Xe[Je]=v(t),n=new Xe,Xe[Je]=null,n[Ze]=t):n=tn(),void 0===e?n:$e.f(n,e)},Tt=wt.f,en=e("unscopables"),nn=Array.prototype;null==nn[en]&&Tt(nn,en,{configurable:!0,value:T(null)});var rn=m.includes;P({target:"Array",proto:!0,forced:f(function(){return!Array(1).includes()})},{includes:function(t){return rn(this,t,1<arguments.length?arguments[1]:void 0)}}),nn[en].includes=!0;function on(t){if(U(e=t)&&(void 0!==(n=e[un])?!!n:"RegExp"==o(e)))throw cn("The method doesn't accept regular expressions");var e,n;return t}var un=e("match"),cn=TypeError,fn=e("match"),an=i("".indexOf);P({target:"String",proto:!0,forced:!function(e){var n=/./;try{"/./"[e](n)}catch(t){try{return n[fn]=!1,"/./"[e](n)}catch(t){}}return!1}("includes")},{includes:function(t){return!!~an(de(c(this)),de(on(t)),1<arguments.length?arguments[1]:void 0)}});var ln={SPACE:{key:[" ","Spacebar"],keyCode:32},ENTER:{key:"Enter",keyCode:13},TAB:{key:"Tab",keyCode:9},ESCAPE:{key:"Escape",keyCode:27}};t.isArray=Ge,t.isBoolean=function(t){return"boolean"==typeof t},t.isEmpty=function(t){return Re(t)&&0===t.length||(Ue(t)||Ge(t))&&0===Object.keys(t).length},t.isInteger=function(t){return ze(t)&&Math.floor(t)===t},t.isKey=function(t){var e=t.keyType,n=t.event;if(!e||!n)return!1;t=e.toUpperCase(),e=ln[t];if(!e)return!1;t=n.key,n=n.keyCode;return t?Ge(e.key)?e.key.includes(t):t===e.key:n===e.keyCode},t.isNull=Ve,t.isNumber=ze,t.isObject=Ue,t.isString=Re,t.isUndefined=We,Object.defineProperty(t,"__esModule",{value:!0})});