object-no-new-keys 4.0.10 → 4.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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
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.0 (2022-04-10)
7
+
8
+ ### Features
9
+
10
+ - export defaults ([a968629](https://github.com/codsen/codsen/commit/a968629d5cabe320b946c636baea46772bf0d471))
11
+
6
12
  ## 4.0.0 (2021-09-09)
7
13
 
8
14
  ### Features
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
@@ -72,8 +72,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
72
72
 
73
73
  MIT License
74
74
 
75
- Copyright (c) 2010-2021 Roy Revelt and other contributors
76
-
75
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
77
76
 
78
77
  <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.1.0
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.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};
@@ -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.1.0
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,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);})();
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.1.0",
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,15 +37,18 @@
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
+ "devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
41
+ "dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
41
42
  "examples": "node '../../ops/scripts/run-examples.js'",
42
- "lect": "node '../../ops/lect/lect.js'",
43
+ "lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
43
44
  "letspublish": "yarn publish || :",
44
45
  "lint": "eslint . --fix",
45
46
  "perf": "node perf/check.js",
46
47
  "prepare": "echo 'ready'",
48
+ "prettier": "prettier",
49
+ "prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
47
50
  "pretest": "yarn run lect && yarn run build",
48
- "test": "c8 yarn run unit && yarn run examples && yarn run lint",
51
+ "test": "yarn run devtest",
49
52
  "unit": "uvu test"
50
53
  },
51
54
  "engines": {
package/types/index.d.ts CHANGED
@@ -1,12 +1,23 @@
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 const defaults: Opts;
17
+ declare function noNewKeys(
18
+ inputOuter: JsonValue,
19
+ referenceOuter: JsonValue,
20
+ originalOptsOuter?: Opts
21
+ ): any;
11
22
 
12
- export { noNewKeys, version };
23
+ export { defaults, noNewKeys, version };