object-no-new-keys 4.0.3 → 4.0.7
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 +0 -20
- package/LICENSE +1 -1
- package/dist/object-no-new-keys.esm.js +62 -57
- package/dist/object-no-new-keys.umd.js +2 -2
- package/package.json +22 -26
package/CHANGELOG.md
CHANGED
|
@@ -3,26 +3,6 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## 4.0.3 (2021-11-02)
|
|
7
|
-
|
|
8
|
-
### Bug Fixes
|
|
9
|
-
|
|
10
|
-
- bump TS and separate ESLint plugins away from this monorepo ([b1ebce1](https://github.com/codsen/codsen/commit/b1ebce1637d8c41c2d848fc24b0ba4058865bd5d))
|
|
11
|
-
|
|
12
|
-
### Features
|
|
13
|
-
|
|
14
|
-
- migrate to ES Modules ([c579dff](https://github.com/codsen/codsen/commit/c579dff3b23205e383035ca10ddcec671e35d0fe))
|
|
15
|
-
|
|
16
|
-
### BREAKING CHANGES
|
|
17
|
-
|
|
18
|
-
- programs now are in ES Modules and won't work with Common JS require()
|
|
19
|
-
|
|
20
|
-
## 4.0.1 (2021-09-13)
|
|
21
|
-
|
|
22
|
-
### Bug Fixes
|
|
23
|
-
|
|
24
|
-
- bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
|
|
25
|
-
|
|
26
6
|
## 4.0.0 (2021-09-09)
|
|
27
7
|
|
|
28
8
|
### Features
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010
|
|
3
|
+
Copyright (c) 2010-2021 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
|
@@ -1,75 +1,80 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name object-no-new-keys
|
|
3
3
|
* @fileoverview Check, does a plain object (AST/JSON) has any unique keys, not present in a reference object (another AST/JSON)
|
|
4
|
-
* @version 4.0.
|
|
4
|
+
* @version 4.0.7
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/object-no-new-keys/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var version$1 = "4.0.
|
|
10
|
+
var version$1 = "4.0.7";
|
|
11
11
|
|
|
12
12
|
const version = version$1;
|
|
13
13
|
function isObj(something) {
|
|
14
|
-
|
|
14
|
+
return (something && typeof something === "object" && !Array.isArray(something));
|
|
15
15
|
}
|
|
16
16
|
function noNewKeys(inputOuter, referenceOuter, originalOptsOuter) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
17
|
+
if (originalOptsOuter && !isObj(originalOptsOuter)) {
|
|
18
|
+
throw new TypeError(`object-no-new-keys/noNewKeys(): [THROW_ID_02] opts should be a plain object. It was given as ${JSON.stringify(originalOptsOuter, null, 4)} (type ${typeof originalOptsOuter})`);
|
|
19
|
+
}
|
|
20
|
+
const defaults = {
|
|
21
|
+
mode: 2,
|
|
22
|
+
};
|
|
23
|
+
const optsOuter = { ...defaults, ...originalOptsOuter };
|
|
24
|
+
if (typeof optsOuter.mode === "string" &&
|
|
25
|
+
["1", "2"].includes(optsOuter.mode)) {
|
|
26
|
+
optsOuter.mode = +optsOuter.mode;
|
|
27
|
+
}
|
|
28
|
+
else if (![1, 2].includes(optsOuter.mode)) {
|
|
29
|
+
throw new TypeError(`object-no-new-keys/objectNoNewKeys(): [THROW_ID_01] opts.mode should be "1" or "2" (string or number).`);
|
|
30
|
+
}
|
|
31
|
+
function objectNoNewKeysInternal(input, reference, opts, innerVar) {
|
|
32
|
+
let temp;
|
|
33
|
+
if (isObj(input)) {
|
|
34
|
+
if (isObj(reference)) {
|
|
35
|
+
Object.keys(input).forEach((key) => {
|
|
36
|
+
if (!Object.prototype.hasOwnProperty.call(reference, key)) {
|
|
37
|
+
temp = innerVar.path.length > 0 ? `${innerVar.path}.${key}` : key;
|
|
38
|
+
innerVar.res.push(temp);
|
|
39
|
+
}
|
|
40
|
+
else if (isObj(input[key]) || Array.isArray(input[key])) {
|
|
41
|
+
temp = {
|
|
42
|
+
path: innerVar.path.length > 0 ? `${innerVar.path}.${key}` : key,
|
|
43
|
+
res: innerVar.res,
|
|
44
|
+
};
|
|
45
|
+
innerVar.res = objectNoNewKeysInternal(input[key], reference[key], opts, temp).res;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
innerVar.res = innerVar.res.concat(Object.keys(input).map((key) => innerVar.path.length > 0 ? `${innerVar.path}.${key}` : key));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else if (Array.isArray(input)) {
|
|
54
|
+
if (Array.isArray(reference)) {
|
|
55
|
+
for (let i = 0, len = input.length; i < len; i++) {
|
|
56
|
+
temp = {
|
|
57
|
+
path: `${innerVar.path.length > 0 ? innerVar.path : ""}[${i}]`,
|
|
58
|
+
res: innerVar.res,
|
|
59
|
+
};
|
|
60
|
+
if (opts.mode === 2) {
|
|
61
|
+
innerVar.res = objectNoNewKeysInternal(input[i], reference[0], opts, temp).res;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
innerVar.res = objectNoNewKeysInternal(input[i], reference[i], opts, temp).res;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
innerVar.res = innerVar.res.concat(input.map((_el, i) => `${innerVar.path.length > 0 ? innerVar.path : ""}[${i}]`));
|
|
70
|
+
}
|
|
62
71
|
}
|
|
63
|
-
|
|
64
|
-
innerVar.res = innerVar.res.concat(input.map((_el, i) => `${innerVar.path.length > 0 ? innerVar.path : ""}[${i}]`));
|
|
65
|
-
}
|
|
72
|
+
return innerVar;
|
|
66
73
|
}
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
res: []
|
|
72
|
-
}).res;
|
|
74
|
+
return objectNoNewKeysInternal(inputOuter, referenceOuter, optsOuter, {
|
|
75
|
+
path: "",
|
|
76
|
+
res: [],
|
|
77
|
+
}).res;
|
|
73
78
|
}
|
|
74
79
|
|
|
75
80
|
export { noNewKeys, version };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name object-no-new-keys
|
|
3
3
|
* @fileoverview Check, does a plain object (AST/JSON) has any unique keys, not present in a reference object (another AST/JSON)
|
|
4
|
-
* @version 4.0.
|
|
4
|
+
* @version 4.0.7
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/object-no-new-keys/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).objectNoNewKeys={})}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&!Array.isArray(e)}e.noNewKeys=function(e,r,o){if(o&&!t(o))throw new TypeError(`object-no-new-keys/noNewKeys(): [THROW_ID_02] opts should be a plain object. It was given as ${JSON.stringify(o,null,4)} (type ${typeof o})`);const s={mode:2,...o};if("string"==typeof s.mode&&["1","2"].includes(s.mode))s.mode=+s.mode;else if(![1,2].includes(s.mode))throw new TypeError('object-no-new-keys/objectNoNewKeys(): [THROW_ID_01] opts.mode should be "1" or "2" (string or number).');return function e(r,o,s,n){let a;if(t(r))t(o)?Object.keys(r).forEach((p=>{Object.prototype.hasOwnProperty.call(o,p)?(t(r[p])||Array.isArray(r[p]))&&(a={path:n.path.length>0?`${n.path}.${p}`:p,res:n.res},n.res=e(r[p],o[p],s,a).res):(a=n.path.length>0?`${n.path}.${p}`:p,n.res.push(a))})):n.res=n.res.concat(Object.keys(r).map((e=>n.path.length>0?`${n.path}.${e}`:e)));else if(Array.isArray(r))if(Array.isArray(o))for(let t=0,p=r.length;t<p;t++)a={path:`${n.path.length>0?n.path:""}[${t}]`,res:n.res},n.res=2===s.mode?e(r[t],o[0],s,a).res:e(r[t],o[t],s,a).res;else n.res=n.res.concat(r.map(((e,t)=>`${n.path.length>0?n.path:""}[${t}]`)));return n}(e,r,s,{path:"",res:[]}).res},e.version="4.0.
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).objectNoNewKeys={})}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&!Array.isArray(e)}e.noNewKeys=function(e,r,o){if(o&&!t(o))throw new TypeError(`object-no-new-keys/noNewKeys(): [THROW_ID_02] opts should be a plain object. It was given as ${JSON.stringify(o,null,4)} (type ${typeof o})`);const s={mode:2,...o};if("string"==typeof s.mode&&["1","2"].includes(s.mode))s.mode=+s.mode;else if(![1,2].includes(s.mode))throw new TypeError('object-no-new-keys/objectNoNewKeys(): [THROW_ID_01] opts.mode should be "1" or "2" (string or number).');return function e(r,o,s,n){let a;if(t(r))t(o)?Object.keys(r).forEach((p=>{Object.prototype.hasOwnProperty.call(o,p)?(t(r[p])||Array.isArray(r[p]))&&(a={path:n.path.length>0?`${n.path}.${p}`:p,res:n.res},n.res=e(r[p],o[p],s,a).res):(a=n.path.length>0?`${n.path}.${p}`:p,n.res.push(a))})):n.res=n.res.concat(Object.keys(r).map((e=>n.path.length>0?`${n.path}.${e}`:e)));else if(Array.isArray(r))if(Array.isArray(o))for(let t=0,p=r.length;t<p;t++)a={path:`${n.path.length>0?n.path:""}[${t}]`,res:n.res},n.res=2===s.mode?e(r[t],o[0],s,a).res:e(r[t],o[t],s,a).res;else n.res=n.res.concat(r.map(((e,t)=>`${n.path.length>0?n.path:""}[${t}]`)));return n}(e,r,s,{path:"",res:[]}).res},e.version="4.0.7",Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "object-no-new-keys",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.7",
|
|
4
4
|
"description": "Check, does a plain object (AST/JSON) has any unique keys, not present in a reference object (another AST/JSON)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compare",
|
|
@@ -36,13 +36,12 @@
|
|
|
36
36
|
"types": "types/index.d.ts",
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "rollup -c",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
39
|
+
"build:esbuild": "node '../../scripts/esbuild.js'",
|
|
40
|
+
"build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
|
|
41
|
+
"ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
|
|
41
42
|
"clean_types": "../../scripts/cleanTypes.js",
|
|
42
43
|
"dev": "rollup -c --dev",
|
|
43
44
|
"devunittest": "npm run dev && tap --only -R 'base'",
|
|
44
|
-
"esbuild": "node '../../scripts/esbuild.js'",
|
|
45
|
-
"esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
|
|
46
45
|
"format": "npm run lect && npm run prettier && npm run lint",
|
|
47
46
|
"lect": "lect",
|
|
48
47
|
"lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
|
|
@@ -51,17 +50,14 @@
|
|
|
51
50
|
"republish": "npm publish || :",
|
|
52
51
|
"tap": "tap",
|
|
53
52
|
"pretest": "npm run build",
|
|
54
|
-
"test": "npm run
|
|
53
|
+
"test": "npm run test:ci && npm run perf",
|
|
54
|
+
"test:ci": "npm run unittest && npm run test:examples && npm run format",
|
|
55
55
|
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
56
56
|
"tsc": "tsc",
|
|
57
|
-
"unittest": "tap --no-only --
|
|
57
|
+
"unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
|
|
58
58
|
},
|
|
59
59
|
"tap": {
|
|
60
60
|
"check-coverage": false,
|
|
61
|
-
"coverage-report": [
|
|
62
|
-
"json-summary",
|
|
63
|
-
"text"
|
|
64
|
-
],
|
|
65
61
|
"node-arg": [
|
|
66
62
|
"--no-warnings",
|
|
67
63
|
"--experimental-loader",
|
|
@@ -83,7 +79,7 @@
|
|
|
83
79
|
}
|
|
84
80
|
},
|
|
85
81
|
"dependencies": {
|
|
86
|
-
"@babel/runtime": "^7.16.
|
|
82
|
+
"@babel/runtime": "^7.16.3"
|
|
87
83
|
},
|
|
88
84
|
"devDependencies": {
|
|
89
85
|
"@babel/cli": "^7.16.0",
|
|
@@ -94,8 +90,8 @@
|
|
|
94
90
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
95
91
|
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
96
92
|
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
97
|
-
"@babel/plugin-transform-runtime": "^7.16.
|
|
98
|
-
"@babel/preset-env": "^7.16.
|
|
93
|
+
"@babel/plugin-transform-runtime": "^7.16.4",
|
|
94
|
+
"@babel/preset-env": "^7.16.4",
|
|
99
95
|
"@babel/preset-typescript": "^7.16.0",
|
|
100
96
|
"@babel/register": "^7.16.0",
|
|
101
97
|
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
@@ -105,26 +101,26 @@
|
|
|
105
101
|
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
106
102
|
"@rollup/plugin-strip": "^2.1.0",
|
|
107
103
|
"@rollup/plugin-typescript": "^8.3.0",
|
|
108
|
-
"@types/node": "^16.11.
|
|
104
|
+
"@types/node": "^16.11.10",
|
|
109
105
|
"@types/tap": "^15.0.5",
|
|
110
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
111
|
-
"@typescript-eslint/parser": "^5.
|
|
112
|
-
"core-js": "^3.19.
|
|
106
|
+
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
107
|
+
"@typescript-eslint/parser": "^5.5.0",
|
|
108
|
+
"core-js": "^3.19.2",
|
|
113
109
|
"cross-env": "^7.0.3",
|
|
114
|
-
"eslint": "^8.
|
|
115
|
-
"lect": "^0.18.
|
|
116
|
-
"rollup": "^2.
|
|
110
|
+
"eslint": "^8.3.0",
|
|
111
|
+
"lect": "^0.18.7",
|
|
112
|
+
"rollup": "^2.60.1",
|
|
117
113
|
"rollup-plugin-ascii": "^0.0.3",
|
|
118
114
|
"rollup-plugin-banner": "^0.2.1",
|
|
119
115
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
120
|
-
"rollup-plugin-dts": "^4.0.
|
|
116
|
+
"rollup-plugin-dts": "^4.0.1",
|
|
121
117
|
"rollup-plugin-terser": "^7.0.2",
|
|
122
|
-
"tap": "^15.
|
|
118
|
+
"tap": "^15.1.5",
|
|
123
119
|
"tslib": "^2.3.1",
|
|
124
|
-
"type-fest": "^2.
|
|
125
|
-
"typescript": "^4.
|
|
120
|
+
"type-fest": "^2.6.0",
|
|
121
|
+
"typescript": "^4.5.2"
|
|
126
122
|
},
|
|
127
123
|
"engines": {
|
|
128
|
-
"node": ">=
|
|
124
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
129
125
|
}
|
|
130
126
|
}
|