ejv 1.1.10 → 1.1.11

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/build/util.js CHANGED
@@ -1,66 +1,68 @@
1
- "use strict";
2
- var __spreadArrays = (this && this.__spreadArrays) || function () {
3
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
4
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
5
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6
- r[k] = a[j];
7
- return r;
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.clone = void 0;
11
- var clone = function (obj) {
12
- var result = null;
13
- if (!!obj) {
14
- var type = typeof obj;
15
- if (type === 'object') {
16
- if (obj.push !== undefined && typeof obj.push === 'function') {
17
- type = 'array';
18
- }
19
- else if (obj.getFullYear !== undefined && typeof obj.getFullYear === 'function') {
20
- type = 'date';
21
- }
22
- else if (obj.byteLength !== undefined) {
23
- type = 'buffer';
24
- }
25
- else if (obj.exec !== undefined && obj.test !== undefined) {
26
- type = 'regexp';
27
- }
28
- }
29
- switch (type) {
30
- case 'boolean':
31
- case 'number':
32
- case 'function':
33
- case 'string':
34
- case 'buffer':
35
- // ok with simple copy
36
- result = obj;
37
- break;
38
- case 'regexp':
39
- result = new RegExp(obj);
40
- break;
41
- case 'date':
42
- result = new Date(obj);
43
- break;
44
- case 'array':
45
- result = __spreadArrays(obj.map(function (one) {
46
- return exports.clone(one);
47
- }));
48
- break;
49
- case 'object':
50
- // sanitize default false
51
- result = {};
52
- Object.keys(obj)
53
- .forEach(function (key) {
54
- // recursively call
55
- result[key] = exports.clone(obj[key]);
56
- });
57
- break;
58
- }
59
- }
60
- else {
61
- result = obj; // do not copy null & undefined
62
- }
63
- return result;
64
- };
65
- exports.clone = clone;
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.clone = void 0;
13
+ var clone = function (obj) {
14
+ var result = null;
15
+ if (!!obj) {
16
+ var type = typeof obj;
17
+ if (type === 'object') {
18
+ if (obj.push !== undefined && typeof obj.push === 'function') {
19
+ type = 'array';
20
+ }
21
+ else if (obj.getFullYear !== undefined && typeof obj.getFullYear === 'function') {
22
+ type = 'date';
23
+ }
24
+ else if (obj.byteLength !== undefined) {
25
+ type = 'buffer';
26
+ }
27
+ else if (obj.exec !== undefined && obj.test !== undefined) {
28
+ type = 'regexp';
29
+ }
30
+ }
31
+ switch (type) {
32
+ case 'boolean':
33
+ case 'number':
34
+ case 'function':
35
+ case 'string':
36
+ case 'buffer':
37
+ // ok with simple copy
38
+ result = obj;
39
+ break;
40
+ case 'regexp':
41
+ result = new RegExp(obj);
42
+ break;
43
+ case 'date':
44
+ result = new Date(obj);
45
+ break;
46
+ case 'array':
47
+ result = __spreadArray([], obj.map(function (one) {
48
+ return (0, exports.clone)(one);
49
+ }), true);
50
+ break;
51
+ case 'object':
52
+ // sanitize default false
53
+ result = {};
54
+ Object.keys(obj)
55
+ .forEach(function (key) {
56
+ // recursively call
57
+ result[key] = (0, exports.clone)(obj[key]);
58
+ });
59
+ break;
60
+ }
61
+ }
62
+ else {
63
+ result = obj; // do not copy null & undefined
64
+ }
65
+ return result;
66
+ };
67
+ exports.clone = clone;
66
68
  //# sourceMappingURL=util.js.map
package/build/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;;;;;;;;AAAO,IAAM,KAAK,GAAG,UAAC,GAAS;IAC9B,IAAI,MAAM,GAAS,IAAI,CAAC;IAExB,IAAI,CAA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,QAAQ;gBACZ,MAAM,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;gBACzB,MAAM;YAEP,KAAK,MAAM;gBACV,MAAM,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;gBACvB,MAAM;YAEP,KAAK,OAAO;gBACX,MAAM,qBAAO,GAAG,CAAC,GAAG,CAAC,UAAC,GAAS;oBAC9B,OAAO,IAAA,aAAK,EAAC,GAAG,CAAC,CAAC;gBACnB,CAAC,CAAC,OAAC,CAAC;gBACJ,MAAM;YAEP,KAAK,QAAQ;gBACZ,yBAAyB;gBACzB,MAAM,GAAG,EAAE,CAAC;gBAEZ,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;qBACd,OAAO,CAAC,UAAA,GAAG;oBACX,mBAAmB;oBACnB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAA,aAAK,EAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC/B,CAAC,CAAC,CAAC;gBACJ,MAAM;SACP;KACD;SAAM;QACN,MAAM,GAAG,GAAG,CAAC,CAAC,+BAA+B;KAC7C;IAED,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AA1DW,QAAA,KAAK,SA0DhB"}
package/package.json CHANGED
@@ -1,39 +1,39 @@
1
- {
2
- "name": "ejv",
3
- "version": "1.1.10",
4
- "description": "Easy JSON Validator",
5
- "main": "build/public_api.js",
6
- "types": "build/public_api.d.ts",
7
- "scripts": {
8
- "clean": "rimraf ./build",
9
- "prebuild": "yarn clean",
10
- "build": "tsc",
11
- "prebuild:test": "yarn clean",
12
- "build:test": "tsc -p tsconfig.spec.json",
13
- "pretest": "yarn build:test",
14
- "test": "mocha ./build/**/*.spec.js"
15
- },
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/han41858/ejv.git"
19
- },
20
- "keywords": [
21
- "json",
22
- "validator",
23
- "validation"
24
- ],
25
- "author": "Janghyun Han <han41858@gmail.com>",
26
- "license": "MIT",
27
- "bugs": {
28
- "url": "https://github.com/han41858/ejv/issues"
29
- },
30
- "homepage": "https://github.com/han41858/ejv#readme",
31
- "devDependencies": {
32
- "@types/chai": "^4.2.14",
33
- "@types/mocha": "^8.2.0",
34
- "chai": "^4.2.0",
35
- "mocha": "^8.2.1",
36
- "rimraf": "^3.0.2",
37
- "typescript": "^4.1.3"
38
- }
39
- }
1
+ {
2
+ "name": "ejv",
3
+ "version": "1.1.11",
4
+ "description": "Easy JSON Validator",
5
+ "main": "build/public_api.js",
6
+ "types": "build/public_api.d.ts",
7
+ "scripts": {
8
+ "clean": "rimraf ./build",
9
+ "prebuild": "yarn clean",
10
+ "build": "tsc",
11
+ "prebuild:test": "yarn clean",
12
+ "build:test": "tsc -p tsconfig.spec.json",
13
+ "pretest": "yarn build:test",
14
+ "test": "mocha ./build/**/*.spec.js"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/han41858/ejv.git"
19
+ },
20
+ "keywords": [
21
+ "json",
22
+ "validator",
23
+ "validation"
24
+ ],
25
+ "author": "Janghyun Han <han41858@gmail.com>",
26
+ "license": "MIT",
27
+ "bugs": {
28
+ "url": "https://github.com/han41858/ejv/issues"
29
+ },
30
+ "homepage": "https://github.com/han41858/ejv#readme",
31
+ "devDependencies": {
32
+ "@types/chai": "^4.2.14",
33
+ "@types/mocha": "^8.2.0",
34
+ "chai": "^4.2.0",
35
+ "mocha": "^8.2.1",
36
+ "rimraf": "^3.0.2",
37
+ "typescript": "^4.1.3"
38
+ }
39
+ }
@@ -1,17 +1,17 @@
1
- // to test common type easily
2
- export const commonTestRunner = (testFnc,
3
- nullResult : boolean,
4
- undefinedResult : boolean,
5
- booleanResult : boolean,
6
- numberResult : boolean,
7
- stringResult : boolean,
8
- arrayResult : boolean,
9
- objectResult : boolean) : boolean => {
10
- return testFnc(null) === nullResult
11
- && testFnc(undefined) === undefinedResult
12
- && testFnc(true) === booleanResult
13
- && testFnc(8) === numberResult
14
- && testFnc('hello') === stringResult
15
- && testFnc([1, 2, 3]) === arrayResult
16
- && testFnc({ a : 1 }) === objectResult;
17
- };
1
+ // to test common type easily
2
+ export const commonTestRunner = (testFnc,
3
+ nullResult : boolean,
4
+ undefinedResult : boolean,
5
+ booleanResult : boolean,
6
+ numberResult : boolean,
7
+ stringResult : boolean,
8
+ arrayResult : boolean,
9
+ objectResult : boolean) : boolean => {
10
+ return testFnc(null) === nullResult
11
+ && testFnc(undefined) === undefinedResult
12
+ && testFnc(true) === booleanResult
13
+ && testFnc(8) === numberResult
14
+ && testFnc('hello') === stringResult
15
+ && testFnc([1, 2, 3]) === arrayResult
16
+ && testFnc({ a : 1 }) === objectResult;
17
+ };