UNPKG

@livelybone/copy

Version:

About clipboard copy, Object simple&deep copy

10 lines (8 loc) 3.98 kB
/** * Bundle of @livelybone/copy * Generated: 2023-07-25 * Version: 2.6.6 * License: MIT * Author: 2631541504@qq.com */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).objectDeepMerge=t()}(this,function(){"use strict";function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,u,c=[],a=!0,f=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);a=!0);}catch(e){f=!0,o=e}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(f)throw o}}return c}}(e,t)||r(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||r(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){var r;if(e)return"string"==typeof e?n(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var i=function(e){return e.NormalObj="object",e.Array="Array",e}({});function u(t){var e=["undefined"!=typeof Promise&&Promise,"undefined"!=typeof Date&&Date,"undefined"!=typeof Error&&Error,"undefined"!=typeof RegExp&&RegExp,"undefined"!=typeof FileList&&FileList,"undefined"!=typeof File&&File,"undefined"!=typeof Element&&Element,"undefined"!=typeof Window&&Window,"undefined"!=typeof Document&&Document];return"object"===o(t)&&null!==t&&!e.some(function(e){return e&&t instanceof e})&&(t instanceof Array?i.Array:i.NormalObj)}function c(e){var a=["",""];return function i(e){var u,c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:["Object"],t=2<arguments.length?arguments[2]:void 0;return"object"===o(e)&&null!==e&&(u=t?[].concat(l(t),[e]):[e],Object.entries(e).some(function(e){var t,r,e=f(e,2),n=e[0],e=e[1],n=[].concat(l(c),[n]),o=(t=e,r=u,void 0!==(o=Object.keys(r).find(function(e){return r[+e]===t}))?{index:+o}:void 0);return o?(a[0]=n.slice(0,o.index+1).reduce(function(e,t){return"".concat(e,".").concat(t)},"").replace(/^\./,""),a[1]=n.reduce(function(e,t){return"".concat(e,".").concat(t)},"").replace(/^\./,""),!0):i(e,n,u)}))}(e)?a:null}function a(n){for(var e=arguments.length,t=new Array(1<e?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return t.forEach(function(e){Object.entries(e).forEach(function(e){var e=f(e,2),t=e[0],e=e[1];if("__proto__"===t||"constructor"===t||"prototype"===t)return n;var r=n[t];u(e)&&u(r)?a(r,e):n[t]="object"===o(e)?JSON.parse(JSON.stringify(e)):e})}),n}return function(e){for(var n="same",t=arguments.length,r=new Array(1<t?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];return[e].concat(r).forEach(function(e,t){var r=c(e);if(r)throw r=JSON.stringify(r),new Error("objectDeepMerge: Circular structure is not supported, the ".concat(t,"th parameter is a circular structure with CircularStructurePaths(").concat(r,")"));t=u(e);if(!t||"same"!==n&&n!==t)throw new Error("objectDeepMerge: Please ensure that parameters are all Array or normal Object");n=t}),a.apply(void 0,[e].concat(r))}});