@resk/core
Version:
An innovative TypeScript framework that empowers developers to build applications with a fully decorator-based architecture for efficient resource management. By combining the power of decorators with a resource-oriented design, DecorRes enhances code cla
1 lines • 3.57 kB
JavaScript
;function p(n){return !n||typeof n!="object"?false:n instanceof Date?true:typeof n.getTime!="function"?false:!(Object.prototype.toString.call(n)!=="[object Date]"||isNaN(n.getTime()))}function T(n){return typeof window!="object"||!window||typeof document=="undefined"||typeof HTMLElement=="undefined"?false:n===document?true:"HTMLElement"in window?!!n&&n instanceof HTMLElement:!!n&&typeof n=="object"&&n.nodeType===1&&!!n.nodeName}function d(n){return n==null||typeof n=="string"||typeof n=="number"||typeof n=="boolean"}function m(n){if(n instanceof RegExp)return true;if(!n||typeof n!="object"||!Object.prototype.toString.call(n).includes("RegExp"))return false;try{return new RegExp(n),!0}catch(e){return false}}function f(n){if(n===null||typeof n!="object"||T(n)||p(n)||m(n)||d(n))return false;let e=Object.getPrototypeOf(n);if(e===null)return true;let t=e.constructor;if(typeof t!="function")return false;if(t===Object)return true;let r=t.prototype;return typeof r!="object"?false:r===Object.prototype?true:typeof e.hasOwnProperty=="function"&&e.hasOwnProperty("isPrototypeOf")&&typeof e.isPrototypeOf=="function"}function A(n){if(Array.isArray(n)){let r=[];for(var e=0;e<n.length;e++)r[e]=A(n[e]);return r}else if(f(n)&&n){let r={};for(var t in n)n.hasOwnProperty(t)&&(r[t]=A(n[t]));return r}else return n}var v=Object.getSize=function(n,e=false){if(!n||typeof n!="object")return 0;if(Array.isArray(n))return n.length;typeof e!="boolean"&&(e=false);let t=0;for(let r in n)if(n.hasOwnProperty(r)&&(t++,e===true))return t;return t};function $(...n){if(n.length===1)return f(n[0])?n[0]:{};let e=null;for(var t in n){let r=n[t];if(f(r)){if(Object.getSize(r,true)>0)return r;e||(e=r);}}return e||{}}function x(n,...e){let t=Array.isArray(n),r=f(n);(n==null||!t&&!r)&&(n={});for(let i=0;i<e.length;i++){let o=e[i];if(o==null)continue;let a=f(o),y=Array.isArray(o);if(!(!a&&!y)){if(t){y&&h(n,o);continue}else if(y)continue;for(let c in o){let s=o[c];if(s==null)continue;if(s===o){n[c]=n;continue}let u=n[c],g=Array.isArray(u),O=Array.isArray(s);if(g){O?h(n[c],s):n[c]=s;continue}else if(!f(u)){n[c]=s;continue}if(O||!f(s)){n[c]=s;continue}n[c]=x({},u,s);}}}return n}var h=(n,e)=>{let t=e.length,r=0;for(let i=0;i<n.length;i++){let o=n[i],a=e[i];if(i<t){let y=Array.isArray(o),c=Array.isArray(a),s=f(o),u=f(a);y&&c||s&&u?(n[r]=x(y?[]:{},o,a),r++):a!=null?(n[r]=a,r++):o!=null&&(n[r]=o,r++);}}for(let i=n.length;i<t;i++)e[i]!==void 0&&e[i]!==null&&n.push(e[i]);return n};function b(n,e){return l(n,"",{},e)}function l(n,e="",t={},r){if(t=f(t)?t:{},d(n)||p(n)||m(n)||Array.isArray(n)&&(r!=null&&r.skipArrays))return e&&(t[e]=n),t;if(typeof n=="function"||typeof n=="object"&&!f(n)&&!S(n))return t;if(n instanceof Map||n instanceof WeakMap)return Array.from(n.entries()).forEach(([i,o])=>{let a=e?`${e}[${String(i)}]`:String(i);l(o,a,t,r);}),t;if(Array.isArray(n)||n instanceof Set||n instanceof WeakSet)return (Array.isArray(n)?n:Array.from(n)).forEach((o,a)=>{let y=e?`${e}[${a}]`:String(a);l(o,y,t,r);}),t;if(f(n))for(let i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;let o=n[i],a=e?e.endsWith("]")?`${e}.${i}`:`${e}.${i}`:i;l(o,a,t,r);}return t}function S(n){return Array.isArray(n)||n instanceof Set||n instanceof Map||n instanceof WeakMap||n instanceof WeakSet}function w(n){return Object.entries(n)}Object.typedEntries=w;Object.flatten=b;Object.clone=A;exports.cloneObject=A;exports.defaultObj=$;exports.extendObj=x;exports.flattenObject=b;exports.isIterableStructure=S;exports.isObj=f;exports.objectSize=v;exports.typedEntries=w;