UNPKG

funtool

Version:

A modern, efficient, and modular JavaScript utility library designed to enhance developer productivity.

3 lines (2 loc) 3.58 kB
"use strict";function t(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)}function e(t){return"function"==typeof t||"object"==typeof t&&null!==t}function n(t){return"[object Map]"===Object.prototype.toString.call(t)&&t instanceof Map}function r(t){return"[object Set]"===Object.prototype.toString.call(t)&&t instanceof Set}function o(t){return"function"==typeof t}function c(t){return"object"!=typeof t&&"function"!=typeof t||null==t}function i(i,u){if(c(i))return i;if(t(i))return i.map(((t,e)=>{if(o(u)){return u(t,e)}return t}));if(f=i,"[object Date]"===Object.prototype.toString.call(f))return new Date(i.getTime());var f;if(function(t){return"[object RegExp]"===Object.prototype.toString.call(t)}(i))return new RegExp(i.source,i.flags);if(n(i))return new Map(i);if(r(i))return new Set(i);if(function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}(i))return i.slice();if(function(t){return t instanceof DataView&&"[object DataView]"===Object.prototype.toString.call(t)}(i))return new DataView(i.buffer.slice(0));if(e(i)){const t=Object.getPrototypeOf(i),e=Object.create(t);for(const t in i)if(Object.prototype.hasOwnProperty.call(i,t)){const n=i[t],r=u?.(n,t);e[t]=void 0!==r?r:n}return e}return i}const u={Date:t=>new Date(t.getTime()),RegExp:t=>new RegExp(t.source,t.flags),Array:(t,e,n)=>{const r=[];return e.set(t,r),t.forEach(((t,o)=>{r[o]=n(t,e)})),r},Map:(t,e,n)=>{const r=new Map;return e.set(t,r),t.forEach(((t,o)=>{r.set(o,n(t,e))})),r},Set:(t,e,n)=>{const r=new Set;return e.set(t,r),t.forEach((t=>{r.add(n(t,e))})),r}};function f(t,e,n,r){if(i=t,"[object Null]"===Object.prototype.toString.call(i)||!function(t){return null!=t&&"object"==typeof t}(t))return t;var i;if(o(t)||function(t){return"symbol"==typeof t}(t)||function(t){return"[object BigInt]"===Object.prototype.toString.call(t)}(t)||function(t){return"[object WeakMap]"===Object.prototype.toString.call(t)&&t instanceof WeakMap}(t)||function(t){return"[object WeakSet]"===Object.prototype.toString.call(t)&&t instanceof WeakSet}(t)){const e="object"==typeof t&&null!==t&&"constructor"in t&&t.constructor?.name||typeof t;return console.warn(`⚠️ Warning: Unsupported type "${e}" encountered, returning original.`),t}if(e.has(t))return e.get(t);const f=Object.prototype.toString.call(t).slice(8,-1);if(f in u)return u[f](t,e,n);const a={};return e.set(t,a),function(t,e){return c(t)?[]:("undefined"!=typeof Reflect&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys(t):[...Object.getOwnPropertyNames?Object.getOwnPropertyNames(t):[],...Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]]).filter((n=>{const r=Object.getOwnPropertyDescriptor(t,n);return!!r&&(o(e)?e(n,r):r.enumerable)}))}(t).forEach((o=>{if(function(t,e){return!c(t)&&Object.prototype.hasOwnProperty.call(t,e)}(t,o)){const c=t[o],i=r?.(c,o,t);a[o]=void 0!==i?i:n(c,e)}})),a}exports.clone=function(t){return i(t)},exports.cloneDeep=function t(e,n=new WeakMap){return f(e,n,t)},exports.cloneDeepWith=function(t,e,n=new WeakMap){const r=(t,o=n)=>{const c=e(t);return void 0!==c?c:f(t,o,r,e)};return r(t)},exports.cloneWith=function(t,e){return i(t,e)},exports.includes=function(o,c,i=0){return t(o)?o.slice(i).includes(c):(u=o,"[object String]"===Object.prototype.toString.call(u)?-1!==o.indexOf(String(c),i):n(o)||r(o)?o.has(c):!!function(t){if(!e(t))return!1;const n=Object.getPrototypeOf(t);return null===n||n===Object.prototype||null===Object.getPrototypeOf(n)}(o)&&Object.values(o).includes(c));var u}; //# sourceMappingURL=index.cjs.js.map