check-types-mini 8.0.19 → 8.0.22
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 +1 -1
- package/README.md +1 -1
- package/dist/check-types-mini.esm.js +3 -3
- package/dist/check-types-mini.umd.js +11 -11
- package/package.json +7 -7
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2025 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,6 +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 © 2010-
|
|
75
|
+
Copyright © 2010-2025 Roy Revelt and other contributors.
|
|
76
76
|
|
|
77
77
|
<p align="center"><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"></p>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name check-types-mini
|
|
3
3
|
* @fileoverview Validate options object
|
|
4
|
-
* @version 8.0.
|
|
4
|
+
* @version 8.0.22
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/check-types-mini/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import i from"type-detect";import{traverse as
|
|
10
|
+
import i from"type-detect";import{traverse as N}from"ast-monkey-traverse";import{arrayiffy as j}from"arrayiffy-if-string";import E from"object-path";import{isMatch as S}from"matcher";import{isPlainObject as $,pullAll as g,intersection as k}from"codsen-utils";var w="8.0.22";var R=w,v={ignoreKeys:[],ignorePaths:[],acceptArrays:!1,acceptArraysIgnore:[],enforceStrictKeyset:!0,schema:{},msg:"check-types-mini",optsVarName:"opts"};function T(a,r,p){function y(s){return s!=null}function b(s,l){return typeof l=="string"&&(l=j(l)),Array.from(s).filter(n=>!l.some(t=>S(n,t,{caseSensitive:!0})))}let V=Object.prototype.hasOwnProperty,A=["any","anything","every","everything","all","whatever","whatevs"];if(!y(a))throw new Error("check-types-mini: [THROW_ID_01] First argument is missing!");let e={...v,...p};if(typeof e.ignoreKeys=="string"&&(e.ignoreKeys=[e.ignoreKeys]),typeof e.ignorePaths=="string"&&(e.ignorePaths=[e.ignorePaths]),typeof e.acceptArraysIgnore=="string"&&(e.acceptArraysIgnore=[e.acceptArraysIgnore]),e.msg=`${e.msg}`.trim(),e.msg[e.msg.length-1]===":"&&(e.msg=e.msg.slice(0,e.msg.length-1).trim()),$(e.schema))Object.keys(e.schema).forEach(s=>{if($(e.schema[s])){let l={};N(e.schema[s],(n,t,m)=>{let u=t!==void 0?t:n;return!Array.isArray(u)&&!$(u)&&(l[`${s}.${m.path}`]=u),u}),delete e.schema[s],e.schema={...e.schema,...l}}}),Object.keys(e.schema).forEach(s=>{Array.isArray(e.schema[s])||(e.schema[s]=[e.schema[s]]),e.schema[s]=e.schema[s].map(l=>`${l}`.toLowerCase().trim())});else if(e.schema!=null)throw new Error(`check-types-mini: opts.schema was customised to ${JSON.stringify(e.schema,null,0)} which is not object but ${typeof e.schema}`);if(y(r)||(r={}),e.enforceStrictKeyset)if(y(e.schema)&&Object.keys(e.schema).length){if(r&&b(g(Object.keys(a),Object.keys(r).concat(Object.keys(e.schema))),e.ignoreKeys).length){let s=g(Object.keys(a),Object.keys(r).concat(Object.keys(e.schema)));throw new TypeError(`${e.msg}: ${e.optsVarName}.enforceStrictKeyset is on and the following key${s.length>1?"s":""} ${s.length>1?"are":"is"} not covered by schema and/or reference objects: ${s.join(", ")}`)}}else if($(r)&&Object.keys(r).length){if(b(g(Object.keys(a),Object.keys(r)),e.ignoreKeys).length!==0){let s=g(Object.keys(a),Object.keys(r));throw new TypeError(`${e.msg}: The input object has key${s.length>1?"s":""} which ${s.length>1?"are":"is"} not covered by the reference object: ${s.join(", ")}`)}else if(b(g(Object.keys(r),Object.keys(a)),e.ignoreKeys).length!==0){let s=g(Object.keys(r),Object.keys(a));throw new TypeError(`${e.msg}: The reference object has key${s.length>1?"s":""} which ${s.length>1?"are":"is"} not present in the input object: ${s.join(", ")}`)}}else throw new TypeError(`${e.msg}: Both ${e.optsVarName}.schema and reference objects are missing! We don't have anything to match the keys as you requested via resolvedOpts.enforceStrictKeyset!`);let h=[];N(a,(s,l,n)=>{let t=l,m=s;if(n.parentType==="array"&&(m=void 0,t=s),Array.isArray(h)&&h.length&&h.some(o=>n.path.startsWith(o))||m&&e.ignoreKeys.some(o=>m&&S(m,o))||e.ignorePaths.some(o=>S(n.path,o)))return t;let u=!(!$(t)&&!Array.isArray(t)&&Array.isArray(n.parent)),f=!1;$(e.schema)&&V.call(e.schema,n.path)&&(f=!0);let d=!1;if($(r)&&E.has(r,n.path)&&(d=!0),e.enforceStrictKeyset&&u&&!f&&!d)throw new TypeError(`${e.msg}: ${e.optsVarName}.${n.path} is neither covered by reference object (second input argument), nor ${e.optsVarName}.schema! To stop this error, turn off ${e.optsVarName}.enforceStrictKeyset or provide some type reference (2nd argument or ${e.optsVarName}.schema).
|
|
11
11
|
|
|
12
12
|
Debug info:
|
|
13
13
|
|
|
@@ -21,4 +21,4 @@ resolvedOpts = ${JSON.stringify(e,null,4)}
|
|
|
21
21
|
|
|
22
22
|
current = ${JSON.stringify(t,null,4)}
|
|
23
23
|
|
|
24
|
-
`);if(f){let o=
|
|
24
|
+
`);if(f){let o=j(e.schema[n.path]).map(c=>`${c}`.toLowerCase());if(E.set(e.schema,n.path,o),k(o,A).length)h.push(n.path);else if(t!==!0&&t!==!1&&!o.includes(i(t).toLowerCase())||(t===!0||t===!1)&&!o.includes(String(t))&&!o.includes("boolean"))if(Array.isArray(t)&&e.acceptArrays){for(let c=0,O=t.length;c<O;c++)if(!o.includes(i(t[c]).toLowerCase()))throw new TypeError(`${e.msg}: ${e.optsVarName}.${n.path}.${c}, the ${c}th element (equal to ${JSON.stringify(t[c],null,0)}) is of a type ${i(t[c]).toLowerCase()}, but only the following are allowed by the ${e.optsVarName}.schema: ${o.join(", ")}`)}else throw new TypeError(`${e.msg}: ${e.optsVarName}.${n.path} was customised to ${i(t)!=="string"?'"':""}${JSON.stringify(t,null,0)}${i(t)!=="string"?'"':""} (type: ${i(t).toLowerCase()}) which is not among the allowed types in schema (which is equal to ${JSON.stringify(o,null,0)})`)}else if(r&&$(r)&&d){let o=E.get(r,n.path);if(e.acceptArrays&&Array.isArray(t)&&!e.acceptArraysIgnore.includes(s)){if(!t.every(O=>i(O).toLowerCase()===i(r[s]).toLowerCase()))throw new TypeError(`${e.msg}: ${e.optsVarName}.${n.path} was customised to be array, but not all of its elements are ${i(r[s]).toLowerCase()}-type`)}else if(i(t)!==i(o))throw new TypeError(`${e.msg}: ${e.optsVarName}.${n.path} was customised to ${i(t).toLowerCase()==="string"?"":'"'}${JSON.stringify(t,null,0)}${i(t).toLowerCase()==="string"?"":'"'} which is not ${i(o).toLowerCase()} but ${i(t).toLowerCase()}`)}return t})}function M(a,r,p){T(a,r,p)}export{M as checkTypesMini,v as defaults,R as version};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name check-types-mini
|
|
3
3
|
* @fileoverview Validate options object
|
|
4
|
-
* @version 8.0.
|
|
4
|
+
* @version 8.0.22
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/check-types-mini/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
"use strict";var checkTypesMini=(()=>{var oe=Object.create;var T=Object.defineProperty,ae=Object.defineProperties,le=Object.getOwnPropertyDescriptor,fe=Object.getOwnPropertyDescriptors,ue=Object.getOwnPropertyNames,Q=Object.getOwnPropertySymbols,ce=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var _=(r,t,a)=>t in r?T(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a,v=(r,t)=>{for(var a in t||(t={}))G.call(t,a)&&_(r,a,t[a]);if(Q)for(var a of Q(t))pe.call(t,a)&&_(r,a,t[a]);return r},x=(r,t)=>ae(r,fe(t));var C=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ye=(r,t)=>{for(var a in t)T(r,a,{get:t[a],enumerable:!0})},q=(r,t,a,g)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ue(t))!G.call(r,u)&&u!==a&&T(r,u,{get:()=>t[u],enumerable:!(g=le(t,u))||g.enumerable});return r};var P=(r,t,a)=>(a=r!=null?oe(ce(r)):{},q(t||!r||!r.__esModule?T(a,"default",{value:r,enumerable:!0}):a,r)),me=r=>q(T({},"__esModule",{value:!0}),r);var Y=C((M,L)=>{(function(r,t){typeof M=="object"&&typeof L<"u"?L.exports=t():typeof define=="function"&&define.amd?define(t):r.typeDetect=t()})(M,function(){"use strict";var r=typeof Promise=="function",t=typeof self=="object"?self:global,a=typeof Symbol<"u",g=typeof Map<"u",u=typeof Set<"u",m=typeof WeakMap<"u",f=typeof WeakSet<"u",e=typeof DataView<"u",y=a&&typeof Symbol.iterator<"u",s=a&&typeof Symbol.toStringTag<"u",o=u&&typeof Set.prototype.entries=="function",i=g&&typeof Map.prototype.entries=="function",p=o&&Object.getPrototypeOf(new Set().entries()),b=i&&Object.getPrototypeOf(new Map().entries()),S=y&&typeof Array.prototype[Symbol.iterator]=="function",E=S&&Object.getPrototypeOf([][Symbol.iterator]()),c=y&&typeof String.prototype[Symbol.iterator]=="function",n=c&&Object.getPrototypeOf(""[Symbol.iterator]()),l=8,$=-1;function d(h){var W=typeof h;if(W!=="object")return W;if(h===null)return"null";if(h===t)return"global";if(Array.isArray(h)&&(s===!1||!(Symbol.toStringTag in h)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&h===window.location)return"Location";if(typeof window.document=="object"&&h===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&h===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&h===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&h instanceof window.HTMLElement){if(h.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(h.tagName==="TD")return"HTMLTableDataCellElement";if(h.tagName==="TH")return"HTMLTableHeaderCellElement"}}var U=s&&h[Symbol.toStringTag];if(typeof U=="string")return U;var O=Object.getPrototypeOf(h);return O===RegExp.prototype?"RegExp":O===Date.prototype?"Date":r&&O===Promise.prototype?"Promise":u&&O===Set.prototype?"Set":g&&O===Map.prototype?"Map":f&&O===WeakSet.prototype?"WeakSet":m&&O===WeakMap.prototype?"WeakMap":e&&O===DataView.prototype?"DataView":g&&O===b?"Map Iterator":u&&O===p?"Set Iterator":S&&O===E?"Array Iterator":c&&O===n?"String Iterator":O===null?"Object":Object.prototype.toString.call(h).slice(l,$)}return d})});var J=C((De,z)=>{"use strict";z.exports=ge;function N(r){return r instanceof Buffer?Buffer.from(r):new r.constructor(r.buffer.slice(),r.byteOffset,r.length)}function ge(r){if(r=r||{},r.circles)return $e(r);return r.proto?g:a;function t(u,m){for(var f=Object.keys(u),e=new Array(f.length),y=0;y<f.length;y++){var s=f[y],o=u[s];typeof o!="object"||o===null?e[s]=o:o instanceof Date?e[s]=new Date(o):ArrayBuffer.isView(o)?e[s]=N(o):e[s]=m(o)}return e}function a(u){if(typeof u!="object"||u===null)return u;if(u instanceof Date)return new Date(u);if(Array.isArray(u))return t(u,a);if(u instanceof Map)return new Map(t(Array.from(u),a));if(u instanceof Set)return new Set(t(Array.from(u),a));var m={};for(var f in u)if(Object.hasOwnProperty.call(u,f)!==!1){var e=u[f];typeof e!="object"||e===null?m[f]=e:e instanceof Date?m[f]=new Date(e):e instanceof Map?m[f]=new Map(t(Array.from(e),a)):e instanceof Set?m[f]=new Set(t(Array.from(e),a)):ArrayBuffer.isView(e)?m[f]=N(e):m[f]=a(e)}return m}function g(u){if(typeof u!="object"||u===null)return u;if(u instanceof Date)return new Date(u);if(Array.isArray(u))return t(u,g);if(u instanceof Map)return new Map(t(Array.from(u),g));if(u instanceof Set)return new Set(t(Array.from(u),g));var m={};for(var f in u){var e=u[f];typeof e!="object"||e===null?m[f]=e:e instanceof Date?m[f]=new Date(e):e instanceof Map?m[f]=new Map(t(Array.from(e),g)):e instanceof Set?m[f]=new Set(t(Array.from(e),g)):ArrayBuffer.isView(e)?m[f]=N(e):m[f]=g(e)}return m}}function $e(r){var t=[],a=[];return r.proto?m:u;function g(f,e){for(var y=Object.keys(f),s=new Array(y.length),o=0;o<y.length;o++){var i=y[o],p=f[i];if(typeof p!="object"||p===null)s[i]=p;else if(p instanceof Date)s[i]=new Date(p);else if(ArrayBuffer.isView(p))s[i]=N(p);else{var b=t.indexOf(p);b!==-1?s[i]=a[b]:s[i]=e(p)}}return s}function u(f){if(typeof f!="object"||f===null)return f;if(f instanceof Date)return new Date(f);if(Array.isArray(f))return g(f,u);if(f instanceof Map)return new Map(g(Array.from(f),u));if(f instanceof Set)return new Set(g(Array.from(f),u));var e={};t.push(f),a.push(e);for(var y in f)if(Object.hasOwnProperty.call(f,y)!==!1){var s=f[y];if(typeof s!="object"||s===null)e[y]=s;else if(s instanceof Date)e[y]=new Date(s);else if(s instanceof Map)e[y]=new Map(g(Array.from(s),u));else if(s instanceof Set)e[y]=new Set(g(Array.from(s),u));else if(ArrayBuffer.isView(s))e[y]=N(s);else{var o=t.indexOf(s);o!==-1?e[y]=a[o]:e[y]=u(s)}}return t.pop(),a.pop(),e}function m(f){if(typeof f!="object"||f===null)return f;if(f instanceof Date)return new Date(f);if(Array.isArray(f))return g(f,m);if(f instanceof Map)return new Map(g(Array.from(f),m));if(f instanceof Set)return new Set(g(Array.from(f),m));var e={};t.push(f),a.push(e);for(var y in f){var s=f[y];if(typeof s!="object"||s===null)e[y]=s;else if(s instanceof Date)e[y]=new Date(s);else if(s instanceof Map)e[y]=new Map(g(Array.from(s),m));else if(s instanceof Set)e[y]=new Set(g(Array.from(s),m));else if(ArrayBuffer.isView(s))e[y]=N(s);else{var o=t.indexOf(s);o!==-1?e[y]=a[o]:e[y]=m(s)}}return t.pop(),a.pop(),e}}});var re=C((te,V)=>{(function(r,t){"use strict";typeof V=="object"&&typeof V.exports=="object"?V.exports=t():typeof define=="function"&&define.amd?define([],t):r.objectPath=t()})(te,function(){"use strict";var r=Object.prototype.toString;function t(o,i){return o==null?!1:Object.prototype.hasOwnProperty.call(o,i)}function a(o){if(!o||m(o)&&o.length===0)return!0;if(typeof o!="string"){for(var i in o)if(t(o,i))return!1;return!0}return!1}function g(o){return r.call(o)}function u(o){return typeof o=="object"&&g(o)==="[object Object]"}var m=Array.isArray||function(o){return r.call(o)==="[object Array]"};function f(o){return typeof o=="boolean"||g(o)==="[object Boolean]"}function e(o){var i=parseInt(o);return i.toString()===o?i:o}function y(o){o=o||{};var i=function(c){return Object.keys(i).reduce(function(n,l){return l==="create"||typeof i[l]=="function"&&(n[l]=i[l].bind(i,c)),n},{})},p;o.includeInheritedProps?p=function(){return!0}:p=function(c,n){return typeof n=="number"&&Array.isArray(c)||t(c,n)};function b(c,n){if(p(c,n))return c[n]}var S;o.includeInheritedProps?S=function(c,n){typeof n!="string"&&typeof n!="number"&&(n=String(n));var l=b(c,n);if(n==="__proto__"||n==="prototype"||n==="constructor"&&typeof l=="function")throw new Error("For security reasons, object's magic properties cannot be set");return l}:S=function(c,n){return b(c,n)};function E(c,n,l,$){if(typeof n=="number"&&(n=[n]),!n||n.length===0)return c;if(typeof n=="string")return E(c,n.split(".").map(e),l,$);var d=n[0],h=S(c,d);return n.length===1?((h===void 0||!$)&&(c[d]=l),h):(h===void 0&&(typeof n[1]=="number"?c[d]=[]:c[d]={}),E(c[d],n.slice(1),l,$))}return i.has=function(c,n){if(typeof n=="number"?n=[n]:typeof n=="string"&&(n=n.split(".")),!n||n.length===0)return!!c;for(var l=0;l<n.length;l++){var $=e(n[l]);if(typeof $=="number"&&m(c)&&$<c.length||(o.includeInheritedProps?$ in Object(c):t(c,$)))c=c[$];else return!1}return!0},i.ensureExists=function(c,n,l){return E(c,n,l,!0)},i.set=function(c,n,l,$){return E(c,n,l,$)},i.insert=function(c,n,l,$){var d=i.get(c,n);$=~~$,m(d)||(d=[],i.set(c,n,d)),d.splice($,0,l)},i.empty=function(c,n){if(!a(n)&&c!=null){var l,$;if(l=i.get(c,n)){if(typeof l=="string")return i.set(c,n,"");if(f(l))return i.set(c,n,!1);if(typeof l=="number")return i.set(c,n,0);if(m(l))l.length=0;else if(u(l))for($ in l)p(l,$)&&delete l[$];else return i.set(c,n,null)}}},i.push=function(c,n){var l=i.get(c,n);m(l)||(l=[],i.set(c,n,l)),l.push.apply(l,Array.prototype.slice.call(arguments,2))},i.coalesce=function(c,n,l){for(var $,d=0,h=n.length;d<h;d++)if(($=i.get(c,n[d]))!==void 0)return $;return l},i.get=function(c,n,l){if(typeof n=="number"&&(n=[n]),!n||n.length===0)return c;if(c==null)return l;if(typeof n=="string")return i.get(c,n.split("."),l);var $=e(n[0]),d=S(c,$);return d===void 0?l:n.length===1?d:i.get(c[$],n.slice(1),l)},i.del=function(n,l){if(typeof l=="number"&&(l=[l]),n==null||a(l))return n;if(typeof l=="string")return i.del(n,l.split("."));var $=e(l[0]);if(S(n,$),!p(n,$))return n;if(l.length===1)m(n)?n.splice($,1):delete n[$];else return i.del(n[$],l.slice(1));return n},i}var s=y();return s.create=y,s.withInheritedProps=y({includeInheritedProps:!0}),s})});var Ae={};ye(Ae,{checkTypesMini:()=>ve,defaults:()=>ie,version:()=>Se});var w=P(Y(),1);var ee=P(J(),1);var Z=P(J(),1);var Ne=(0,Z.default)();function A(r){if(r==null||typeof r!="object")return!1;let t=Object.getPrototypeOf(r);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in r)&&!(Symbol.toStringTag in r)}function D(r=[],t=[]){return!r||!Array.isArray(r)||!r.length?[]:!t||!Array.isArray(t)||!t.length?r:r.filter(a=>!t.includes(a))}function X(r=[],t=[]){return!r||!t?[]:Array.from(new Set(Array.from(r).filter(a=>new Set(t).has(a))))}function he(r){if(r.includes(".")){let t=r.lastIndexOf(".");if(!r.slice(0,t).includes("."))return r.slice(0,t);for(let a=t-1;a--;)if(r[a]===".")return r.slice(a+1,t)}return null}var k=he;var K=(0,ee.default)();function B(r,t){let a={now:!1};function g(u,m,f,e){let y=K(u),s,o=v({depth:-1,path:""},f);if(o.depth+=1,Array.isArray(y))for(let i=0,p=y.length;i<p&&!e.now;i++){let b=o.path?`${o.path}.${i}`:`${i}`;y[i]!==void 0?(o.parent=K(y),o.parentType="array",o.parentKey=k(b),s=g(m(y[i],void 0,x(v({},o),{path:b}),e),m,x(v({},o),{path:b}),e),Number.isNaN(s)&&i<y.length?(y.splice(i,1),i-=1):y[i]=s):y.splice(i,1)}else if(A(y))for(let i in y){if(e.now&&i!=null)break;let p=o.path?`${o.path}.${i}`:i;o.depth===0&&i!=null&&(o.topmostKey=i),o.parent=K(y),o.parentType="object",o.parentKey=k(p),s=g(m(i,y[i],x(v({},o),{path:p}),e),m,x(v({},o),{path:p}),e),Number.isNaN(s)?delete y[i]:y[i]=s}return y}return g(r,t,{},a)}function H(r){return typeof r!="string"?r:r.length?[r]:[]}var I=P(re(),1);function R(r){if(typeof r!="string")throw new TypeError("Expected a string");return r.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var F=new Map,ne=(r,t)=>{if(!Array.isArray(r))switch(typeof r){case"string":r=[r];break;case"undefined":r=[];break;default:throw new TypeError(`Expected '${t}' to be a string or an array, but got a type of '${typeof r}'`)}return r.filter(a=>{if(typeof a!="string"){if(typeof a>"u")return!1;throw new TypeError(`Expected '${t}' to be an array of strings, but found a type of '${typeof a}' in the array`)}return!0})},de=(r,t)=>{t=v({caseSensitive:!1},t);let a=r+JSON.stringify(t);if(F.has(a))return F.get(a);let g=r[0]==="!";g&&(r=r.slice(1)),r=R(r).replace(/\\\*/g,"[\\s\\S]*");let u=new RegExp(`^${r}$`,t.caseSensitive?"":"i");return u.negated=g,F.set(a,u),u},be=(r,t,a,g)=>{if(r=ne(r,"inputs"),t=ne(t,"patterns"),t.length===0)return[];t=t.map(f=>de(f,a));let{allPatterns:u}=a||{},m=[];for(let f of r){let e,y=[...t].fill(!1);for(let[s,o]of t.entries())if(o.test(f)&&(y[s]=!0,e=!o.negated,!e))break;if(!(e===!1||e===void 0&&t.some(s=>!s.negated)||u&&y.some((s,o)=>!s&&!t[o].negated))&&(m.push(f),g))break}return m};function j(r,t,a){return be(r,t,a,!0).length>0}var se="8.0.19";var Se=se,ie={ignoreKeys:[],ignorePaths:[],acceptArrays:!1,acceptArraysIgnore:[],enforceStrictKeyset:!0,schema:{},msg:"check-types-mini",optsVarName:"opts"};function Oe(r,t,a){function g(s){return s!=null}function u(s,o){return typeof o=="string"&&(o=H(o)),Array.from(s).filter(i=>!o.some(p=>j(i,p,{caseSensitive:!0})))}let m=Object.prototype.hasOwnProperty,f=["any","anything","every","everything","all","whatever","whatevs"];if(!g(r))throw new Error("check-types-mini: [THROW_ID_01] First argument is missing!");let e=v(v({},ie),a);if(typeof e.ignoreKeys=="string"&&(e.ignoreKeys=[e.ignoreKeys]),typeof e.ignorePaths=="string"&&(e.ignorePaths=[e.ignorePaths]),typeof e.acceptArraysIgnore=="string"&&(e.acceptArraysIgnore=[e.acceptArraysIgnore]),e.msg=`${e.msg}`.trim(),e.msg[e.msg.length-1]===":"&&(e.msg=e.msg.slice(0,e.msg.length-1).trim()),A(e.schema))Object.keys(e.schema).forEach(s=>{if(A(e.schema[s])){let o={};B(e.schema[s],(i,p,b)=>{let S=p!==void 0?p:i;return!Array.isArray(S)&&!A(S)&&(o[`${s}.${b.path}`]=S),S}),delete e.schema[s],e.schema=v(v({},e.schema),o)}}),Object.keys(e.schema).forEach(s=>{Array.isArray(e.schema[s])||(e.schema[s]=[e.schema[s]]),e.schema[s]=e.schema[s].map(o=>`${o}`.toLowerCase().trim())});else if(e.schema!=null)throw new Error(`check-types-mini: opts.schema was customised to ${JSON.stringify(e.schema,null,0)} which is not object but ${typeof e.schema}`);if(g(t)||(t={}),e.enforceStrictKeyset)if(g(e.schema)&&Object.keys(e.schema).length){if(t&&u(D(Object.keys(r),Object.keys(t).concat(Object.keys(e.schema))),e.ignoreKeys).length){let s=D(Object.keys(r),Object.keys(t).concat(Object.keys(e.schema)));throw new TypeError(`${e.msg}: ${e.optsVarName}.enforceStrictKeyset is on and the following key${s.length>1?"s":""} ${s.length>1?"are":"is"} not covered by schema and/or reference objects: ${s.join(", ")}`)}}else if(A(t)&&Object.keys(t).length){if(u(D(Object.keys(r),Object.keys(t)),e.ignoreKeys).length!==0){let s=D(Object.keys(r),Object.keys(t));throw new TypeError(`${e.msg}: The input object has key${s.length>1?"s":""} which ${s.length>1?"are":"is"} not covered by the reference object: ${s.join(", ")}`)}else if(u(D(Object.keys(t),Object.keys(r)),e.ignoreKeys).length!==0){let s=D(Object.keys(t),Object.keys(r));throw new TypeError(`${e.msg}: The reference object has key${s.length>1?"s":""} which ${s.length>1?"are":"is"} not present in the input object: ${s.join(", ")}`)}}else throw new TypeError(`${e.msg}: Both ${e.optsVarName}.schema and reference objects are missing! We don't have anything to match the keys as you requested via resolvedOpts.enforceStrictKeyset!`);let y=[];B(r,(s,o,i)=>{let p=o,b=s;if(i.parentType==="array"&&(b=void 0,p=s),Array.isArray(y)&&y.length&&y.some(n=>i.path.startsWith(n))||b&&e.ignoreKeys.some(n=>b&&j(b,n))||e.ignorePaths.some(n=>j(i.path,n)))return p;let S=!(!A(p)&&!Array.isArray(p)&&Array.isArray(i.parent)),E=!1;A(e.schema)&&m.call(e.schema,i.path)&&(E=!0);let c=!1;if(A(t)&&I.default.has(t,i.path)&&(c=!0),e.enforceStrictKeyset&&S&&!E&&!c)throw new TypeError(`${e.msg}: ${e.optsVarName}.${i.path} is neither covered by reference object (second input argument), nor ${e.optsVarName}.schema! To stop this error, turn off ${e.optsVarName}.enforceStrictKeyset or provide some type reference (2nd argument or ${e.optsVarName}.schema).
|
|
10
|
+
"use strict";var checkTypesMini=(()=>{var oe=Object.create;var k=Object.defineProperty,ae=Object.defineProperties,ce=Object.getOwnPropertyDescriptor,le=Object.getOwnPropertyDescriptors,ue=Object.getOwnPropertyNames,U=Object.getOwnPropertySymbols,fe=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var Q=(e,t,c)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:c}):e[t]=c,E=(e,t)=>{for(var c in t||(t={}))_.call(t,c)&&Q(e,c,t[c]);if(U)for(var c of U(t))pe.call(t,c)&&Q(e,c,t[c]);return e},j=(e,t)=>ae(e,le(t));var L=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ye=(e,t)=>{for(var c in t)k(e,c,{get:t[c],enumerable:!0})},q=(e,t,c,g)=>{if(t&&typeof t=="object"||typeof t=="function")for(let y of ue(t))!_.call(e,y)&&y!==c&&k(e,y,{get:()=>t[y],enumerable:!(g=ce(t,y))||g.enumerable});return e};var P=(e,t,c)=>(c=e!=null?oe(fe(e)):{},q(t||!e||!e.__esModule?k(c,"default",{value:e,enumerable:!0}):c,e)),ge=e=>q(k({},"__esModule",{value:!0}),e);var Y=L((J,M)=>{(function(e,t){typeof J=="object"&&typeof M<"u"?M.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.typeDetect=t())})(J,function(){"use strict";var e=typeof Promise=="function",t=function(d){if(typeof globalThis=="object")return globalThis;Object.defineProperty(d,"typeDetectGlobalObject",{get:function(){return this},configurable:!0});var T=typeDetectGlobalObject;return delete d.typeDetectGlobalObject,T}(Object.prototype),c=typeof Symbol<"u",g=typeof Map<"u",y=typeof Set<"u",h=typeof WeakMap<"u",p=typeof WeakSet<"u",r=typeof DataView<"u",a=c&&typeof Symbol.iterator<"u",i=c&&typeof Symbol.toStringTag<"u",o=y&&typeof Set.prototype.entries=="function",n=g&&typeof Map.prototype.entries=="function",l=o&&Object.getPrototypeOf(new Set().entries()),b=n&&Object.getPrototypeOf(new Map().entries()),$=a&&typeof Array.prototype[Symbol.iterator]=="function",S=$&&Object.getPrototypeOf([][Symbol.iterator]()),f=a&&typeof String.prototype[Symbol.iterator]=="function",s=f&&Object.getPrototypeOf(""[Symbol.iterator]()),u=8,m=-1;function O(d){var T=typeof d;if(T!=="object")return T;if(d===null)return"null";if(d===t)return"global";if(Array.isArray(d)&&(i===!1||!(Symbol.toStringTag in d)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&d===window.location)return"Location";if(typeof window.document=="object"&&d===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&d===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&d===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&d instanceof window.HTMLElement){if(d.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(d.tagName==="TD")return"HTMLTableDataCellElement";if(d.tagName==="TH")return"HTMLTableHeaderCellElement"}}var C=i&&d[Symbol.toStringTag];if(typeof C=="string")return C;var A=Object.getPrototypeOf(d);return A===RegExp.prototype?"RegExp":A===Date.prototype?"Date":e&&A===Promise.prototype?"Promise":y&&A===Set.prototype?"Set":g&&A===Map.prototype?"Map":p&&A===WeakSet.prototype?"WeakSet":h&&A===WeakMap.prototype?"WeakMap":r&&A===DataView.prototype?"DataView":g&&A===b?"Map Iterator":y&&A===l?"Set Iterator":$&&A===S?"Array Iterator":f&&A===s?"String Iterator":A===null?"Object":Object.prototype.toString.call(d).slice(u,m)}return O})});var K=L((ve,z)=>{"use strict";z.exports=me;function N(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function me(e){if(e=e||{},e.circles)return he(e);let t=new Map;if(t.set(Date,p=>new Date(p)),t.set(Map,(p,r)=>new Map(g(Array.from(p),r))),t.set(Set,(p,r)=>new Set(g(Array.from(p),r))),e.constructorHandlers)for(let p of e.constructorHandlers)t.set(p[0],p[1]);let c=null;return e.proto?h:y;function g(p,r){let a=Object.keys(p),i=new Array(a.length);for(let o=0;o<a.length;o++){let n=a[o],l=p[n];typeof l!="object"||l===null?i[n]=l:l.constructor!==Object&&(c=t.get(l.constructor))?i[n]=c(l,r):ArrayBuffer.isView(l)?i[n]=N(l):i[n]=r(l)}return i}function y(p){if(typeof p!="object"||p===null)return p;if(Array.isArray(p))return g(p,y);if(p.constructor!==Object&&(c=t.get(p.constructor)))return c(p,y);let r={};for(let a in p){if(Object.hasOwnProperty.call(p,a)===!1)continue;let i=p[a];typeof i!="object"||i===null?r[a]=i:i.constructor!==Object&&(c=t.get(i.constructor))?r[a]=c(i,y):ArrayBuffer.isView(i)?r[a]=N(i):r[a]=y(i)}return r}function h(p){if(typeof p!="object"||p===null)return p;if(Array.isArray(p))return g(p,h);if(p.constructor!==Object&&(c=t.get(p.constructor)))return c(p,h);let r={};for(let a in p){let i=p[a];typeof i!="object"||i===null?r[a]=i:i.constructor!==Object&&(c=t.get(i.constructor))?r[a]=c(i,h):ArrayBuffer.isView(i)?r[a]=N(i):r[a]=h(i)}return r}}function he(e){let t=[],c=[],g=new Map;if(g.set(Date,a=>new Date(a)),g.set(Map,(a,i)=>new Map(h(Array.from(a),i))),g.set(Set,(a,i)=>new Set(h(Array.from(a),i))),e.constructorHandlers)for(let a of e.constructorHandlers)g.set(a[0],a[1]);let y=null;return e.proto?r:p;function h(a,i){let o=Object.keys(a),n=new Array(o.length);for(let l=0;l<o.length;l++){let b=o[l],$=a[b];if(typeof $!="object"||$===null)n[b]=$;else if($.constructor!==Object&&(y=g.get($.constructor)))n[b]=y($,i);else if(ArrayBuffer.isView($))n[b]=N($);else{let S=t.indexOf($);S!==-1?n[b]=c[S]:n[b]=i($)}}return n}function p(a){if(typeof a!="object"||a===null)return a;if(Array.isArray(a))return h(a,p);if(a.constructor!==Object&&(y=g.get(a.constructor)))return y(a,p);let i={};t.push(a),c.push(i);for(let o in a){if(Object.hasOwnProperty.call(a,o)===!1)continue;let n=a[o];if(typeof n!="object"||n===null)i[o]=n;else if(n.constructor!==Object&&(y=g.get(n.constructor)))i[o]=y(n,p);else if(ArrayBuffer.isView(n))i[o]=N(n);else{let l=t.indexOf(n);l!==-1?i[o]=c[l]:i[o]=p(n)}}return t.pop(),c.pop(),i}function r(a){if(typeof a!="object"||a===null)return a;if(Array.isArray(a))return h(a,r);if(a.constructor!==Object&&(y=g.get(a.constructor)))return y(a,r);let i={};t.push(a),c.push(i);for(let o in a){let n=a[o];if(typeof n!="object"||n===null)i[o]=n;else if(n.constructor!==Object&&(y=g.get(n.constructor)))i[o]=y(n,r);else if(ArrayBuffer.isView(n))i[o]=N(n);else{let l=t.indexOf(n);l!==-1?i[o]=c[l]:i[o]=r(n)}}return t.pop(),c.pop(),i}}});var re=L((te,x)=>{(function(e,t){"use strict";typeof x=="object"&&typeof x.exports=="object"?x.exports=t():typeof define=="function"&&define.amd?define([],t):e.objectPath=t()})(te,function(){"use strict";var e=Object.prototype.toString;function t(o,n){return o==null?!1:Object.prototype.hasOwnProperty.call(o,n)}function c(o){if(!o||h(o)&&o.length===0)return!0;if(typeof o!="string"){for(var n in o)if(t(o,n))return!1;return!0}return!1}function g(o){return e.call(o)}function y(o){return typeof o=="object"&&g(o)==="[object Object]"}var h=Array.isArray||function(o){return e.call(o)==="[object Array]"};function p(o){return typeof o=="boolean"||g(o)==="[object Boolean]"}function r(o){var n=parseInt(o);return n.toString()===o?n:o}function a(o){o=o||{};var n=function(f){return Object.keys(n).reduce(function(s,u){return u==="create"||typeof n[u]=="function"&&(s[u]=n[u].bind(n,f)),s},{})},l;o.includeInheritedProps?l=function(){return!0}:l=function(f,s){return typeof s=="number"&&Array.isArray(f)||t(f,s)};function b(f,s){if(l(f,s))return f[s]}var $;o.includeInheritedProps?$=function(f,s){typeof s!="string"&&typeof s!="number"&&(s=String(s));var u=b(f,s);if(s==="__proto__"||s==="prototype"||s==="constructor"&&typeof u=="function")throw new Error("For security reasons, object's magic properties cannot be set");return u}:$=function(f,s){return b(f,s)};function S(f,s,u,m){if(typeof s=="number"&&(s=[s]),!s||s.length===0)return f;if(typeof s=="string")return S(f,s.split(".").map(r),u,m);var O=s[0],d=$(f,O);return s.length===1?((d===void 0||!m)&&(f[O]=u),d):(d===void 0&&(typeof s[1]=="number"?f[O]=[]:f[O]={}),S(f[O],s.slice(1),u,m))}return n.has=function(f,s){if(typeof s=="number"?s=[s]:typeof s=="string"&&(s=s.split(".")),!s||s.length===0)return!!f;for(var u=0;u<s.length;u++){var m=r(s[u]);if(typeof m=="number"&&h(f)&&m<f.length||(o.includeInheritedProps?m in Object(f):t(f,m)))f=f[m];else return!1}return!0},n.ensureExists=function(f,s,u){return S(f,s,u,!0)},n.set=function(f,s,u,m){return S(f,s,u,m)},n.insert=function(f,s,u,m){var O=n.get(f,s);m=~~m,h(O)||(O=[],n.set(f,s,O)),O.splice(m,0,u)},n.empty=function(f,s){if(!c(s)&&f!=null){var u,m;if(u=n.get(f,s)){if(typeof u=="string")return n.set(f,s,"");if(p(u))return n.set(f,s,!1);if(typeof u=="number")return n.set(f,s,0);if(h(u))u.length=0;else if(y(u))for(m in u)l(u,m)&&delete u[m];else return n.set(f,s,null)}}},n.push=function(f,s){var u=n.get(f,s);h(u)||(u=[],n.set(f,s,u)),u.push.apply(u,Array.prototype.slice.call(arguments,2))},n.coalesce=function(f,s,u){for(var m,O=0,d=s.length;O<d;O++)if((m=n.get(f,s[O]))!==void 0)return m;return u},n.get=function(f,s,u){if(typeof s=="number"&&(s=[s]),!s||s.length===0)return f;if(f==null)return u;if(typeof s=="string")return n.get(f,s.split("."),u);var m=r(s[0]),O=$(f,m);return O===void 0?u:s.length===1?O:n.get(f[m],s.slice(1),u)},n.del=function(s,u){if(typeof u=="number"&&(u=[u]),s==null||c(u))return s;if(typeof u=="string")return n.del(s,u.split("."));var m=r(u[0]);if($(s,m),!l(s,m))return s;if(u.length===1)h(s)?s.splice(m,1):delete s[m];else return n.del(s[m],u.slice(1));return s},n}var i=a();return i.create=a,i.withInheritedProps=a({includeInheritedProps:!0}),i})});var Ae={};ye(Ae,{checkTypesMini:()=>Se,defaults:()=>ie,version:()=>Oe});var w=P(Y(),1);var ee=P(K(),1);var Z=P(K(),1);var De=(0,Z.default)();function v(e){if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function D(e=[],t=[]){return!e||!Array.isArray(e)||!e.length?[]:!t||!Array.isArray(t)||!t.length?e:e.filter(c=>!t.includes(c))}function X(e=[],t=[]){return!e||!t?[]:Array.from(new Set(Array.from(e).filter(c=>new Set(t).has(c))))}function H(e){if(e.includes(".")){let t=e.lastIndexOf(".");if(!e.slice(0,t).includes("."))return e.slice(0,t);for(let c=t-1;c--;)if(e[c]===".")return e.slice(c+1,t)}return null}var B=(0,ee.default)();function R(e,t){let c={now:!1};function g(y,h,p,r){let a=B(y),i,o=E({depth:-1,path:""},p);if(o.depth+=1,Array.isArray(a))for(let n=0,l=a.length;n<l&&!r.now;n++){let b=o.path?`${o.path}.${n}`:`${n}`;a[n]!==void 0?(o.parent=B(a),o.parentType="array",o.parentKey=H(b),i=g(h(a[n],void 0,j(E({},o),{path:b}),r),h,j(E({},o),{path:b}),r),Number.isNaN(i)&&n<a.length?(a.splice(n,1),n-=1):a[n]=i):a.splice(n,1)}else if(v(a))for(let n in a){if(r.now&&n!=null)break;let l=o.path?`${o.path}.${n}`:n;o.depth===0&&n!=null&&(o.topmostKey=n),o.parent=B(a),o.parentType="object",o.parentKey=H(l),i=g(h(n,a[n],j(E({},o),{path:l}),r),h,j(E({},o),{path:l}),r),Number.isNaN(i)?delete a[n]:a[n]=i}return a}return g(e,t,{},c)}function F(e){return typeof e!="string"?e:e.length?[e]:[]}var I=P(re(),1);function W(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var G=new Map,ne=(e,t)=>{if(!Array.isArray(e))switch(typeof e){case"string":e=[e];break;case"undefined":e=[];break;default:throw new TypeError(`Expected '${t}' to be a string or an array, but got a type of '${typeof e}'`)}return e.filter(c=>{if(typeof c!="string"){if(typeof c>"u")return!1;throw new TypeError(`Expected '${t}' to be an array of strings, but found a type of '${typeof c}' in the array`)}return!0})},$e=(e,t)=>{t=E({caseSensitive:!1},t);let c=e+JSON.stringify(t);if(G.has(c))return G.get(c);let g=e[0]==="!";g&&(e=e.slice(1)),e=W(e).replace(/\\\*/g,"[\\s\\S]*");let y=new RegExp(`^${e}$`,t.caseSensitive?"":"i");return y.negated=g,G.set(c,y),y},de=(e,t,c,g)=>{if(e=ne(e,"inputs"),t=ne(t,"patterns"),t.length===0)return[];t=t.map(p=>$e(p,c));let{allPatterns:y}=c||{},h=[];for(let p of e){let r,a=[...t].fill(!1);for(let[i,o]of t.entries())if(o.test(p)&&(a[i]=!0,r=!o.negated,!r))break;if(!(r===!1||r===void 0&&t.some(i=>!i.negated)||y&&a.some((i,o)=>!i&&!t[o].negated))&&(h.push(p),g))break}return h};function V(e,t,c){return de(e,t,c,!0).length>0}var se="8.0.22";var Oe=se,ie={ignoreKeys:[],ignorePaths:[],acceptArrays:!1,acceptArraysIgnore:[],enforceStrictKeyset:!0,schema:{},msg:"check-types-mini",optsVarName:"opts"};function we(e,t,c){function g(i){return i!=null}function y(i,o){return typeof o=="string"&&(o=F(o)),Array.from(i).filter(n=>!o.some(l=>V(n,l,{caseSensitive:!0})))}let h=Object.prototype.hasOwnProperty,p=["any","anything","every","everything","all","whatever","whatevs"];if(!g(e))throw new Error("check-types-mini: [THROW_ID_01] First argument is missing!");let r=E(E({},ie),c);if(typeof r.ignoreKeys=="string"&&(r.ignoreKeys=[r.ignoreKeys]),typeof r.ignorePaths=="string"&&(r.ignorePaths=[r.ignorePaths]),typeof r.acceptArraysIgnore=="string"&&(r.acceptArraysIgnore=[r.acceptArraysIgnore]),r.msg=`${r.msg}`.trim(),r.msg[r.msg.length-1]===":"&&(r.msg=r.msg.slice(0,r.msg.length-1).trim()),v(r.schema))Object.keys(r.schema).forEach(i=>{if(v(r.schema[i])){let o={};R(r.schema[i],(n,l,b)=>{let $=l!==void 0?l:n;return!Array.isArray($)&&!v($)&&(o[`${i}.${b.path}`]=$),$}),delete r.schema[i],r.schema=E(E({},r.schema),o)}}),Object.keys(r.schema).forEach(i=>{Array.isArray(r.schema[i])||(r.schema[i]=[r.schema[i]]),r.schema[i]=r.schema[i].map(o=>`${o}`.toLowerCase().trim())});else if(r.schema!=null)throw new Error(`check-types-mini: opts.schema was customised to ${JSON.stringify(r.schema,null,0)} which is not object but ${typeof r.schema}`);if(g(t)||(t={}),r.enforceStrictKeyset)if(g(r.schema)&&Object.keys(r.schema).length){if(t&&y(D(Object.keys(e),Object.keys(t).concat(Object.keys(r.schema))),r.ignoreKeys).length){let i=D(Object.keys(e),Object.keys(t).concat(Object.keys(r.schema)));throw new TypeError(`${r.msg}: ${r.optsVarName}.enforceStrictKeyset is on and the following key${i.length>1?"s":""} ${i.length>1?"are":"is"} not covered by schema and/or reference objects: ${i.join(", ")}`)}}else if(v(t)&&Object.keys(t).length){if(y(D(Object.keys(e),Object.keys(t)),r.ignoreKeys).length!==0){let i=D(Object.keys(e),Object.keys(t));throw new TypeError(`${r.msg}: The input object has key${i.length>1?"s":""} which ${i.length>1?"are":"is"} not covered by the reference object: ${i.join(", ")}`)}else if(y(D(Object.keys(t),Object.keys(e)),r.ignoreKeys).length!==0){let i=D(Object.keys(t),Object.keys(e));throw new TypeError(`${r.msg}: The reference object has key${i.length>1?"s":""} which ${i.length>1?"are":"is"} not present in the input object: ${i.join(", ")}`)}}else throw new TypeError(`${r.msg}: Both ${r.optsVarName}.schema and reference objects are missing! We don't have anything to match the keys as you requested via resolvedOpts.enforceStrictKeyset!`);let a=[];R(e,(i,o,n)=>{let l=o,b=i;if(n.parentType==="array"&&(b=void 0,l=i),Array.isArray(a)&&a.length&&a.some(s=>n.path.startsWith(s))||b&&r.ignoreKeys.some(s=>b&&V(b,s))||r.ignorePaths.some(s=>V(n.path,s)))return l;let $=!(!v(l)&&!Array.isArray(l)&&Array.isArray(n.parent)),S=!1;v(r.schema)&&h.call(r.schema,n.path)&&(S=!0);let f=!1;if(v(t)&&I.default.has(t,n.path)&&(f=!0),r.enforceStrictKeyset&&$&&!S&&!f)throw new TypeError(`${r.msg}: ${r.optsVarName}.${n.path} is neither covered by reference object (second input argument), nor ${r.optsVarName}.schema! To stop this error, turn off ${r.optsVarName}.enforceStrictKeyset or provide some type reference (2nd argument or ${r.optsVarName}.schema).
|
|
11
11
|
|
|
12
12
|
Debug info:
|
|
13
13
|
|
|
14
|
-
obj = ${JSON.stringify(
|
|
14
|
+
obj = ${JSON.stringify(e,null,4)}
|
|
15
15
|
|
|
16
16
|
ref = ${JSON.stringify(t,null,4)}
|
|
17
17
|
|
|
18
|
-
innerObj = ${JSON.stringify(
|
|
18
|
+
innerObj = ${JSON.stringify(n,null,4)}
|
|
19
19
|
|
|
20
|
-
resolvedOpts = ${JSON.stringify(
|
|
20
|
+
resolvedOpts = ${JSON.stringify(r,null,4)}
|
|
21
21
|
|
|
22
|
-
current = ${JSON.stringify(
|
|
22
|
+
current = ${JSON.stringify(l,null,4)}
|
|
23
23
|
|
|
24
|
-
`);if(
|
|
24
|
+
`);if(S){let s=F(r.schema[n.path]).map(u=>`${u}`.toLowerCase());if(I.default.set(r.schema,n.path,s),X(s,p).length)a.push(n.path);else if(l!==!0&&l!==!1&&!s.includes((0,w.default)(l).toLowerCase())||(l===!0||l===!1)&&!s.includes(String(l))&&!s.includes("boolean"))if(Array.isArray(l)&&r.acceptArrays){for(let u=0,m=l.length;u<m;u++)if(!s.includes((0,w.default)(l[u]).toLowerCase()))throw new TypeError(`${r.msg}: ${r.optsVarName}.${n.path}.${u}, the ${u}th element (equal to ${JSON.stringify(l[u],null,0)}) is of a type ${(0,w.default)(l[u]).toLowerCase()}, but only the following are allowed by the ${r.optsVarName}.schema: ${s.join(", ")}`)}else throw new TypeError(`${r.msg}: ${r.optsVarName}.${n.path} was customised to ${(0,w.default)(l)!=="string"?'"':""}${JSON.stringify(l,null,0)}${(0,w.default)(l)!=="string"?'"':""} (type: ${(0,w.default)(l).toLowerCase()}) which is not among the allowed types in schema (which is equal to ${JSON.stringify(s,null,0)})`)}else if(t&&v(t)&&f){let s=I.default.get(t,n.path);if(r.acceptArrays&&Array.isArray(l)&&!r.acceptArraysIgnore.includes(i)){if(!l.every(m=>(0,w.default)(m).toLowerCase()===(0,w.default)(t[i]).toLowerCase()))throw new TypeError(`${r.msg}: ${r.optsVarName}.${n.path} was customised to be array, but not all of its elements are ${(0,w.default)(t[i]).toLowerCase()}-type`)}else if((0,w.default)(l)!==(0,w.default)(s))throw new TypeError(`${r.msg}: ${r.optsVarName}.${n.path} was customised to ${(0,w.default)(l).toLowerCase()==="string"?"":'"'}${JSON.stringify(l,null,0)}${(0,w.default)(l).toLowerCase()==="string"?"":'"'} which is not ${(0,w.default)(s).toLowerCase()} but ${(0,w.default)(l).toLowerCase()}`)}return l})}function Se(e,t,c){we(e,t,c)}return ge(Ae);})();
|
|
25
25
|
/**
|
|
26
26
|
* @name codsen-utils
|
|
27
27
|
* @fileoverview Various utility functions
|
|
28
|
-
* @version 1.6.
|
|
28
|
+
* @version 1.6.7
|
|
29
29
|
* @author Roy Revelt, Codsen Ltd
|
|
30
30
|
* @license MIT
|
|
31
31
|
* {@link https://codsen.com/os/codsen-utils/}
|
|
@@ -33,7 +33,7 @@ current = ${JSON.stringify(p,null,4)}
|
|
|
33
33
|
/**
|
|
34
34
|
* @name ast-monkey-util
|
|
35
35
|
* @fileoverview Utility library of AST helper functions
|
|
36
|
-
* @version 3.0.
|
|
36
|
+
* @version 3.0.10
|
|
37
37
|
* @author Roy Revelt, Codsen Ltd
|
|
38
38
|
* @license MIT
|
|
39
39
|
* {@link https://codsen.com/os/ast-monkey-util/}
|
|
@@ -41,7 +41,7 @@ current = ${JSON.stringify(p,null,4)}
|
|
|
41
41
|
/**
|
|
42
42
|
* @name ast-monkey-traverse
|
|
43
43
|
* @fileoverview Utility library to traverse AST
|
|
44
|
-
* @version 4.0.
|
|
44
|
+
* @version 4.0.19
|
|
45
45
|
* @author Roy Revelt, Codsen Ltd
|
|
46
46
|
* @license MIT
|
|
47
47
|
* {@link https://codsen.com/os/ast-monkey-traverse/}
|
|
@@ -49,7 +49,7 @@ current = ${JSON.stringify(p,null,4)}
|
|
|
49
49
|
/**
|
|
50
50
|
* @name arrayiffy-if-string
|
|
51
51
|
* @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
|
|
52
|
-
* @version 5.0.
|
|
52
|
+
* @version 5.0.10
|
|
53
53
|
* @author Roy Revelt, Codsen Ltd
|
|
54
54
|
* @license MIT
|
|
55
55
|
* {@link https://codsen.com/os/arrayiffy-if-string/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "check-types-mini",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.22",
|
|
4
4
|
"description": "Validate options object",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compare",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"homepage": "https://codsen.com/os/check-types-mini",
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://github.com/codsen/codsen.git",
|
|
22
|
+
"url": "git+https://github.com/codsen/codsen.git",
|
|
23
23
|
"directory": "packages/check-types-mini"
|
|
24
24
|
},
|
|
25
25
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
46
46
|
"lect": "node '../../ops/lect/lect.js' && npm run prettier -- 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
|
|
47
47
|
"letspublish": "npm publish || :",
|
|
48
|
-
"lint": "eslint . --
|
|
48
|
+
"lint": "eslint . --fix",
|
|
49
49
|
"perf": "node perf/check.js",
|
|
50
50
|
"prep": "echo 'ready'",
|
|
51
51
|
"prettier": "prettier",
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"arrayiffy-if-string": "^5.0.
|
|
76
|
-
"ast-monkey-traverse": "^4.0.
|
|
77
|
-
"codsen-utils": "^1.6.
|
|
75
|
+
"arrayiffy-if-string": "^5.0.10",
|
|
76
|
+
"ast-monkey-traverse": "^4.0.19",
|
|
77
|
+
"codsen-utils": "^1.6.7",
|
|
78
78
|
"matcher": "^5.0.0",
|
|
79
79
|
"object-path": "^0.11.8",
|
|
80
|
-
"type-detect": "^4.0
|
|
80
|
+
"type-detect": "^4.1.0"
|
|
81
81
|
}
|
|
82
82
|
}
|