Comparing version 2.0.1 to 2.0.2
# fast-copy CHANGELOG | ||
## 2.0.2 | ||
- Manually coalesce options instead of use destructuring (performance) | ||
## 2.0.1 | ||
@@ -4,0 +8,0 @@ |
@@ -185,5 +185,6 @@ 'use strict'; | ||
*/ | ||
function copy(object, _a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.isStrict, isStrict = _c === void 0 ? false : _c, _d = _b.realm, realm = _d === void 0 ? GLOBAL_THIS : _d; | ||
var RealmArrayBuffer = realm.ArrayBuffer, RealmBuffer = realm.Buffer, RealmMap = realm.Map, RealmSet = realm.Set, RealmWeakMap = realm.WeakMap, RealmWeakSet = realm.WeakSet; | ||
function copy(object, options) { | ||
// manually coalesced instead of default parameters for performance | ||
var isStrict = !!(options && options.isStrict); | ||
var realm = (options && options.realm) || GLOBAL_THIS; | ||
var getObjectClone = isStrict | ||
@@ -236,3 +237,3 @@ ? getObjectCloneStrict | ||
// maps | ||
if (RealmMap && object instanceof RealmMap) { | ||
if (realm.Map && object instanceof realm.Map) { | ||
cache.add(object); | ||
@@ -246,3 +247,3 @@ clone = new Constructor(); | ||
// sets | ||
if (RealmSet && object instanceof RealmSet) { | ||
if (realm.Set && object instanceof realm.Set) { | ||
cache.add(object); | ||
@@ -256,5 +257,5 @@ clone = new Constructor(); | ||
// buffers (node-only) | ||
if (RealmBuffer && RealmBuffer.isBuffer(object)) { | ||
clone = RealmBuffer.allocUnsafe | ||
? RealmBuffer.allocUnsafe(object.length) | ||
if (realm.Buffer && realm.Buffer.isBuffer(object)) { | ||
clone = realm.Buffer.allocUnsafe | ||
? realm.Buffer.allocUnsafe(object.length) | ||
: new Constructor(object.length); | ||
@@ -265,9 +266,9 @@ object.copy(clone); | ||
// arraybuffers / dataviews | ||
if (RealmArrayBuffer) { | ||
if (realm.ArrayBuffer) { | ||
// dataviews | ||
if (RealmArrayBuffer.isView(object)) { | ||
if (realm.ArrayBuffer.isView(object)) { | ||
return new Constructor(object.buffer.slice(0)); | ||
} | ||
// arraybuffers | ||
if (object instanceof RealmArrayBuffer) { | ||
if (object instanceof realm.ArrayBuffer) { | ||
return object.slice(0); | ||
@@ -283,5 +284,5 @@ } | ||
// weakmaps | ||
(RealmWeakMap && object instanceof RealmWeakMap) || | ||
(realm.WeakMap && object instanceof realm.WeakMap) || | ||
// weaksets | ||
(RealmWeakSet && object instanceof RealmWeakSet)) { | ||
(realm.WeakSet && object instanceof realm.WeakSet)) { | ||
return object; | ||
@@ -288,0 +289,0 @@ } |
@@ -183,5 +183,6 @@ var toStringFunction = Function.prototype.toString; | ||
*/ | ||
function copy(object, _a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.isStrict, isStrict = _c === void 0 ? false : _c, _d = _b.realm, realm = _d === void 0 ? GLOBAL_THIS : _d; | ||
var RealmArrayBuffer = realm.ArrayBuffer, RealmBuffer = realm.Buffer, RealmMap = realm.Map, RealmSet = realm.Set, RealmWeakMap = realm.WeakMap, RealmWeakSet = realm.WeakSet; | ||
function copy(object, options) { | ||
// manually coalesced instead of default parameters for performance | ||
var isStrict = !!(options && options.isStrict); | ||
var realm = (options && options.realm) || GLOBAL_THIS; | ||
var getObjectClone = isStrict | ||
@@ -234,3 +235,3 @@ ? getObjectCloneStrict | ||
// maps | ||
if (RealmMap && object instanceof RealmMap) { | ||
if (realm.Map && object instanceof realm.Map) { | ||
cache.add(object); | ||
@@ -244,3 +245,3 @@ clone = new Constructor(); | ||
// sets | ||
if (RealmSet && object instanceof RealmSet) { | ||
if (realm.Set && object instanceof realm.Set) { | ||
cache.add(object); | ||
@@ -254,5 +255,5 @@ clone = new Constructor(); | ||
// buffers (node-only) | ||
if (RealmBuffer && RealmBuffer.isBuffer(object)) { | ||
clone = RealmBuffer.allocUnsafe | ||
? RealmBuffer.allocUnsafe(object.length) | ||
if (realm.Buffer && realm.Buffer.isBuffer(object)) { | ||
clone = realm.Buffer.allocUnsafe | ||
? realm.Buffer.allocUnsafe(object.length) | ||
: new Constructor(object.length); | ||
@@ -263,9 +264,9 @@ object.copy(clone); | ||
// arraybuffers / dataviews | ||
if (RealmArrayBuffer) { | ||
if (realm.ArrayBuffer) { | ||
// dataviews | ||
if (RealmArrayBuffer.isView(object)) { | ||
if (realm.ArrayBuffer.isView(object)) { | ||
return new Constructor(object.buffer.slice(0)); | ||
} | ||
// arraybuffers | ||
if (object instanceof RealmArrayBuffer) { | ||
if (object instanceof realm.ArrayBuffer) { | ||
return object.slice(0); | ||
@@ -281,5 +282,5 @@ } | ||
// weakmaps | ||
(RealmWeakMap && object instanceof RealmWeakMap) || | ||
(realm.WeakMap && object instanceof realm.WeakMap) || | ||
// weaksets | ||
(RealmWeakSet && object instanceof RealmWeakSet)) { | ||
(realm.WeakSet && object instanceof realm.WeakSet)) { | ||
return object; | ||
@@ -286,0 +287,0 @@ } |
@@ -189,5 +189,6 @@ (function (global, factory) { | ||
*/ | ||
function copy(object, _a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.isStrict, isStrict = _c === void 0 ? false : _c, _d = _b.realm, realm = _d === void 0 ? GLOBAL_THIS : _d; | ||
var RealmArrayBuffer = realm.ArrayBuffer, RealmBuffer = realm.Buffer, RealmMap = realm.Map, RealmSet = realm.Set, RealmWeakMap = realm.WeakMap, RealmWeakSet = realm.WeakSet; | ||
function copy(object, options) { | ||
// manually coalesced instead of default parameters for performance | ||
var isStrict = !!(options && options.isStrict); | ||
var realm = (options && options.realm) || GLOBAL_THIS; | ||
var getObjectClone = isStrict | ||
@@ -240,3 +241,3 @@ ? getObjectCloneStrict | ||
// maps | ||
if (RealmMap && object instanceof RealmMap) { | ||
if (realm.Map && object instanceof realm.Map) { | ||
cache.add(object); | ||
@@ -250,3 +251,3 @@ clone = new Constructor(); | ||
// sets | ||
if (RealmSet && object instanceof RealmSet) { | ||
if (realm.Set && object instanceof realm.Set) { | ||
cache.add(object); | ||
@@ -260,5 +261,5 @@ clone = new Constructor(); | ||
// buffers (node-only) | ||
if (RealmBuffer && RealmBuffer.isBuffer(object)) { | ||
clone = RealmBuffer.allocUnsafe | ||
? RealmBuffer.allocUnsafe(object.length) | ||
if (realm.Buffer && realm.Buffer.isBuffer(object)) { | ||
clone = realm.Buffer.allocUnsafe | ||
? realm.Buffer.allocUnsafe(object.length) | ||
: new Constructor(object.length); | ||
@@ -269,9 +270,9 @@ object.copy(clone); | ||
// arraybuffers / dataviews | ||
if (RealmArrayBuffer) { | ||
if (realm.ArrayBuffer) { | ||
// dataviews | ||
if (RealmArrayBuffer.isView(object)) { | ||
if (realm.ArrayBuffer.isView(object)) { | ||
return new Constructor(object.buffer.slice(0)); | ||
} | ||
// arraybuffers | ||
if (object instanceof RealmArrayBuffer) { | ||
if (object instanceof realm.ArrayBuffer) { | ||
return object.slice(0); | ||
@@ -287,5 +288,5 @@ } | ||
// weakmaps | ||
(RealmWeakMap && object instanceof RealmWeakMap) || | ||
(realm.WeakMap && object instanceof realm.WeakMap) || | ||
// weaksets | ||
(RealmWeakSet && object instanceof RealmWeakSet)) { | ||
(realm.WeakSet && object instanceof realm.WeakSet)) { | ||
return object; | ||
@@ -292,0 +293,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self)["fast-copy"]=t()}(this,function(){"use strict";var e=Function.prototype.toString,t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.getOwnPropertySymbols,f=Object.getPrototypeOf,c=Object.prototype,a=c.hasOwnProperty,u=c.propertyIsEnumerable,l="function"==typeof i,s="function"==typeof WeakSet,d=function(){if(s)return new WeakSet;var e=t({add:function(t){return e._values.push(t)},has:function(t){return!!~e._values.indexOf(t)}});return e._values=[],e},p=function(n,r){if(!n.constructor)return t(null);var o=n.__proto__||f(n);return n.constructor===r.Object?o===r.Object.prototype?{}:t(o):~e.call(n.constructor).indexOf("[native code]")?new n.constructor:t(o)},y=function(e,t,n,r){var o=p(e,t);for(var f in e)a.call(e,f)&&(o[f]=n(e[f],r));if(l){var c=i(e);if(c.length)for(var s=0,d=void 0;s<c.length;s++)d=c[s],u.call(e,d)&&(o[d]=n(e[d],r))}return o},v=function(e,t,f,c){var a=p(e,t),u=l?[].concat(o(e),i(e)):o(e);if(u.length)for(var s=0,d=void 0,y=void 0;s<u.length;s++)"callee"!==(d=u[s])&&"caller"!==d&&((y=r(e,d)).value=f(e[d],c),n(a,d,y));return a},g=function(e){var t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t},b=Array.isArray,w="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void(console&&console.error&&console.error('Unable to locate global object, returning "this".'));function O(e,t){var n=void 0===t?{}:t,r=n.isStrict,o=void 0!==r&&r,i=n.realm,f=void 0===i?w:i,c=f.ArrayBuffer,a=f.Buffer,u=f.Map,l=f.Set,s=f.WeakMap,p=f.WeakSet,O=o?v:y,h=function(e,t){if(!e||"object"!=typeof e||t.has(e))return e;var n,r=e.constructor;if(r===f.Object)return t.add(e),O(e,f,h,t);if(b(e)){if(t.add(e),o)return v(e,f,h,t);n=new r;for(var i=0;i<e.length;i++)n[i]=h(e[i],t);return n}if(e instanceof f.Date)return new r(e.getTime());if(e instanceof f.RegExp)return(n=new r(e.source,e.flags||g(e))).lastIndex=e.lastIndex,n;if(u&&e instanceof u)return t.add(e),n=new r,e.forEach(function(e,r){n.set(r,h(e,t))}),n;if(l&&e instanceof l)return t.add(e),n=new r,e.forEach(function(e){n.add(h(e,t))}),n;if(a&&a.isBuffer(e))return n=a.allocUnsafe?a.allocUnsafe(e.length):new r(e.length),e.copy(n),n;if(c){if(c.isView(e))return new r(e.buffer.slice(0));if(e instanceof c)return e.slice(0)}return"function"==typeof e.then||e instanceof Error||s&&e instanceof s||p&&e instanceof p?e:(t.add(e),O(e,f,h,t))};return h(e,d())}return O.strict=function(e,t){return O(e,{isStrict:!0,realm:t?t.realm:void 0})},O}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self)["fast-copy"]=t()}(this,function(){"use strict";var e=Function.prototype.toString,t=Object.create,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols,i=Object.getPrototypeOf,a=Object.prototype,c=a.hasOwnProperty,u=a.propertyIsEnumerable,l="function"==typeof f,s="function"==typeof WeakSet,d=function(){if(s)return new WeakSet;var e=t({add:function(t){return e._values.push(t)},has:function(t){return!!~e._values.indexOf(t)}});return e._values=[],e},p=function(r,n){if(!r.constructor)return t(null);var o=r.__proto__||i(r);return r.constructor===n.Object?o===n.Object.prototype?{}:t(o):~e.call(r.constructor).indexOf("[native code]")?new r.constructor:t(o)},y=function(e,t,r,n){var o=p(e,t);for(var i in e)c.call(e,i)&&(o[i]=r(e[i],n));if(l){var a=f(e);if(a.length)for(var s=0,d=void 0;s<a.length;s++)d=a[s],u.call(e,d)&&(o[d]=r(e[d],n))}return o},v=function(e,t,i,a){var c=p(e,t),u=l?[].concat(o(e),f(e)):o(e);if(u.length)for(var s=0,d=void 0,y=void 0;s<u.length;s++)"callee"!==(d=u[s])&&"caller"!==d&&((y=n(e,d)).value=i(e[d],a),r(c,d,y));return c},g=function(e){var t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t},b=Array.isArray,w="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void(console&&console.error&&console.error('Unable to locate global object, returning "this".'));function O(e,t){var r=!(!t||!t.isStrict),n=t&&t.realm||w,o=r?v:y,f=function(e,t){if(!e||"object"!=typeof e||t.has(e))return e;var i,a=e.constructor;if(a===n.Object)return t.add(e),o(e,n,f,t);if(b(e)){if(t.add(e),r)return v(e,n,f,t);i=new a;for(var c=0;c<e.length;c++)i[c]=f(e[c],t);return i}if(e instanceof n.Date)return new a(e.getTime());if(e instanceof n.RegExp)return(i=new a(e.source,e.flags||g(e))).lastIndex=e.lastIndex,i;if(n.Map&&e instanceof n.Map)return t.add(e),i=new a,e.forEach(function(e,r){i.set(r,f(e,t))}),i;if(n.Set&&e instanceof n.Set)return t.add(e),i=new a,e.forEach(function(e){i.add(f(e,t))}),i;if(n.Buffer&&n.Buffer.isBuffer(e))return i=n.Buffer.allocUnsafe?n.Buffer.allocUnsafe(e.length):new a(e.length),e.copy(i),i;if(n.ArrayBuffer){if(n.ArrayBuffer.isView(e))return new a(e.buffer.slice(0));if(e instanceof n.ArrayBuffer)return e.slice(0)}return"function"==typeof e.then||e instanceof Error||n.WeakMap&&e instanceof n.WeakMap||n.WeakSet&&e instanceof n.WeakSet?e:(t.add(e),o(e,n,f,t))};return f(e,d())}return O.strict=function(e,t){return O(e,{isStrict:!0,realm:t?t.realm:void 0})},O}); |
@@ -73,3 +73,3 @@ { | ||
"types": "index.d.ts", | ||
"version": "2.0.1" | ||
"version": "2.0.2" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
97588
967