@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.26 kB
JavaScript
;var A=require('./isPrimitive'),O=require('./date/isDateObj'),d=require('./isRegex'),dom=require('./dom');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var A__default=/*#__PURE__*/_interopDefault(A);var O__default=/*#__PURE__*/_interopDefault(O);var d__default=/*#__PURE__*/_interopDefault(d);function a(n){if(n===null||typeof n!="object"||dom.isDOMElement(n)||O__default.default(n)||d__default.default(n)||A__default.default(n))return false;const e=Object.getPrototypeOf(n);if(e===null)return true;const t=e.constructor;if(typeof t!="function")return false;if(t===Object)return true;const r=t.prototype;return typeof r!="object"?false:r===Object.prototype?true:typeof e.hasOwnProperty=="function"&&e.hasOwnProperty("isPrototypeOf")&&typeof e.isPrototypeOf=="function"}function T(n){if(Array.isArray(n)){const r=[];for(var e=0;e<n.length;e++)r[e]=T(n[e]);return r}else if(a(n)&&n){const r={};for(var t in n)n.hasOwnProperty(t)&&(r[t]=T(n[t]));return r}else return n}const I=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 M(...n){if(n.length===1)return a(n[0])?n[0]:{};let e=null;for(var t in n){const r=n[t];if(a(r)){if(Object.getSize(r,true)>0)return r;e||(e=r);}}return e||{}}function m(n,...e){const t=Array.isArray(n),r=a(n);(n==null||!t&&!r)&&(n={});for(let i=0;i<e.length;i++){const o=e[i];if(o==null)continue;const y=a(o),f=Array.isArray(o);if(!(!y&&!f)){if(t){f&&h(n,o);continue}else if(f)continue;for(let c in o){const s=o[c];if(s==null)continue;if(s===o){n[c]=n;continue}const u=n[c],k=Array.isArray(u),p=Array.isArray(s);if(k){p?h(n[c],s):n[c]=s;continue}else if(!a(u)){n[c]=s;continue}if(p||!a(s)){n[c]=s;continue}n[c]=m({},u,s);}}}return n}const h=(n,e)=>{const t=e.length;let r=0;for(let i=0;i<n.length;i++){const o=n[i],y=e[i];if(i<t){const f=Array.isArray(o),c=Array.isArray(y),s=a(o),u=a(y);f&&c||s&&u?(n[r]=m(f?[]:{},o,y),r++):y!=null?(n[r]=y,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 K(n){return l(n)}function l(n,e="",t={}){if(t=a(t)?t:{},A__default.default(n)||O__default.default(n)||d__default.default(n))return e&&(t[e]=n),t;if(typeof n=="function"||typeof n=="object"&&!a(n)&&!b(n))return t;if(n instanceof Map||n instanceof WeakMap)return Array.from(n.entries()).forEach(([r,i])=>{const o=e?`${e}[${String(r)}]`:String(r);l(i,o,t);}),t;if(Array.isArray(n)||n instanceof Set||n instanceof WeakSet)return (Array.isArray(n)?n:Array.from(n)).forEach((i,o)=>{const y=e?`${e}[${o}]`:String(o);l(i,y,t);}),t;if(a(n))for(const r in n){if(!Object.prototype.hasOwnProperty.call(n,r))continue;const i=n[r],o=e?e.endsWith("]")?`${e}.${r}`:`${e}.${r}`:r;l(i,o,t);}return t}function b(n){return Array.isArray(n)||n instanceof Set||n instanceof Map||n instanceof WeakMap||n instanceof WeakSet}function P(n){return Object.entries(n)}Object.typedEntries=P,Object.flatten=K,Object.clone=T;exports.cloneObject=T;exports.defaultObj=M;exports.extendObj=m;exports.flattenObject=K;exports.isIterableStructure=b;exports.isObj=a;exports.objectSize=I;exports.typedEntries=P;