Comparing version 0.1.6 to 0.2.0
@@ -1,1 +0,1 @@ | ||
module.exports=function(e){var r={};function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)t.d(o,n,function(r){return e[r]}.bind(null,n));return o},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){"use strict";function o(e={},{setPrototype:r=!1,invokeConstructors:t=!0,copyNonEnumerables:o=!1,copySymbols:n=!1,copyGettersSetters:i=!1,allowCircularReferences:c=!1}={}){if(!e||"object"!=typeof e)throw new TypeError("TypeError: invalid 'obj' argument's type");if(e instanceof Error)throw new TypeError("TypeError: cannot copy Error objects");const s={setPrototype:r,invokeConstructors:t,copyNonEnumerables:o,copySymbols:n,copyGettersSetters:i,allowCircularReferences:c};if("boolean"!=typeof r)throw new TypeError("TypeError: invalid 'setPrototype' flag's type");if("boolean"!=typeof t)throw new TypeError("TypeError: invalid 'invokeConstructors' flag's type");if("boolean"!=typeof o)throw new TypeError("TypeError: invalid 'copyNonEnumerables' flag's type");if("boolean"!=typeof n)throw new TypeError("TypeError: invalid 'copySymbols' flag's type");if("boolean"!=typeof i)throw new TypeError("TypeError: invalid 'copyGettersSetters' flag's type");if("boolean"!=typeof c)throw new TypeError("TypeError: invalid 'allowCircularReferences' flag's type");return function e(r,{setPrototype:t,invokeConstructors:o,copyNonEnumerables:n,copySymbols:i,copyGettersSetters:c,allowCircularReferences:s},a,f){a.set(r,r);let l=null;const p=Object.getOwnPropertyDescriptors(r);l=o?new r.constructor:t?Object.create(Object.getPrototypeOf(r)):{};const u=new WeakMap;if(Object.entries(p).forEach(([r,p])=>{const{value:y,enumerable:b}=p;if((n||b)&&(i||"symbol"!=typeof y)&&(c||!p.get&&!p.set))if(y&&"object"==typeof y){if(a.has(y)){if(s)return void(l[r]=a.get(y));throw new TypeError("TypeError: circular reference found")}if(u.has(y))return void(l[r]=u.get(y));if(y instanceof Error)throw new TypeError("TypeError: cannot copy Error objects");if(y instanceof String||y instanceof Number||y instanceof Boolean){const e=p.value.valueOf();return void Object.defineProperty(l,r,{...p,...{value:e}})}if(y instanceof Date){const e=new Date(p.value.getTime());return void Object.defineProperty(l,r,{...p,...{value:e}})}if(y instanceof RegExp){const{value:{lastIndex:e}}=p,t=new RegExp(p.value.source,p.value.flags);return Object.defineProperty(l,r,{...p,...{value:t}}),void(l[r].lastIndex=e)}if(y instanceof Promise)return void Object.defineProperty(l,r,p);l[r]=e(y,{setPrototype:t,invokeConstructors:o,copyNonEnumerables:n,copySymbols:i,copyGettersSetters:c,allowCircularReferences:s},a,f),u.set(y,l[r])}else Object.defineProperty(l,r,p)}),s&&(a.set(r,l),f===r)){const e=new WeakMap;e.set(l),function r(t,o){Object.entries(t).forEach(([n,i])=>{if(i&&"object"==typeof i)if(o.has(i))t[n]=o.get(i);else{if(e.has(i))return;e.set(i),r(i,o)}})}(l,a)}return l}(e,s,new WeakMap,e)}t.r(r),t.d(r,"default",function(){return o})}]).default; | ||
module.exports=function(e){var r={};function o(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=r,o.d=function(e,r,t){o.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,r){if(1&r&&(e=o(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(o.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)o.d(t,n,function(r){return e[r]}.bind(null,n));return t},o.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(r,"a",r),r},o.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},o.p="",o(o.s=0)}([function(e,r){e.exports=function(e={},{setPrototype:r=!1,invokeConstructors:o=!0,copyNonEnumerables:t=!1,copySymbols:n=!1,copyGettersSetters:s=!1,allowCircularReferences:i=!1}={}){if(!e||"object"!=typeof e)throw new TypeError("TypeError: invalid 'obj' argument's type");if(e instanceof Number||e instanceof String||e instanceof Boolean)throw new TypeError("TypeError: wrapper objects are not allowed as source");if(e instanceof Promise)throw new TypeError("TypeError: Promises are not allowed as source");if(e instanceof Error)throw new TypeError("TypeError: cannot copy Error objects");if(e instanceof RegExp){const{source:r,flags:o,lastIndex:t}=e,n=new RegExp(r,o);return n.lastIndex=t,n}if(e instanceof Date)return new Date(e.getTime());const a={setPrototype:r,invokeConstructors:o,copyNonEnumerables:t,copySymbols:n,copyGettersSetters:s,allowCircularReferences:i};if("boolean"!=typeof r)throw new TypeError("TypeError: invalid 'setPrototype' flag's type");if("boolean"!=typeof o)throw new TypeError("TypeError: invalid 'invokeConstructors' flag's type");if("boolean"!=typeof t)throw new TypeError("TypeError: invalid 'copyNonEnumerables' flag's type");if("boolean"!=typeof n)throw new TypeError("TypeError: invalid 'copySymbols' flag's type");if("boolean"!=typeof s)throw new TypeError("TypeError: invalid 'copyGettersSetters' flag's type");if("boolean"!=typeof i)throw new TypeError("TypeError: invalid 'allowCircularReferences' flag's type");return function e(r,{setPrototype:o,invokeConstructors:t,copyNonEnumerables:n,copySymbols:s,copyGettersSetters:i,allowCircularReferences:a},c,f){c.set(r,r);let l=null;const p=Object.getOwnPropertyDescriptors(r);l=t?new r.constructor:o?Object.create(Object.getPrototypeOf(r)):{};const u=new WeakMap;if(Object.entries(p).forEach(([r,p])=>{const{value:y,enumerable:b}=p;if((n||b)&&(s||"symbol"!=typeof y)&&(i||!p.get&&!p.set))if(y&&"object"==typeof y){if(c.has(y)){if(a)return void(l[r]=c.get(y));throw new TypeError("TypeError: circular reference found")}if(u.has(y))return void(l[r]=u.get(y));if(y instanceof Error)throw new TypeError("TypeError: cannot copy Error objects");if(y instanceof Number||y instanceof Boolean){const e=p.value.valueOf();return void Object.defineProperty(l,r,{...p,...{value:e}})}if(y instanceof String){const e=p.value.toString();return void Object.defineProperty(l,r,{...p,...{value:e}})}if(y instanceof Date){const e=new Date(p.value.getTime());return void Object.defineProperty(l,r,{...p,...{value:e}})}if(y instanceof RegExp){const{value:{lastIndex:e}}=p,o=new RegExp(p.value.source,p.value.flags);return Object.defineProperty(l,r,{...p,...{value:o}}),void(l[r].lastIndex=e)}if(y instanceof Promise)return void Object.defineProperty(l,r,p);l[r]=e(y,{setPrototype:o,invokeConstructors:t,copyNonEnumerables:n,copySymbols:s,copyGettersSetters:i,allowCircularReferences:a},c,f),u.set(y,l[r])}else{const e=Object.getOwnPropertyDescriptor(l,r);e&&!e.configurable||Object.defineProperty(l,r,p)}}),a&&(c.set(r,l),f===r)){const e=new WeakMap;e.set(l),function r(o,t){Object.entries(o).forEach(([n,s])=>{if(s&&"object"==typeof s)if(t.has(s))o[n]=t.get(s);else{if(e.has(s))return;e.set(s),r(s,t)}})}(l,c)}return l}(e,a,new WeakMap,e)}}]); |
{ | ||
"name": "omniclone", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"description": "deepClone function for js objects", | ||
"main": "dist/main.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"test": "jest --watchAll --coverage", | ||
"dev": "webpack --mode development src/deepClone.js", | ||
"build": "webpack --mode production src/deepClone.js" | ||
"build": "webpack --mode production src/deepClone.js", | ||
"lint": "eslint" | ||
}, | ||
@@ -35,2 +36,4 @@ "repository": { | ||
"devDependencies": { | ||
"babel-jest": "^23.6.0", | ||
"babel-preset-env": "^1.7.0", | ||
"eslint": "^5.11.1", | ||
@@ -40,7 +43,14 @@ "eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jest": "^22.1.2", | ||
"eslint-plugin-prettier": "^3.0.1", | ||
"jest": "^23.6.0", | ||
"prettier": "^1.15.3", | ||
"webpack": "^4.28.3", | ||
"webpack-cli": "^3.2.0" | ||
}, | ||
"jest": { | ||
"transform": { | ||
"^.+\\.js$": "babel-jest" | ||
} | ||
} | ||
} |
@@ -135,2 +135,3 @@ # omniclone | ||
``` | ||
Odds are that to properly copy gets&setts you have also to enable the `copyNonEnumerables` flag. | ||
@@ -175,5 +176,6 @@ ### allowCircularReferences (default false) | ||
## warnings | ||
## warnings and limitations | ||
1. promises and methods are always copied by reference | ||
2. `super` is statically bound to a class heirarchy, remember it | ||
3. `Error` objects cannot be copied | ||
3. `Error` objects cannot be properly copied because of js limitations | ||
4. currently there is no isomorphic way to detect if an object is a `Proxy` nor is possible to access the handler object. Because of transparent virtualization, `omniclone` will copy each properties, the `constructor` and the `[[Prototype]]` directly from the proxed object. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
12625
1
179
12