@oxog/kindof
Version:
Zero-dependency advanced type detection library with TypeScript support, plugin system, and 100% test coverage
11 lines (10 loc) • 36.7 kB
JavaScript
(function(n,d){typeof exports=="object"&&typeof module!="undefined"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(n=typeof globalThis!="undefined"?globalThis:n||self,d(n.kindOf={}))})(this,function(n){"use strict";const d={"[object Arguments]":"arguments","[object Array]":"array","[object ArrayBuffer]":"arraybuffer","[object AsyncFunction]":"asyncfunction","[object AsyncGeneratorFunction]":"asyncgeneratorfunction","[object BigInt]":"bigint","[object BigInt64Array]":"bigint64array","[object BigUint64Array]":"biguint64array","[object Boolean]":"boolean","[object DataView]":"dataview","[object Date]":"date","[object Error]":"error","[object Float32Array]":"float32array","[object Float64Array]":"float64array","[object Function]":"function","[object GeneratorFunction]":"generatorfunction","[object Int8Array]":"int8array","[object Int16Array]":"int16array","[object Int32Array]":"int32array","[object Map]":"map","[object Number]":"number","[object Object]":"object","[object Promise]":"promise","[object Proxy]":"proxy","[object RegExp]":"regexp","[object Set]":"set","[object SharedArrayBuffer]":"sharedarraybuffer","[object String]":"string","[object Symbol]":"symbol","[object Uint8Array]":"uint8array","[object Uint8ClampedArray]":"uint8clampedarray","[object Uint16Array]":"uint16array","[object Uint32Array]":"uint32array","[object WeakMap]":"weakmap","[object WeakSet]":"weakset","[object Window]":"window","[object HTMLDocument]":"document","[object Document]":"document","[object Null]":"null","[object Undefined]":"undefined"},X=Object.prototype.toString,Y=Symbol.toStringTag;function Z(e){if(e===void 0)return"undefined";if(e===null)return"null";switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"symbol":return"symbol";case"bigint":return"bigint";case"function":return Q(e);case"object":return x(e);default:return null}}function Q(e){var t;const r=e.toString();if(/^class\s/.test(r))return"function";if(/^async\s*function\s*\*/.test(r)||/^async\s*\*/.test(r))return"asyncgeneratorfunction";if(/^async\s/.test(r))return"asyncfunction";if(/^function\s*\*/.test(r)||/^\*/.test(r))return"generatorfunction";const o=(t=e.constructor)==null?void 0:t.name;return o==="AsyncFunction"?"asyncfunction":o==="GeneratorFunction"?"generatorfunction":o==="AsyncGeneratorFunction"?"asyncgeneratorfunction":"function"}function x(e){const t=X.call(e),r=d[t];if(r)return r;if(typeof Buffer!="undefined"&&Buffer.isBuffer&&Buffer.isBuffer(e))return"buffer";if(typeof e=="object"&&"callee"in e&&typeof e.callee=="function")return"arguments";if(ee(e))return"stream";if(te(e))return"eventemitter";if(t==="[object Object]"){const o=e[Y];if(typeof o=="string")return o.toLowerCase();const i=e.constructor;if(i&&i!==Object){const a=i.name;if(a&&a!=="Object")return a.toLowerCase()}}return re(e)?"element":ne(e)?"node":oe(e)?"global":"object"}function ee(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function te(e){return e!==null&&typeof e=="object"&&typeof e.on=="function"&&typeof e.emit=="function"&&typeof e.removeListener=="function"}function re(e){return typeof HTMLElement=="undefined"?!1:e instanceof HTMLElement}function ne(e){return typeof Node=="undefined"?!1:e instanceof Node}function oe(e){return typeof globalThis!="undefined"&&e===globalThis||typeof global!="undefined"&&e===global||typeof window!="undefined"&&e===window||typeof self!="undefined"&&e===self}const ie=WeakMap.prototype,ae=WeakSet.prototype,ue=Map.prototype,ce=Set.prototype,se=ArrayBuffer.prototype,fe=DataView.prototype,E=typeof SharedArrayBuffer!="undefined"?SharedArrayBuffer.prototype:null;function le(e){if(e==null)return null;try{if(e instanceof Promise||ye(e))return"promise";if(e instanceof Map||e.__proto__===ue)return"map";if(e instanceof Set||e.__proto__===ce)return"set";if(e instanceof WeakMap||e.__proto__===ie)return"weakmap";if(e instanceof WeakSet||e.__proto__===ae)return"weakset";if(e instanceof ArrayBuffer||e.__proto__===se)return"arraybuffer";if(E&&(e instanceof SharedArrayBuffer||e.__proto__===E))return"sharedarraybuffer";if(e instanceof DataView||e.__proto__===fe)return"dataview";if(pe(e))return"proxy"}catch(t){}return null}function ye(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function pe(e){try{if(typeof e!="object"&&typeof e!="function")return!1;new Proxy({},e);const t=Object.getOwnPropertyDescriptor(e,Symbol.toStringTag);return!!(t&&!t.configurable&&t.value==="Proxy")}catch(t){return!1}}function de(e){var t;if(!ArrayBuffer.isView(e))return null;const r=Object.getPrototypeOf(e);switch((t=r==null?void 0:r.constructor)==null?void 0:t.name){case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array";case"BigInt64Array":return"bigint64array";case"BigUint64Array":return"biguint64array";default:return null}}let y=null,b=!0;function u(e){if(e===void 0)return"undefined";if(e===null)return"null";const t=ge(e);if(t)return t;if(typeof e=="object"&&b&&y){const o=y.get(e);if(o)return o}let r=Z(e);if(!r||r==="object"){const o=le(e);if(o)r=o;else{const i=de(e);i?r=i:r=he(e)||r||"object"}}return typeof e=="object"&&b&&r&&(y||(y=new WeakMap),y.set(e,r)),r||"object"}function be(e){if(e===void 0)return"undefined";if(e===null)return"null";const t=typeof e;return t!=="object"&&t!=="function"?t:Array.isArray(e)?"array":e instanceof Date?"date":e instanceof RegExp?"regexp":e instanceof Error?"error":"object"}function me(e){const t=new Array(e.length);for(let r=0;r<e.length;r++)t[r]=u(e[r]);return t}function g(e){const t=u(e),r=e===null||typeof e!="object"&&typeof e!="function";let o=null,i=null,a=!1,c=!1,s=null;const l={};if(!r&&e!==null){const f=e;f.constructor&&(o=f.constructor.name||null);const O=Object.getPrototypeOf(f);O&&O.constructor&&(i=O.constructor.name||null),a=typeof f[Symbol.iterator]=="function",c=typeof f[Symbol.asyncIterator]=="function"||t==="promise"||t==="asyncfunction"||t==="asyncgeneratorfunction",f[Symbol.toStringTag]&&(s=String(f[Symbol.toStringTag])),t==="array"?l.length=f.length:t==="map"||t==="set"?l.size=f.size:t==="arraybuffer"||t==="sharedarraybuffer"?l.byteLength=f.byteLength:t.includes("array")&&f.buffer&&(l.byteLength=f.byteLength,l.length=f.length)}return{type:t,constructor:o,prototype:i,isPrimitive:r,isBuiltIn:je(t),isNullish:e==null,isIterable:a,isAsync:c,customType:s,metadata:Object.keys(l).length>0?l:void 0}}function ge(e){const t=typeof e;switch(t){case"boolean":case"number":case"string":case"symbol":case"bigint":return t;default:return null}}function he(e){try{const t=e[Symbol.toStringTag];if(typeof t=="string")return t.toLowerCase();if(e.constructor&&e.constructor!==Object){const r=e.constructor.name;if(r&&r!=="Object")return r.toLowerCase()}}catch(t){}return null}function je(e){return new Set(["undefined","null","boolean","number","string","symbol","bigint","object","array","function","date","regexp","error","map","set","weakmap","weakset","int8array","uint8array","uint8clampedarray","int16array","uint16array","int32array","uint32array","float32array","float64array","bigint64array","biguint64array","promise","generatorfunction","asyncfunction","asyncgeneratorfunction","proxy","dataview","arraybuffer","sharedarraybuffer","arguments"]).has(e)}function $e(){b=!0,y||(y=new WeakMap)}function we(){b=!1,y=null}function Ae(){y&&(y=new WeakMap)}function Se(e){return e===void 0}function ve(e){return e===null}function Te(e){return typeof e=="boolean"}function Oe(e){return typeof e=="number"}function Ee(e){return typeof e=="string"}function Be(e){return typeof e=="symbol"}function Me(e){return typeof e=="bigint"}function Ie(e){return e===null||typeof e!="object"&&typeof e!="function"}function Pe(e){return e==null}function ke(e){return!e}function Ne(e){return!!e}function Fe(e){return typeof e=="number"&&Number.isInteger(e)}function Ce(e){return typeof e=="number"&&Number.isSafeInteger(e)}function _e(e){return typeof e=="number"&&Number.isFinite(e)}function h(e){return typeof e=="number"&&Number.isNaN(e)}function Ue(e){return e===1/0||e===-1/0}function Le(e){return e===""}function De(e){return typeof e!="string"||e===""?!1:!h(Number(e))&&!h(parseFloat(e))}function Re(e){if(typeof e!="string")return!1;try{return JSON.parse(e),!0}catch(t){return!1}}function B(e){return e!==null&&typeof e=="object"}function Ge(e){return Array.isArray(e)}function We(e){return typeof e=="function"}function He(e){return e instanceof Date}function ze(e){return e instanceof RegExp}function Ve(e){return e instanceof Error||e!==null&&typeof e=="object"&&"name"in e&&"message"in e&&"stack"in e}function Je(e){return e instanceof Promise||e!==null&&typeof e=="object"&&"then"in e&&typeof e.then=="function"}function qe(e){return Object.prototype.toString.call(e)==="[object Arguments]"}function Ke(e){return typeof Buffer!="undefined"&&e!==null&&typeof e=="object"&&"isBuffer"in Buffer&&Buffer.isBuffer(e)}function j(e){if(!B(e))return!1;const t=Object.getPrototypeOf(e);if(t===null)return!0;const r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.toString.call(r)===Function.prototype.toString.call(Object)}function Xe(e){return e==null?!0:typeof e=="string"||Array.isArray(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:j(e)?Object.keys(e).length===0:!1}function Ye(e){return Array.isArray(e)&&e.length===0}function Ze(e){return j(e)&&Object.keys(e).length===0}function M(e){return e!=null&&(typeof e=="object"||typeof e=="string")&&(typeof e=="string"||"length"in e)&&typeof e.length=="number"}function Qe(e){return e!=null&&typeof e=="object"&&"size"in e&&typeof e.size=="number"}function xe(e){return e!=null&&typeof e!="function"&&M(e)&&e.length>=0&&e.length<=Number.MAX_SAFE_INTEGER}function et(e){return e!=null&&typeof e[Symbol.iterator]=="function"}function I(e){return e!=null&&typeof e[Symbol.asyncIterator]=="function"}function tt(e){if(typeof e!="function")return!1;try{const t={},r=e.bind(t);return new r,!0}catch(t){return!1}}function rt(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&"then"in e&&typeof e.then=="function"}function nt(e){return e!==null&&typeof e=="object"&&"subscribe"in e&&typeof e.subscribe=="function"}function ot(e){return e!==null&&typeof e=="object"&&typeof e.next=="function"&&typeof e.throw=="function"&&typeof e.return=="function"}function it(e){return e!==null&&typeof e=="object"&&typeof e.next=="function"&&typeof e.throw=="function"&&typeof e.return=="function"&&I(e)}function at(e){var t;return typeof e!="function"?!1:((t=e.constructor)==null?void 0:t.name)==="GeneratorFunction"||/^function\s*\*/.test(e.toString())}function ut(e){var t;return typeof e!="function"?!1:((t=e.constructor)==null?void 0:t.name)==="AsyncFunction"||/^async\s/.test(e.toString())}function ct(e){var t;return typeof e!="function"?!1:((t=e.constructor)==null?void 0:t.name)==="AsyncGeneratorFunction"||/^async\s*function\s*\*/.test(e.toString())}function st(e){try{if(typeof e!="object"&&typeof e!="function"||e===null)return!1;const t={get(){throw new Error("proxy trap")}},r=new Proxy({},t);return Object.prototype.toString.call(e)===Object.prototype.toString.call(r)}catch(t){return!1}}function ft(e){return e instanceof TypeError}function lt(e){return e instanceof RangeError}function yt(e){return e instanceof SyntaxError}function pt(e){return e instanceof ReferenceError}function dt(e){return e instanceof EvalError}function bt(e){return e instanceof URIError}function mt(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function gt(e){return e!==null&&typeof e=="object"&&typeof e.on=="function"&&typeof e.emit=="function"&&typeof e.removeListener=="function"}function ht(e){return typeof Element!="undefined"&&e instanceof Element}function jt(e){return typeof Node!="undefined"&&e instanceof Node}function $t(e){return typeof Window!="undefined"&&e instanceof Window}function wt(e){return typeof Document!="undefined"&&e instanceof Document}function At(e){return typeof globalThis!="undefined"&&e===globalThis||typeof global!="undefined"&&e===global||typeof window!="undefined"&&e===window||typeof self!="undefined"&&e===self}function St(e){return e instanceof Map}function vt(e){return e instanceof Set}function Tt(e){return e instanceof WeakMap}function Ot(e){return e instanceof WeakSet}function Et(e){return e instanceof DataView}function Bt(e){return e instanceof ArrayBuffer}function Mt(e){return typeof SharedArrayBuffer!="undefined"&&e instanceof SharedArrayBuffer}function It(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Pt(e){return e instanceof Int8Array}function kt(e){return e instanceof Uint8Array}function Nt(e){return e instanceof Uint8ClampedArray}function Ft(e){return e instanceof Int16Array}function Ct(e){return e instanceof Uint16Array}function _t(e){return e instanceof Int32Array}function Ut(e){return e instanceof Uint32Array}function Lt(e){return e instanceof Float32Array}function Dt(e){return e instanceof Float64Array}function Rt(e){return typeof BigInt64Array!="undefined"&&e instanceof BigInt64Array}function Gt(e){return typeof BigUint64Array!="undefined"&&e instanceof BigUint64Array}function P(e,t){return u(e)===t}function Wt(e,t){if(u(e)!==t)throw new TypeError(`Expected type "${t}" but got "${u(e)}"`)}function Ht(e,t,r){return P(e,t)?e:r}var zt=Object.defineProperty,Vt=Object.defineProperties,Jt=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable,N=(e,t,r)=>t in e?zt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,F=(e,t)=>{for(var r in t||(t={}))qt.call(t,r)&&N(e,r,t[r]);if(k)for(var r of k(t))Kt.call(t,r)&&N(e,r,t[r]);return e},C=(e,t)=>Vt(e,Jt(t));function _(e,t,r={}){var o,i,a;const c=[],s={path:r.path||"",strict:(o=r.strict)!=null?o:!0,coerce:(i=r.coerce)!=null?i:!1,partial:(a=r.partial)!=null?a:!1};return $(e,t,s,c),{valid:c.length===0,errors:c}}function $(e,t,r,o){if(typeof t=="string"){const i=u(e);i!==t&&o.push({path:r.path||"root",expected:t,actual:i,message:`Expected type "${t}" but got "${i}"`})}else if(Array.isArray(t)){if(!Array.isArray(e)){o.push({path:r.path||"root",expected:"array",actual:u(e),message:`Expected array but got "${u(e)}"`});return}const i=t[0];i&&e.forEach((a,c)=>{$(a,i,C(F({},r),{path:`${r.path}[${c}]`}),o)})}else if(t&&typeof t=="object"){if(typeof e!="object"||e===null){o.push({path:r.path||"root",expected:"object",actual:u(e),message:`Expected object but got "${u(e)}"`});return}const i=e,a=t;if(!r.partial)for(const c of Object.keys(a))c in i||o.push({path:r.path?`${r.path}.${c}`:c,expected:typeof a[c]=="string"?a[c]:u(a[c]),actual:"undefined",message:`Missing required property "${c}"`});for(const c of Object.keys(i))if(c in a){const s=a[c];s!==void 0&&$(i[c],s,C(F({},r),{path:r.path?`${r.path}.${c}`:c}),o)}else r.strict&&o.push({path:r.path?`${r.path}.${c}`:c,expected:"undefined",actual:u(i[c]),message:`Unexpected property "${c}"`})}}function Xt(e,t){return r=>_(r,e,t)}function w(e){switch(u(e)){case"string":return e;case"number":case"boolean":case"bigint":return String(e);case"symbol":return e.toString();case"undefined":return"undefined";case"null":return"null";case"date":return e.toISOString();case"regexp":return e.toString();case"function":return e.toString();case"array":return JSON.stringify(e);case"object":try{return JSON.stringify(e)}catch(t){return Object.prototype.toString.call(e)}default:return String(e)}}function U(e){switch(u(e)){case"number":return e;case"string":{const t=Number(e);return isNaN(t)?null:t}case"boolean":return e?1:0;case"null":return 0;case"bigint":{const t=Number(e);return t>Number.MAX_SAFE_INTEGER||t<Number.MIN_SAFE_INTEGER?null:t}case"date":return e.getTime();default:return null}}function L(e){switch(u(e)){case"boolean":return e;case"string":{const t=e.toLowerCase();return t!==""&&t!=="false"&&t!=="0"&&t!=="no"&&t!=="null"&&t!=="undefined"}case"number":return e!==0&&!isNaN(e);case"null":case"undefined":return!1;case"array":return e.length>0;case"object":return Object.keys(e).length>0;default:return!!e}}function D(e){switch(u(e)){case"bigint":return e;case"number":return Number.isInteger(e)?BigInt(e):null;case"string":try{return BigInt(e)}catch(t){return null}case"boolean":return BigInt(e?1:0);default:return null}}function R(e){switch(u(e)){case"symbol":return e;case"string":return Symbol(e);case"number":return Symbol(String(e));default:return Symbol(w(e))}}function Yt(e){switch(u(e)){case"array":return e;case"string":return Array.from(e);case"set":return Array.from(e);case"map":return Array.from(e);case"arguments":return Array.from(e);case"null":case"undefined":return[];default:return e!==null&&typeof e=="object"&&"length"in e?Array.from(e):[e]}}function Zt(e){switch(u(e)){case"object":return e;case"array":{const t=e,r={};return t.forEach((o,i)=>{r[i]=o}),r}case"map":{const t=e,r={};for(const[o,i]of t)r[String(o)]=i;return r}case"set":{const t=e,r={};let o=0;for(const i of t)r[o++]=i;return r}case"string":{const t=e,r={};for(let o=0;o<t.length;o++)r[o]=t[o];return r}case"null":case"undefined":return{};default:return{value:e}}}function Qt(e){switch(u(e)){case"map":return e;case"object":{const t=e,r=new Map;for(const[o,i]of Object.entries(t))r.set(o,i);return r}case"array":{const t=e,r=new Map;return t.forEach((o,i)=>{r.set(i,o)}),r}case"set":{const t=e,r=new Map;let o=0;for(const i of t)r.set(o++,i);return r}default:return null}}function xt(e){switch(u(e)){case"set":return e;case"array":return new Set(e);case"string":return new Set(Array.from(e));case"map":return new Set(e.values());case"object":return new Set(Object.values(e));default:return e!=null?new Set([e]):new Set}}function er(e){switch(u(e)){case"date":return e;case"string":{const t=new Date(e);return isNaN(t.getTime())?null:t}case"number":{const t=new Date(e);return isNaN(t.getTime())?null:t}default:return null}}function tr(e){switch(u(e)){case"regexp":return e;case"string":try{return new RegExp(e)}catch(t){return null}default:return null}}function rr(e){switch(u(e)){case"error":return e;case"string":return new Error(e);case"object":return e&&typeof e=="object"&&"message"in e?new Error(String(e.message)):new Error(String(e));default:return new Error(String(e))}}function nr(e){switch(u(e)){case"function":case"asyncfunction":case"generatorfunction":case"asyncgeneratorfunction":return e;case"string":try{return new Function("return "+String(e))}catch(t){return null}default:return null}}function or(e){switch(u(e)){case"promise":return e;case"function":try{const t=e();return Promise.resolve(t)}catch(t){return Promise.reject(t)}default:return Promise.resolve(e)}}function ir(e){if(typeof Buffer=="undefined")return null;switch(u(e)){case"buffer":return e;case"string":return Buffer.from(e);case"array":return Buffer.from(e);case"uint8array":return Buffer.from(e);case"arraybuffer":return Buffer.from(e);default:return null}}function ar(e,t){const r=u(e);switch(r){case"arraybuffer":return new t(e);case"array":{const o=e,i=new ArrayBuffer(o.length*4),a=new t(i);for(let c=0;c<o.length;c++)a[c]=o[c];return a}default:return r.includes("array")&&e instanceof ArrayBuffer?new t(e):null}}function ur(e,t){const r=u(e);if(r===t)return e;switch(t){case"string":return w(e);case"number":return U(e);case"boolean":return L(e);case"bigint":return D(e);case"symbol":return R(e);case"undefined":return;case"null":return null;case"array":if(r==="object"&&e!==null){const o=Array.from(e);return o.length>0?o:null}return null;case"object":if(r==="array"){const o={};return e.forEach((i,a)=>{o[a]=i}),o}return null;case"date":if(r==="string"){const o=new Date(e);return isNaN(o.getTime())?null:o}return null;default:return null}}class G{constructor(){this.metrics=new Map,this.enabled=!1}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}startTimer(t){if(!this.enabled)return()=>{};const r=performance.now();return()=>{const o=performance.now()-r;this.recordMetric(t,o)}}recordCacheHit(t){if(!this.enabled)return;const r=this.getOrCreateMetric(t);r.cacheHits++}recordCacheMiss(t){if(!this.enabled)return;const r=this.getOrCreateMetric(t);r.cacheMisses++}recordMetric(t,r){const o=this.getOrCreateMetric(t);o.totalCalls++,o.totalTime+=r,o.averageTime=o.totalTime/o.totalCalls,o.minTime=Math.min(o.minTime,r),o.maxTime=Math.max(o.maxTime,r)}getOrCreateMetric(t){this.metrics.has(t)||this.metrics.set(t,{totalCalls:0,totalTime:0,averageTime:0,minTime:1/0,maxTime:0,cacheHits:0,cacheMisses:0});const r=this.metrics.get(t);if(!r)throw new Error(`Metric '${t}' should exist after creation`);return r}getMetrics(t){return t?this.metrics.get(t)||this.getOrCreateMetric(t):new Map(this.metrics)}reset(t){t?this.metrics.delete(t):this.metrics.clear()}getReport(){const t=["Performance Report:",""];for(const[r,o]of this.metrics){if(t.push(`${r}:`),t.push(` Total calls: ${o.totalCalls}`),t.push(` Total time: ${o.totalTime.toFixed(2)}ms`),t.push(` Average time: ${o.averageTime.toFixed(2)}ms`),t.push(` Min time: ${o.minTime.toFixed(2)}ms`),t.push(` Max time: ${o.maxTime.toFixed(2)}ms`),t.push(` Cache hits: ${o.cacheHits}`),t.push(` Cache misses: ${o.cacheMisses}`),o.cacheHits+o.cacheMisses>0){const i=o.cacheHits/(o.cacheHits+o.cacheMisses)*100;t.push(` Cache hit rate: ${i.toFixed(1)}%`)}t.push("")}return t.join(`
`)}}const cr=new G;var sr=Object.defineProperty,W=Object.getOwnPropertySymbols,fr=Object.prototype.hasOwnProperty,lr=Object.prototype.propertyIsEnumerable,H=(e,t,r)=>t in e?sr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yr=(e,t)=>{for(var r in t||(t={}))fr.call(t,r)&&H(e,r,t[r]);if(W)for(var r of W(t))lr.call(t,r)&&H(e,r,t[r]);return e};function pr(e,t={}){const r=yr({depth:2,colors:!1,showHidden:!1,showProxy:!0,maxArrayLength:100,maxStringLength:200,breakLength:80,compact:!1,sorted:!1,getters:!1},t);return p(e,r,0,new Set)}function p(e,t,r,o){if(r>t.depth)return"[Object]";if(e===null)return"null";if(e===void 0)return"undefined";const i=u(e);if(i==="string")return dr(e,t);if(i==="number"||i==="boolean"||i==="symbol"||i==="bigint")return String(e);if(typeof e=="object"&&e!==null){if(o.has(e))return"[Circular]";o.add(e)}try{switch(i){case"array":return br(e,t,r,o);case"object":return mr(e,t,r,o);case"function":return gr(e,t);case"date":return hr(e,t);case"regexp":return jr(e,t);case"error":return $r(e,t);case"map":return wr(e,t,r,o);case"set":return Ar(e,t,r,o);case"promise":return Sr(e,t);default:return vr(e,i,t)}}finally{typeof e=="object"&&e!==null&&o.delete(e)}}function dr(e,t){return e.length>t.maxStringLength?`'${e.slice(0,t.maxStringLength)}...'`:`'${e}'`}function br(e,t,r,o){if(e.length===0)return"[]";const i=Math.min(e.length,t.maxArrayLength),a=[];for(let s=0;s<i;s++)a.push(p(e[s],t,r+1,o));if(e.length>i&&a.push(`... ${e.length-i} more items`),t.compact)return`[${a.join(", ")}]`;const c=a.join(", ");return c.length<=t.breakLength?`[${c}]`:`[
${a.map(s=>` ${s}`).join(`,
`)}
]`}function mr(e,t,r,o){const i=t.showHidden?Object.getOwnPropertyNames(e):Object.keys(e);if(i.length===0)return"{}";t.sorted&&i.sort();const a=[];for(const s of i)try{const l=e[s],f=p(l,t,r+1,o);a.push(`${s}: ${f}`)}catch(l){a.push(`${s}: [Error: ${l.message}]`)}if(t.compact)return`{${a.join(", ")}}`;const c=a.join(", ");return c.length<=t.breakLength?`{${c}}`:`{
${a.map(s=>` ${s}`).join(`,
`)}
}`}function gr(e,t){const r=e.name||"anonymous",o=g(e);return o.type==="asyncfunction"?`[AsyncFunction: ${r}]`:o.type==="generatorfunction"?`[GeneratorFunction: ${r}]`:o.type==="asyncgeneratorfunction"?`[AsyncGeneratorFunction: ${r}]`:`[Function: ${r}]`}function hr(e,t){return`${e.toISOString()}`}function jr(e,t){return e.toString()}function $r(e,t){return`${e.name}: ${e.message}`}function wr(e,t,r,o){if(e.size===0)return"Map(0) {}";const i=[];let a=0;for(const[c,s]of e){if(a>=t.maxArrayLength){i.push(`... ${e.size-a} more items`);break}const l=p(c,t,r+1,o),f=p(s,t,r+1,o);i.push(`${l} => ${f}`),a++}return`Map(${e.size}) {${i.join(", ")}}`}function Ar(e,t,r,o){if(e.size===0)return"Set(0) {}";const i=[];let a=0;for(const c of e){if(a>=t.maxArrayLength){i.push(`... ${e.size-a} more items`);break}i.push(p(c,t,r+1,o)),a++}return`Set(${e.size}) {${i.join(", ")}}`}function Sr(e,t){return"Promise { <pending> }"}function vr(e,t,r){return e&&typeof e=="object"&&e.constructor?`${e.constructor.name} {}`:`[${t}]`}function Tr(e){const t=g(e),r=[];r.push(`Type: ${t.type}`),t.constructor&&r.push(`Constructor: ${t.constructor}`),t.customType&&r.push(`Custom Type: ${t.customType}`);const o=[];if(t.isPrimitive&&o.push("primitive"),t.isBuiltIn&&o.push("built-in"),t.isNullish&&o.push("nullish"),t.isIterable&&o.push("iterable"),t.isAsync&&o.push("async"),o.length>0&&r.push(`Flags: ${o.join(", ")}`),t.metadata){const i=Object.entries(t.metadata).map(([a,c])=>`${a}: ${c}`).join(", ");r.push(`Metadata: {${i}}`)}return r.join(`
`)}function Or(e){return new Set(["undefined","null","boolean","number","string","symbol","bigint","object","array","function","date","regexp","error","map","set","weakmap","weakset","int8array","uint8array","uint8clampedarray","int16array","uint16array","int32array","uint32array","float32array","float64array","bigint64array","biguint64array","promise","generatorfunction","asyncfunction","asyncgeneratorfunction","proxy","dataview","arraybuffer","sharedarraybuffer","arguments","buffer","stream","eventemitter","element","node","window","document","global"]).has(e)}function Er(e){return["undefined","null","boolean","number","string","symbol","bigint"].includes(e)?"primitive":["object","array","function","date","regexp","error"].includes(e)?"object":["map","set","weakmap","weakset"].includes(e)?"collection":e.includes("array")&&e!=="array"?"typedarray":["promise","generatorfunction","asyncfunction","asyncgeneratorfunction"].includes(e)?"modern":["buffer","stream","eventemitter"].includes(e)?"node":["element","node","window","document"].includes(e)?"dom":"special"}function Br(e,t){return u(e)===u(t)}function Mr(e,t){const r=u(e);return t.includes(r)}function Ir(e,t){return e.every(r=>u(r)===t)}function z(e){const t=new Map;for(const r of e){const o=u(r);t.has(o)||t.set(o,[]);const i=t.get(o);i&&i.push(r)}return t}function A(e){const t={};for(const r of e){const o=u(r);t[o]=(t[o]||0)+1}return t}function Pr(e,t){return e.filter(r=>u(r)===t)}function kr(e,t){return e.find(r=>u(r)===t)}function Nr(e,t){return e.some(r=>u(r)===t)}function Fr(e,t){return e.every(r=>u(r)===t)}function Cr(e,t){return!e.some(r=>u(r)===t)}function _r(e,t){return e.filter(r=>u(r)===t).length}function Ur(e){const t=new Set;for(const r of e)t.add(u(r));return Array.from(t)}function Lr(e){return z(e)}function Dr(e){if(e.length===0)return null;const t=A(e);let r=0,o=null;for(const[i,a]of Object.entries(t))a>r&&(r=a,o=i);return o}function Rr(e){if(e.length===0)return null;const t=A(e);let r=1/0,o=null;for(const[i,a]of Object.entries(t))a<r&&(r=a,o=i);return o}function V(e){if(e.length===0)return!0;const t=u(e[0]);return e.every(r=>u(r)===t)}function Gr(e){return!V(e)}function J(e,t){const r=[],o=[];for(const i of e)t(i)?r.push(i):o.push(i);return[r,o]}function Wr(e,t){return J(e,r=>u(r)===t)}let Hr=class K{constructor(){this.plugins=new Map,this.customTypes=new Map,this.typeOrder=[];const t=this.detect.bind(this);return Object.setPrototypeOf(t,K.prototype),Object.assign(t,this),t}detect(t){for(let r=this.typeOrder.length-1;r>=0;r--){const o=this.typeOrder[r];if(!o)continue;const i=this.customTypes.get(o);if(i&&i(t))return o}return u(t)}use(t,r={}){if(this.plugins.has(t.name))throw new Error(`Plugin "${t.name}" is already registered`);this.plugins.set(t.name,t);const o=r.prefix||"";for(const[i,a]of Object.entries(t.types)){const c=o+i;if(this.customTypes.has(c)&&!r.override)throw new Error(`Type "${c}" is already defined`);this.customTypes.set(c,a),this.typeOrder.push(c)}return t.setup&&t.setup(this),this}unuse(t){const r=this.plugins.get(t);if(!r)throw new Error(`Plugin "${t}" is not registered`);r.teardown&&r.teardown();for(const o of Object.keys(r.types)){this.customTypes.delete(o);const i=this.typeOrder.indexOf(o);i!==-1&&this.typeOrder.splice(i,1)}return this.plugins.delete(t),this}defineType(t,r){if(this.customTypes.has(t))throw new Error(`Type "${t}" is already defined`);return this.customTypes.set(t,r),this.typeOrder.push(t),this}removeType(t){if(!this.customTypes.has(t))throw new Error(`Type "${t}" is not defined`);this.customTypes.delete(t);const r=this.typeOrder.indexOf(t);return r!==-1&&this.typeOrder.splice(r,1),this}getCustomTypes(){return Object.fromEntries(this.customTypes)}hasType(t){return this.customTypes.has(t)}};function zr(){return new Hr}function S(e){const t={name:e.name,version:e.version,types:e.types};return e.setup&&(t.setup=e.setup),e.teardown&&(t.teardown=e.teardown),t}const Vr=S({name:"react",version:"1.0.0",types:{"react.element":e=>e!==null&&typeof e=="object"&&"$$typeof"in e&&"type"in e&&"props"in e,"react.component":e=>{if(typeof e!="function")return!1;const t=e,r=t.prototype;return!!(r&&r.isReactComponent||t.name&&/^[A-Z]/.test(t.name))},"react.memo":e=>{var t,r;return e!==null&&typeof e=="object"&&"$$typeof"in e&&"type"in e&&((r=(t=e.$$typeof)==null?void 0:t.toString)==null?void 0:r.call(t))==="Symbol(react.memo)"},"react.forwardref":e=>{var t,r;return e!==null&&typeof e=="object"&&"$$typeof"in e&&"render"in e&&((r=(t=e.$$typeof)==null?void 0:t.toString)==null?void 0:r.call(t))==="Symbol(react.forward_ref)"},"react.lazy":e=>{var t,r;return e!==null&&typeof e=="object"&&"$$typeof"in e&&"_payload"in e&&"_init"in e&&((r=(t=e.$$typeof)==null?void 0:t.toString)==null?void 0:r.call(t))==="Symbol(react.lazy)"},"react.context":e=>e!==null&&typeof e=="object"&&"$$typeof"in e&&"_currentValue"in e&&"Provider"in e&&"Consumer"in e,"react.provider":e=>{var t,r;return e!==null&&typeof e=="object"&&"$$typeof"in e&&"_context"in e&&((r=(t=e.$$typeof)==null?void 0:t.toString)==null?void 0:r.call(t))==="Symbol(react.provider)"},"react.consumer":e=>{var t,r;return e!==null&&typeof e=="object"&&"$$typeof"in e&&"_context"in e&&((r=(t=e.$$typeof)==null?void 0:t.toString)==null?void 0:r.call(t))==="Symbol(react.consumer)"},"react.fragment":e=>{var t,r;return e!==null&&typeof e=="object"&&"$$typeof"in e&&"type"in e&&((r=(t=e.type)==null?void 0:t.toString)==null?void 0:r.call(t))==="Symbol(react.fragment)"},"react.portal":e=>{var t,r;return e!==null&&typeof e=="object"&&"$$typeof"in e&&"children"in e&&"containerInfo"in e&&((r=(t=e.$$typeof)==null?void 0:t.toString)==null?void 0:r.call(t))==="Symbol(react.portal)"},"react.suspense":e=>{var t,r;return e!==null&&typeof e=="object"&&"$$typeof"in e&&"type"in e&&((r=(t=e.type)==null?void 0:t.toString)==null?void 0:r.call(t))==="Symbol(react.suspense)"},"react.profiler":e=>{var t,r;return e!==null&&typeof e=="object"&&"$$typeof"in e&&"type"in e&&((r=(t=e.type)==null?void 0:t.toString)==null?void 0:r.call(t))==="Symbol(react.profiler)"},"react.strictmode":e=>{var t,r;return e!==null&&typeof e=="object"&&"$$typeof"in e&&"type"in e&&((r=(t=e.type)==null?void 0:t.toString)==null?void 0:r.call(t))==="Symbol(react.strict_mode)"}}}),v=e=>e!==null&&typeof e=="object"&&"readable"in e&&"read"in e&&typeof e.read=="function"&&"_readableState"in e,T=e=>e!==null&&typeof e=="object"&&"writable"in e&&"write"in e&&typeof e.write=="function"&&"_writableState"in e,q=e=>v(e)&&T(e),Jr=S({name:"node",version:"1.0.0",types:{"node.readablestream":v,"node.writablestream":T,"node.duplexstream":q,"node.transformstream":e=>q(e)&&e!==null&&typeof e=="object"&&"_transform"in e&&typeof e._transform=="function","node.server":e=>e!==null&&typeof e=="object"&&"listen"in e&&"close"in e&&"address"in e&&typeof e.listen=="function","node.incomingmessage":e=>e!==null&&typeof e=="object"&&"headers"in e&&"method"in e&&"url"in e&&v(e),"node.serverresponse":e=>e!==null&&typeof e=="object"&&"statusCode"in e&&"setHeader"in e&&"writeHead"in e&&T(e),"node.childprocess":e=>e!==null&&typeof e=="object"&&"pid"in e&&"kill"in e&&"stdin"in e&&"stdout"in e&&"stderr"in e&&typeof e.kill=="function","node.worker":e=>e!==null&&typeof e=="object"&&"threadId"in e&&"postMessage"in e&&"terminate"in e&&typeof e.postMessage=="function","node.messageport":e=>e!==null&&typeof e=="object"&&"postMessage"in e&&"start"in e&&"close"in e&&typeof e.postMessage=="function","node.url":e=>{var t;return e!==null&&typeof e=="object"&&"href"in e&&"protocol"in e&&"hostname"in e&&"pathname"in e&&"search"in e&&"hash"in e&&((t=e.constructor)==null?void 0:t.name)==="URL"},"node.urlsearchparams":e=>{var t;return e!==null&&typeof e=="object"&&"append"in e&&"get"in e&&"set"in e&&"delete"in e&&typeof e.append=="function"&&((t=e.constructor)==null?void 0:t.name)==="URLSearchParams"},"node.textencoder":e=>{var t;return e!==null&&typeof e=="object"&&"encode"in e&&typeof e.encode=="function"&&((t=e.constructor)==null?void 0:t.name)==="TextEncoder"},"node.textdecoder":e=>{var t;return e!==null&&typeof e=="object"&&"decode"in e&&typeof e.decode=="function"&&((t=e.constructor)==null?void 0:t.name)==="TextDecoder"},"node.abortcontroller":e=>{var t;return e!==null&&typeof e=="object"&&"signal"in e&&"abort"in e&&typeof e.abort=="function"&&((t=e.constructor)==null?void 0:t.name)==="AbortController"},"node.abortsignal":e=>{var t;return e!==null&&typeof e=="object"&&"aborted"in e&&typeof e.aborted=="boolean"&&((t=e.constructor)==null?void 0:t.name)==="AbortSignal"},"node.performanceobserver":e=>{var t;return e!==null&&typeof e=="object"&&"observe"in e&&"disconnect"in e&&typeof e.observe=="function"&&((t=e.constructor)==null?void 0:t.name)==="PerformanceObserver"},"node.performanceentry":e=>{var t,r;return e!==null&&typeof e=="object"&&"name"in e&&"entryType"in e&&"startTime"in e&&"duration"in e&&((r=(t=e.constructor)==null?void 0:t.name)==null?void 0:r.includes("Performance"))}}});function m(e){return u(e)}const qr=m,Kr=m;n.PerformanceMonitor=G,n.assertType=Wt,n.clearCache=Ae,n.coerceType=ur,n.compareTypes=Br,n.countByType=_r,n.createKindOfInstance=zr,n.createPlugin=S,n.createTypeMap=Lr,n.createValidator=Xt,n.default=m,n.disableCache=we,n.enableCache=$e,n.ensureType=Ht,n.everyOfType=Fr,n.fastKindOf=be,n.filterByType=Pr,n.findByType=kr,n.getDetailedType=g,n.getLeastCommonType=Rr,n.getMostCommonType=Dr,n.getType=Kr,n.getTypeCategory=Er,n.getTypeStats=A,n.getUniqueTypes=Ur,n.groupByType=z,n.hasLength=M,n.hasSize=Qe,n.inspect=pr,n.inspectType=Tr,n.isArguments=qe,n.isArray=Ge,n.isArrayBuffer=Bt,n.isArrayLike=xe,n.isAsyncFunction=ut,n.isAsyncGenerator=it,n.isAsyncGeneratorFunction=ct,n.isAsyncIterable=I,n.isBigInt=Me,n.isBigInt64Array=Rt,n.isBigUint64Array=Gt,n.isBoolean=Te,n.isBuffer=Ke,n.isConstructor=tt,n.isDataView=Et,n.isDate=He,n.isDocument=wt,n.isElement=ht,n.isEmpty=Xe,n.isEmptyArray=Ye,n.isEmptyObject=Ze,n.isEmptyString=Le,n.isError=Ve,n.isEvalError=dt,n.isEventEmitter=gt,n.isFalsy=ke,n.isFinite=_e,n.isFloat32Array=Lt,n.isFloat64Array=Dt,n.isFunction=We,n.isGenerator=ot,n.isGeneratorFunction=at,n.isGlobal=At,n.isHeterogeneous=Gr,n.isHomogeneous=V,n.isInfinity=Ue,n.isInt16Array=Ft,n.isInt32Array=_t,n.isInt8Array=Pt,n.isInteger=Fe,n.isIterable=et,n.isJsonString=Re,n.isMap=St,n.isNaN=h,n.isNode=jt,n.isNull=ve,n.isNullish=Pe,n.isNumber=Oe,n.isNumericString=De,n.isObject=B,n.isObservable=nt,n.isPlainObject=j,n.isPrimitive=Ie,n.isPromise=Je,n.isProxy=st,n.isRangeError=lt,n.isReferenceError=pt,n.isRegExp=ze,n.isSafeInteger=Ce,n.isSet=vt,n.isSharedArrayBuffer=Mt,n.isStream=mt,n.isString=Ee,n.isSymbol=Be,n.isSyntaxError=yt,n.isThenable=rt,n.isTruthy=Ne,n.isType=P,n.isTypeError=ft,n.isTypeOfAll=Ir,n.isTypeOfAny=Mr,n.isTypedArray=It,n.isURIError=bt,n.isUint16Array=Ct,n.isUint32Array=Ut,n.isUint8Array=kt,n.isUint8ClampedArray=Nt,n.isUndefined=Se,n.isValidType=Or,n.isWeakMap=Tt,n.isWeakSet=Ot,n.isWindow=$t,n.kindOf=m,n.kindOfMany=me,n.nodePlugin=Jr,n.noneOfType=Cr,n.partition=J,n.partitionByType=Wr,n.performanceMonitor=cr,n.reactPlugin=Vr,n.someOfType=Nr,n.toArray=Yt,n.toBigInt=D,n.toBoolean=L,n.toBuffer=ir,n.toDate=er,n.toError=rr,n.toFunction=nr,n.toMap=Qt,n.toNumber=U,n.toObject=Zt,n.toPromise=or,n.toRegExp=tr,n.toSet=xt,n.toString=w,n.toSymbol=R,n.toTypedArray=ar,n.typeOf=qr,n.validateSchema=_,Object.defineProperty(n,"__esModule",{value:!0})});
//# sourceMappingURL=kindof.umd.min.js.map