object-no-new-keys 4.0.10 → 4.0.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-2021 Roy Revelt and other contributors
3
+ Copyright (c) 2010-2022 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
package/README.md CHANGED
@@ -26,14 +26,12 @@
26
26
 
27
27
  ## Install
28
28
 
29
- This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
29
+ The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `3.1.0`.
30
30
 
31
31
  ```bash
32
32
  npm i object-no-new-keys
33
33
  ```
34
34
 
35
- If you need a legacy version which works with `require`, use version 3.1.0
36
-
37
35
  ## Quick Take
38
36
 
39
37
  ```js
@@ -72,8 +70,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
72
70
 
73
71
  MIT License
74
72
 
75
- Copyright (c) 2010-2021 Roy Revelt and other contributors
76
-
73
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
77
74
 
78
75
  <img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
79
-
@@ -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.10
4
+ * @version 4.0.11
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 u="4.0.10";var f=u;function y(l){return l&&typeof l=="object"&&!Array.isArray(l)}function w(l,h,r){if(r&&!y(r))throw new TypeError(`object-no-new-keys/noNewKeys(): [THROW_ID_02] opts should be a plain object. It was given as ${JSON.stringify(r,null,4)} (type ${typeof r})`);let n={...{mode:2},...r};if(typeof n.mode=="string"&&["1","2"].includes(n.mode))n.mode=+n.mode;else if(![1,2].includes(n.mode))throw new TypeError('object-no-new-keys/objectNoNewKeys(): [THROW_ID_01] opts.mode should be "1" or "2" (string or number).');function a(t,c,p,e){let o;if(y(t))y(c)?Object.keys(t).forEach(s=>{Object.prototype.hasOwnProperty.call(c,s)?(y(t[s])||Array.isArray(t[s]))&&(o={path:e.path.length>0?`${e.path}.${s}`:s,res:e.res},e.res=a(t[s],c[s],p,o).res):(o=e.path.length>0?`${e.path}.${s}`:s,e.res.push(o))}):e.res=e.res.concat(Object.keys(t).map(s=>e.path.length>0?`${e.path}.${s}`:s));else if(Array.isArray(t))if(Array.isArray(c))for(let s=0,d=t.length;s<d;s++)o={path:`${e.path.length>0?e.path:""}[${s}]`,res:e.res},p.mode===2?e.res=a(t[s],c[0],p,o).res:e.res=a(t[s],c[s],p,o).res;else e.res=e.res.concat(t.map((s,d)=>`${e.path.length>0?e.path:""}[${d}]`));return e}return a(l,h,n,{path:"",res:[]}).res}export{w as noNewKeys,f as version};
10
+ var i="4.0.11";var f=i;function y(a){return a&&typeof a=="object"&&!Array.isArray(a)}function w(a,u,c){if(c&&!y(c))throw new TypeError(`object-no-new-keys/noNewKeys(): [THROW_ID_02] opts should be a plain object. It was given as ${JSON.stringify(c,null,4)} (type ${typeof c})`);let r={...{mode:2},...c};if(typeof r.mode=="string"&&["1","2"].includes(r.mode))r.mode=+r.mode;else if(![1,2].includes(r.mode))throw new TypeError('object-no-new-keys/objectNoNewKeys(): [THROW_ID_01] opts.mode should be "1" or "2" (string or number).');function l(s,n,p,e){let o;if(y(s))y(n)?Object.keys(s).forEach(t=>{Object.prototype.hasOwnProperty.call(n,t)?(y(s[t])||Array.isArray(s[t]))&&(o={path:e.path.length>0?`${e.path}.${t}`:t,res:e.res},e.res=l(s[t],n[t],p,o).res):(o=e.path.length>0?`${e.path}.${t}`:t,e.res.push(o))}):e.res=e.res.concat(Object.keys(s).map(t=>e.path.length>0?`${e.path}.${t}`:t));else if(Array.isArray(s))if(Array.isArray(n))for(let t=0,d=s.length;t<d;t++)o={path:`${e.path.length>0?e.path:""}[${t}]`,res:e.res},p.mode===2?e.res=l(s[t],n[0],p,o).res:e.res=l(s[t],n[t],p,o).res;else e.res=e.res.concat(s.map((t,d)=>`${e.path.length>0?e.path:""}[${d}]`));return e}return l(a,u,r,{path:"",res:[]}).res}export{w as noNewKeys,f as 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.10
4
+ * @version 4.0.11
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 objectNoNewKeys=(()=>{var d=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames,m=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var f=(e,s,t)=>s in e?d(e,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[s]=t,b=(e,s)=>{for(var t in s||(s={}))j.call(s,t)&&f(e,t,s[t]);if(m)for(var t of m(s))J.call(s,t)&&f(e,t,s[t]);return e};var $=e=>d(e,"__esModule",{value:!0});var v=(e,s)=>{for(var t in s)d(e,t,{get:s[t],enumerable:!0})},O=(e,s,t,h)=>{if(s&&typeof s=="object"||typeof s=="function")for(let c of A(s))!j.call(e,c)&&(t||c!=="default")&&d(e,c,{get:()=>s[c],enumerable:!(h=g(s,c))||h.enumerable});return e};var x=(e=>(s,t)=>e&&e.get(s)||(t=O($({}),s,1),e&&e.set(s,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var I={};v(I,{noNewKeys:()=>T,version:()=>k});var w="4.0.10";var k=w;function u(e){return e&&typeof e=="object"&&!Array.isArray(e)}function T(e,s,t){if(t&&!u(t))throw new TypeError(`object-no-new-keys/noNewKeys(): [THROW_ID_02] opts should be a plain object. It was given as ${JSON.stringify(t,null,4)} (type ${typeof t})`);let c=b(b({},{mode:2}),t);if(typeof c.mode=="string"&&["1","2"].includes(c.mode))c.mode=+c.mode;else if(![1,2].includes(c.mode))throw new TypeError('object-no-new-keys/objectNoNewKeys(): [THROW_ID_01] opts.mode should be "1" or "2" (string or number).');function p(l,a,y,o){let r;if(u(l))u(a)?Object.keys(l).forEach(n=>{Object.prototype.hasOwnProperty.call(a,n)?(u(l[n])||Array.isArray(l[n]))&&(r={path:o.path.length>0?`${o.path}.${n}`:n,res:o.res},o.res=p(l[n],a[n],y,r).res):(r=o.path.length>0?`${o.path}.${n}`:n,o.res.push(r))}):o.res=o.res.concat(Object.keys(l).map(n=>o.path.length>0?`${o.path}.${n}`:n));else if(Array.isArray(l))if(Array.isArray(a))for(let n=0,i=l.length;n<i;n++)r={path:`${o.path.length>0?o.path:""}[${n}]`,res:o.res},y.mode===2?o.res=p(l[n],a[0],y,r).res:o.res=p(l[n],a[n],y,r).res;else o.res=o.res.concat(l.map((n,i)=>`${o.path.length>0?o.path:""}[${i}]`));return o}return p(e,s,c,{path:"",res:[]}).res}return x(I);})();
10
+ var objectNoNewKeys=(()=>{var d=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames,m=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var f=(e,t,s)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,b=(e,t)=>{for(var s in t||(t={}))j.call(t,s)&&f(e,s,t[s]);if(m)for(var s of m(t))J.call(t,s)&&f(e,s,t[s]);return e};var $=e=>d(e,"__esModule",{value:!0});var x=(e,t)=>{for(var s in t)d(e,s,{get:t[s],enumerable:!0})},v=(e,t,s,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of A(t))!j.call(e,n)&&(s||n!=="default")&&d(e,n,{get:()=>t[n],enumerable:!(u=g(t,n))||u.enumerable});return e};var O=(e=>(t,s)=>e&&e.get(t)||(s=v($({}),t,1),e&&e.set(t,s),s))(typeof WeakMap!="undefined"?new WeakMap:0);var I={};x(I,{noNewKeys:()=>T,version:()=>k});var w="4.0.11";var k=w;function i(e){return e&&typeof e=="object"&&!Array.isArray(e)}function T(e,t,s){if(s&&!i(s))throw new TypeError(`object-no-new-keys/noNewKeys(): [THROW_ID_02] opts should be a plain object. It was given as ${JSON.stringify(s,null,4)} (type ${typeof s})`);let n=b(b({},{mode:2}),s);if(typeof n.mode=="string"&&["1","2"].includes(n.mode))n.mode=+n.mode;else if(![1,2].includes(n.mode))throw new TypeError('object-no-new-keys/objectNoNewKeys(): [THROW_ID_01] opts.mode should be "1" or "2" (string or number).');function p(a,l,y,o){let c;if(i(a))i(l)?Object.keys(a).forEach(r=>{Object.prototype.hasOwnProperty.call(l,r)?(i(a[r])||Array.isArray(a[r]))&&(c={path:o.path.length>0?`${o.path}.${r}`:r,res:o.res},o.res=p(a[r],l[r],y,c).res):(c=o.path.length>0?`${o.path}.${r}`:r,o.res.push(c))}):o.res=o.res.concat(Object.keys(a).map(r=>o.path.length>0?`${o.path}.${r}`:r));else if(Array.isArray(a))if(Array.isArray(l))for(let r=0,h=a.length;r<h;r++)c={path:`${o.path.length>0?o.path:""}[${r}]`,res:o.res},y.mode===2?o.res=p(a[r],l[0],y,c).res:o.res=p(a[r],l[r],y,c).res;else o.res=o.res.concat(a.map((r,h)=>`${o.path.length>0?o.path:""}[${h}]`));return o}return p(e,t,n,{path:"",res:[]}).res}return O(I);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "object-no-new-keys",
3
- "version": "4.0.10",
3
+ "version": "4.0.11",
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",
@@ -37,13 +37,15 @@
37
37
  "scripts": {
38
38
  "build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
39
39
  "dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
40
- "dts": "rollup -c",
40
+ "dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
41
41
  "examples": "node '../../ops/scripts/run-examples.js'",
42
42
  "lect": "node '../../ops/lect/lect.js'",
43
43
  "letspublish": "yarn publish || :",
44
44
  "lint": "eslint . --fix",
45
45
  "perf": "node perf/check.js",
46
46
  "prepare": "echo 'ready'",
47
+ "prettier": "prettier",
48
+ "prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
47
49
  "pretest": "yarn run lect && yarn run build",
48
50
  "test": "c8 yarn run unit && yarn run examples && yarn run lint",
49
51
  "unit": "uvu test"
package/types/index.d.ts CHANGED
@@ -1,12 +1,22 @@
1
1
  declare const version: string;
2
- declare type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
2
+ declare type JsonValue =
3
+ | string
4
+ | number
5
+ | boolean
6
+ | null
7
+ | JsonObject
8
+ | JsonArray;
3
9
  declare type JsonObject = {
4
- [Key in string]?: JsonValue;
10
+ [Key in string]?: JsonValue;
5
11
  };
6
12
  declare type JsonArray = JsonValue[];
7
13
  interface Opts {
8
- mode: 1 | 2;
14
+ mode: 1 | 2;
9
15
  }
10
- declare function noNewKeys(inputOuter: JsonValue, referenceOuter: JsonValue, originalOptsOuter?: Opts): any;
16
+ declare function noNewKeys(
17
+ inputOuter: JsonValue,
18
+ referenceOuter: JsonValue,
19
+ originalOptsOuter?: Opts
20
+ ): any;
11
21
 
12
22
  export { noNewKeys, version };