object-no-new-keys 4.1.0 → 4.1.3

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 CHANGED
@@ -3,6 +3,18 @@
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.1.3 (2022-04-25)
7
+
8
+ ### Bug Fixes
9
+
10
+ - improve types ([f2b1ea1](https://github.com/codsen/codsen/commit/f2b1ea1dee7b912cf1e9d5f30e7483f49b3f8d07))
11
+
12
+ ## 4.1.2 (2022-04-18)
13
+
14
+ ### Bug Fixes
15
+
16
+ - tweak types ([fe67aa5](https://github.com/codsen/codsen/commit/fe67aa510c5523969e83d905c7420106081d4a8b))
17
+
6
18
  # 4.1.0 (2022-04-10)
7
19
 
8
20
  ### Features
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
+ This package is [pure ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). If you're not ready yet, install an older version of this program, 3.1.0 (`npm i object-no-new-keys@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
@@ -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.1.0
4
+ * @version 4.1.3
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 i="4.1.0";var f=i;function y(c){return c&&typeof c=="object"&&!Array.isArray(c)}var b={mode:2};function w(c,u,a){if(a&&!y(a))throw new TypeError(`object-no-new-keys/noNewKeys(): [THROW_ID_02] opts should be a plain object. It was given as ${JSON.stringify(a,null,4)} (type ${typeof a})`);let r={...b,...a};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(c,u,r,{path:"",res:[]}).res}export{b as defaults,w as noNewKeys,f as version};
10
+ var u="4.1.3";var f=u;function l(a){return a&&typeof a=="object"&&!Array.isArray(a)}var b={mode:2};function g(a,h,c){if(c&&!l(c))throw new TypeError(`object-no-new-keys/noNewKeys(): [THROW_ID_02] resolvedOpts should be a plain object. It was given as ${JSON.stringify(c,null,4)} (type ${typeof c})`);let n={...b,...c};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] resolvedOpts.mode should be "1" or "2" (string or number).');function i(s,o,p,e){let r;if(l(s))l(o)?Object.keys(s).forEach(t=>{Object.prototype.hasOwnProperty.call(o,t)?(l(s[t])||Array.isArray(s[t]))&&(r={path:e.path.length?`${e.path}.${t}`:t,res:e.res},e.res=i(s[t],o[t],p,r).res):(r=e.path.length?`${e.path}.${t}`:t,e.res.push(r))}):e.res=e.res.concat(Object.keys(s).map(t=>e.path.length?`${e.path}.${t}`:t));else if(Array.isArray(s))if(Array.isArray(o))for(let t=0,y=s.length;t<y;t++)r={path:`${e.path.length?e.path:""}[${t}]`,res:e.res},p.mode===2?e.res=i(s[t],o[0],p,r).res:e.res=i(s[t],o[t],p,r).res;else e.res=e.res.concat(s.map((t,y)=>`${e.path.length?e.path:""}[${y}]`));return e}return i(a,h,n,{path:"",res:[]}).res}export{b as defaults,g 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.1.0
4
+ * @version 4.1.3
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,b=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable;var m=(t,e,s)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,h=(t,e)=>{for(var s in e||(e={}))j.call(e,s)&&m(t,s,e[s]);if(b)for(var s of b(e))v.call(e,s)&&m(t,s,e[s]);return t};var J=(t,e)=>{for(var s in e)d(t,s,{get:e[s],enumerable:!0})},$=(t,e,s,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of A(e))!j.call(t,c)&&c!==s&&d(t,c,{get:()=>e[c],enumerable:!(a=g(e,c))||a.enumerable});return t};var x=t=>$(d({},"__esModule",{value:!0}),t);var T={};J(T,{defaults:()=>w,noNewKeys:()=>k,version:()=>N});var f="4.1.0";var N=f;function i(t){return t&&typeof t=="object"&&!Array.isArray(t)}var w={mode:2};function k(t,e,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 a=h(h({},w),s);if(typeof a.mode=="string"&&["1","2"].includes(a.mode))a.mode=+a.mode;else if(![1,2].includes(a.mode))throw new TypeError('object-no-new-keys/objectNoNewKeys(): [THROW_ID_01] opts.mode should be "1" or "2" (string or number).');function c(n,p,y,o){let l;if(i(n))i(p)?Object.keys(n).forEach(r=>{Object.prototype.hasOwnProperty.call(p,r)?(i(n[r])||Array.isArray(n[r]))&&(l={path:o.path.length>0?`${o.path}.${r}`:r,res:o.res},o.res=c(n[r],p[r],y,l).res):(l=o.path.length>0?`${o.path}.${r}`:r,o.res.push(l))}):o.res=o.res.concat(Object.keys(n).map(r=>o.path.length>0?`${o.path}.${r}`:r));else if(Array.isArray(n))if(Array.isArray(p))for(let r=0,u=n.length;r<u;r++)l={path:`${o.path.length>0?o.path:""}[${r}]`,res:o.res},y.mode===2?o.res=c(n[r],p[0],y,l).res:o.res=c(n[r],p[r],y,l).res;else o.res=o.res.concat(n.map((r,u)=>`${o.path.length>0?o.path:""}[${u}]`));return o}return c(t,e,a,{path:"",res:[]}).res}return x(T);})();
10
+ var objectNoNewKeys=(()=>{var y=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames,b=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var m=(t,e,s)=>e in t?y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,d=(t,e)=>{for(var s in e||(e={}))j.call(e,s)&&m(t,s,e[s]);if(b)for(var s of b(e))A.call(e,s)&&m(t,s,e[s]);return t};var J=(t,e)=>{for(var s in e)y(t,s,{get:e[s],enumerable:!0})},$=(t,e,s,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of O(e))!j.call(t,a)&&a!==s&&y(t,a,{get:()=>e[a],enumerable:!(c=w(e,a))||c.enumerable});return t};var x=t=>$(y({},"__esModule",{value:!0}),t);var E={};J(E,{defaults:()=>g,noNewKeys:()=>T,version:()=>k});var f="4.1.3";var k=f;function u(t){return t&&typeof t=="object"&&!Array.isArray(t)}var g={mode:2};function T(t,e,s){if(s&&!u(s))throw new TypeError(`object-no-new-keys/noNewKeys(): [THROW_ID_02] resolvedOpts should be a plain object. It was given as ${JSON.stringify(s,null,4)} (type ${typeof s})`);let c=d(d({},g),s);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] resolvedOpts.mode should be "1" or "2" (string or number).');function a(o,p,l,r){let i;if(u(o))u(p)?Object.keys(o).forEach(n=>{Object.prototype.hasOwnProperty.call(p,n)?(u(o[n])||Array.isArray(o[n]))&&(i={path:r.path.length?`${r.path}.${n}`:n,res:r.res},r.res=a(o[n],p[n],l,i).res):(i=r.path.length?`${r.path}.${n}`:n,r.res.push(i))}):r.res=r.res.concat(Object.keys(o).map(n=>r.path.length?`${r.path}.${n}`:n));else if(Array.isArray(o))if(Array.isArray(p))for(let n=0,h=o.length;n<h;n++)i={path:`${r.path.length?r.path:""}[${n}]`,res:r.res},l.mode===2?r.res=a(o[n],p[0],l,i).res:r.res=a(o[n],p[n],l,i).res;else r.res=r.res.concat(o.map((n,h)=>`${r.path.length?r.path:""}[${h}]`));return r}return a(t,e,c,{path:"",res:[]}).res}return x(E);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "object-no-new-keys",
3
- "version": "4.1.0",
3
+ "version": "4.1.3",
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",
package/types/index.d.ts CHANGED
@@ -15,9 +15,9 @@ interface Opts {
15
15
  }
16
16
  declare const defaults: Opts;
17
17
  declare function noNewKeys(
18
- inputOuter: JsonValue,
19
- referenceOuter: JsonValue,
20
- originalOptsOuter?: Opts
21
- ): any;
18
+ input: JsonValue,
19
+ reference: JsonValue,
20
+ opts?: Partial<Opts>
21
+ ): string[];
22
22
 
23
23
  export { defaults, noNewKeys, version };