Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-copy

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-copy - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

44

dist/fast-copy.cjs.js

@@ -12,7 +12,7 @@ 'use strict';

* @property {boolean} SYMBOL_PROPERTIES are symbol properties supported
* @property {boolean} WEAKSET is WeakSet supported
* @property {boolean} WEAKMAP is WeakMap supported
*/
var SUPPORTS = {
SYMBOL_PROPERTIES: typeof getOwnPropertySymbols === 'function',
WEAKSET: typeof WeakSet === 'function',
WEAKMAP: typeof WeakMap === 'function',
};

@@ -28,9 +28,15 @@ /**

var createCache = function () {
if (SUPPORTS.WEAKSET) {
return new WeakSet();
if (SUPPORTS.WEAKMAP) {
return new WeakMap();
}
// tiny implementation of WeakMap
var object = create({
add: function (value) { return object._values.push(value); },
has: function (value) { return !!~object._values.indexOf(value); },
has: function (key) { return !!~object._keys.indexOf(key); },
set: function (key, value) {
object._keys.push(key);
object._values.push(value);
},
get: function (key) { return object._values[object._keys.indexOf(key)]; },
});
object._keys = [];
object._values = [];

@@ -80,2 +86,4 @@ return object;

var clone = getCleanClone(object, realm);
// set in the cache immediately to be able to reuse the object recursively
cache.set(object, clone);
for (var key in object) {

@@ -114,2 +122,4 @@ if (hasOwnProperty.call(object, key)) {

var clone = getCleanClone(object, realm);
// set in the cache immediately to be able to reuse the object recursively
cache.set(object, clone);
var properties = SUPPORTS.SYMBOL_PROPERTIES

@@ -212,9 +222,11 @@ ? getOwnPropertyNames(object).concat(getOwnPropertySymbols(object))

var handleCopy = function (object, cache) {
if (!object || typeof object !== 'object' || cache.has(object)) {
if (!object || typeof object !== 'object') {
return object;
}
if (cache.has(object)) {
return cache.get(object);
}
var Constructor = object.constructor;
// plain objects
if (Constructor === realm.Object) {
cache.add(object);
return getObjectClone(object, realm, handleCopy, cache);

@@ -225,3 +237,2 @@ }

if (isArray(object)) {
cache.add(object);
// if strict, include non-standard properties

@@ -233,2 +244,3 @@ if (isStrict) {

clone = new Constructor();
cache.set(object, clone);
for (var index = 0; index < length_1; index++) {

@@ -251,4 +263,4 @@ clone[index] = handleCopy(object[index], cache);

if (realm.Map && object instanceof realm.Map) {
cache.add(object);
clone = new Constructor();
cache.set(object, clone);
object.forEach(function (value, key) {

@@ -261,4 +273,4 @@ clone.set(key, handleCopy(value, cache));

if (realm.Set && object instanceof realm.Set) {
cache.add(object);
clone = new Constructor();
cache.set(object, clone);
object.forEach(function (value) {

@@ -274,2 +286,3 @@ clone.add(handleCopy(value, cache));

: new Constructor(object.length);
cache.set(object, clone);
object.copy(clone);

@@ -282,7 +295,11 @@ return clone;

if (realm.ArrayBuffer.isView(object)) {
return new Constructor(object.buffer.slice(0));
clone = new Constructor(object.buffer.slice(0));
cache.set(object, clone);
return clone;
}
// arraybuffers
if (object instanceof realm.ArrayBuffer) {
return object.slice(0);
clone = object.slice(0);
cache.set(object, clone);
return clone;
}

@@ -302,3 +319,2 @@ }

}
cache.add(object);
// assume anything left is a custom constructor

@@ -305,0 +321,0 @@ return getObjectClone(object, realm, handleCopy, cache);

@@ -10,7 +10,7 @@ var toStringFunction = Function.prototype.toString;

* @property {boolean} SYMBOL_PROPERTIES are symbol properties supported
* @property {boolean} WEAKSET is WeakSet supported
* @property {boolean} WEAKMAP is WeakMap supported
*/
var SUPPORTS = {
SYMBOL_PROPERTIES: typeof getOwnPropertySymbols === 'function',
WEAKSET: typeof WeakSet === 'function',
WEAKMAP: typeof WeakMap === 'function',
};

@@ -26,9 +26,15 @@ /**

var createCache = function () {
if (SUPPORTS.WEAKSET) {
return new WeakSet();
if (SUPPORTS.WEAKMAP) {
return new WeakMap();
}
// tiny implementation of WeakMap
var object = create({
add: function (value) { return object._values.push(value); },
has: function (value) { return !!~object._values.indexOf(value); },
has: function (key) { return !!~object._keys.indexOf(key); },
set: function (key, value) {
object._keys.push(key);
object._values.push(value);
},
get: function (key) { return object._values[object._keys.indexOf(key)]; },
});
object._keys = [];
object._values = [];

@@ -78,2 +84,4 @@ return object;

var clone = getCleanClone(object, realm);
// set in the cache immediately to be able to reuse the object recursively
cache.set(object, clone);
for (var key in object) {

@@ -112,2 +120,4 @@ if (hasOwnProperty.call(object, key)) {

var clone = getCleanClone(object, realm);
// set in the cache immediately to be able to reuse the object recursively
cache.set(object, clone);
var properties = SUPPORTS.SYMBOL_PROPERTIES

@@ -210,9 +220,11 @@ ? getOwnPropertyNames(object).concat(getOwnPropertySymbols(object))

var handleCopy = function (object, cache) {
if (!object || typeof object !== 'object' || cache.has(object)) {
if (!object || typeof object !== 'object') {
return object;
}
if (cache.has(object)) {
return cache.get(object);
}
var Constructor = object.constructor;
// plain objects
if (Constructor === realm.Object) {
cache.add(object);
return getObjectClone(object, realm, handleCopy, cache);

@@ -223,3 +235,2 @@ }

if (isArray(object)) {
cache.add(object);
// if strict, include non-standard properties

@@ -231,2 +242,3 @@ if (isStrict) {

clone = new Constructor();
cache.set(object, clone);
for (var index = 0; index < length_1; index++) {

@@ -249,4 +261,4 @@ clone[index] = handleCopy(object[index], cache);

if (realm.Map && object instanceof realm.Map) {
cache.add(object);
clone = new Constructor();
cache.set(object, clone);
object.forEach(function (value, key) {

@@ -259,4 +271,4 @@ clone.set(key, handleCopy(value, cache));

if (realm.Set && object instanceof realm.Set) {
cache.add(object);
clone = new Constructor();
cache.set(object, clone);
object.forEach(function (value) {

@@ -272,2 +284,3 @@ clone.add(handleCopy(value, cache));

: new Constructor(object.length);
cache.set(object, clone);
object.copy(clone);

@@ -280,7 +293,11 @@ return clone;

if (realm.ArrayBuffer.isView(object)) {
return new Constructor(object.buffer.slice(0));
clone = new Constructor(object.buffer.slice(0));
cache.set(object, clone);
return clone;
}
// arraybuffers
if (object instanceof realm.ArrayBuffer) {
return object.slice(0);
clone = object.slice(0);
cache.set(object, clone);
return clone;
}

@@ -300,3 +317,2 @@ }

}
cache.add(object);
// assume anything left is a custom constructor

@@ -303,0 +319,0 @@ return getObjectClone(object, realm, handleCopy, cache);

@@ -16,7 +16,7 @@ (function (global, factory) {

* @property {boolean} SYMBOL_PROPERTIES are symbol properties supported
* @property {boolean} WEAKSET is WeakSet supported
* @property {boolean} WEAKMAP is WeakMap supported
*/
var SUPPORTS = {
SYMBOL_PROPERTIES: typeof getOwnPropertySymbols === 'function',
WEAKSET: typeof WeakSet === 'function',
WEAKMAP: typeof WeakMap === 'function',
};

@@ -32,9 +32,15 @@ /**

var createCache = function () {
if (SUPPORTS.WEAKSET) {
return new WeakSet();
if (SUPPORTS.WEAKMAP) {
return new WeakMap();
}
// tiny implementation of WeakMap
var object = create({
add: function (value) { return object._values.push(value); },
has: function (value) { return !!~object._values.indexOf(value); },
has: function (key) { return !!~object._keys.indexOf(key); },
set: function (key, value) {
object._keys.push(key);
object._values.push(value);
},
get: function (key) { return object._values[object._keys.indexOf(key)]; },
});
object._keys = [];
object._values = [];

@@ -84,2 +90,4 @@ return object;

var clone = getCleanClone(object, realm);
// set in the cache immediately to be able to reuse the object recursively
cache.set(object, clone);
for (var key in object) {

@@ -118,2 +126,4 @@ if (hasOwnProperty.call(object, key)) {

var clone = getCleanClone(object, realm);
// set in the cache immediately to be able to reuse the object recursively
cache.set(object, clone);
var properties = SUPPORTS.SYMBOL_PROPERTIES

@@ -216,9 +226,11 @@ ? getOwnPropertyNames(object).concat(getOwnPropertySymbols(object))

var handleCopy = function (object, cache) {
if (!object || typeof object !== 'object' || cache.has(object)) {
if (!object || typeof object !== 'object') {
return object;
}
if (cache.has(object)) {
return cache.get(object);
}
var Constructor = object.constructor;
// plain objects
if (Constructor === realm.Object) {
cache.add(object);
return getObjectClone(object, realm, handleCopy, cache);

@@ -229,3 +241,2 @@ }

if (isArray(object)) {
cache.add(object);
// if strict, include non-standard properties

@@ -237,2 +248,3 @@ if (isStrict) {

clone = new Constructor();
cache.set(object, clone);
for (var index = 0; index < length_1; index++) {

@@ -255,4 +267,4 @@ clone[index] = handleCopy(object[index], cache);

if (realm.Map && object instanceof realm.Map) {
cache.add(object);
clone = new Constructor();
cache.set(object, clone);
object.forEach(function (value, key) {

@@ -265,4 +277,4 @@ clone.set(key, handleCopy(value, cache));

if (realm.Set && object instanceof realm.Set) {
cache.add(object);
clone = new Constructor();
cache.set(object, clone);
object.forEach(function (value) {

@@ -278,2 +290,3 @@ clone.add(handleCopy(value, cache));

: new Constructor(object.length);
cache.set(object, clone);
object.copy(clone);

@@ -286,7 +299,11 @@ return clone;

if (realm.ArrayBuffer.isView(object)) {
return new Constructor(object.buffer.slice(0));
clone = new Constructor(object.buffer.slice(0));
cache.set(object, clone);
return clone;
}
// arraybuffers
if (object instanceof realm.ArrayBuffer) {
return object.slice(0);
clone = object.slice(0);
cache.set(object, clone);
return clone;
}

@@ -306,3 +323,2 @@ }

}
cache.add(object);
// assume anything left is a custom constructor

@@ -309,0 +325,0 @@ return getObjectClone(object, realm, handleCopy, cache);

@@ -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,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.constructor,f=r.__proto__||i(r);if(o===n.Object)return f===n.Object.prototype?{}:t(f);if(~e.call(o).indexOf("[native code]"))try{return new o}catch(e){}return t(f)},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),s=a.length;if(s)for(var d=0,y=void 0;d<s;d++)y=a[d],u.call(e,y)&&(o[y]=r(e[y],n))}return o},v=function(e,t,i,a){var c=p(e,t),u=l?o(e).concat(f(e)):o(e),s=u.length;if(s)for(var d=0,y=void 0,v=void 0;d<s;d++)"callee"!==(y=u[d])&&"caller"!==y&&((v=n(e,y)).value=i(e[y],a),r(c,y,v));return c},b=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},g=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(g(e)){if(t.add(e),r)return v(e,n,f,t);var c=e.length;i=new a;for(var u=0;u<c;u++)i[u]=f(e[u],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||b(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}));
!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,s="function"==typeof f,l="function"==typeof WeakMap,p=function(r,n){if(!r.constructor)return t(null);var o=r.constructor,f=r.__proto__||i(r);if(o===n.Object)return f===n.Object.prototype?{}:t(f);if(~e.call(o).indexOf("[native code]"))try{return new o}catch(e){}return t(f)},y=function(e,t,r,n){var o=p(e,t);for(var i in n.set(e,o),e)c.call(e,i)&&(o[i]=r(e[i],n));if(s){var a=f(e),l=a.length;if(l)for(var y=0,d=void 0;y<l;y++)d=a[y],u.call(e,d)&&(o[d]=r(e[d],n))}return o},d=function(e,t,i,a){var c=p(e,t);a.set(e,c);var u=s?o(e).concat(f(e)):o(e),l=u.length;if(l)for(var y=0,d=void 0,v=void 0;y<l;y++)"callee"!==(d=u[y])&&"caller"!==d&&((v=n(e,d)).value=i(e[d],a),r(c,d,v));return c},v=Array.isArray,g="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 b(e,r){var n=!(!r||!r.isStrict),o=r&&r.realm||g,f=n?d:y,i=function(e,t){if(!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);var r,a,c,u=e.constructor;if(u===o.Object)return f(e,o,i,t);if(v(e)){if(n)return d(e,o,i,t);var s=e.length;r=new u,t.set(e,r);for(var l=0;l<s;l++)r[l]=i(e[l],t);return r}if(e instanceof o.Date)return new u(e.getTime());if(e instanceof o.RegExp)return(r=new u(e.source,e.flags||(c="",(a=e).global&&(c+="g"),a.ignoreCase&&(c+="i"),a.multiline&&(c+="m"),a.unicode&&(c+="u"),a.sticky&&(c+="y"),c))).lastIndex=e.lastIndex,r;if(o.Map&&e instanceof o.Map)return r=new u,t.set(e,r),e.forEach((function(e,n){r.set(n,i(e,t))})),r;if(o.Set&&e instanceof o.Set)return r=new u,t.set(e,r),e.forEach((function(e){r.add(i(e,t))})),r;if(o.Buffer&&o.Buffer.isBuffer(e))return r=o.Buffer.allocUnsafe?o.Buffer.allocUnsafe(e.length):new u(e.length),t.set(e,r),e.copy(r),r;if(o.ArrayBuffer){if(o.ArrayBuffer.isView(e))return r=new u(e.buffer.slice(0)),t.set(e,r),r;if(e instanceof o.ArrayBuffer)return r=e.slice(0),t.set(e,r),r}return"function"==typeof e.then||e instanceof Error||o.WeakMap&&e instanceof o.WeakMap||o.WeakSet&&e instanceof o.WeakSet?e:f(e,o,i,t)};return i(e,function(){if(l)return new WeakMap;var e=t({has:function(t){return!!~e._keys.indexOf(t)},set:function(t,r){e._keys.push(t),e._values.push(r)},get:function(t){return e._values[e._keys.indexOf(t)]}});return e._keys=[],e._values=[],e}())}return b.strict=function(e,t){return b(e,{isStrict:!0,realm:t?t.realm:void 0})},b}));
{
"author": "tony_quetano@planttheidea.com",
"contributors": [
"Dariusz Rzepka <rzepkadarek@gmail.com>"
],
"browser": "dist/fast-copy.js",

@@ -9,7 +12,7 @@ "bugs": {

"devDependencies": {
"@types/jest": "^24.0.21",
"@types/lodash": "^4.14.144",
"@types/node": "^12.12.5",
"@types/ramda": "^0.26.33",
"@types/react": "^16.9.11",
"@types/jest": "^25.1.4",
"@types/lodash": "^4.14.149",
"@types/node": "^13.9.0",
"@types/ramda": "^0.26.43",
"@types/react": "^16.9.23",
"benchee": "^1.0.3",

@@ -20,24 +23,23 @@ "cli-table2": "^0.2.0",

"fast-clone": "^1.5.3",
"fast-deepclone": "^1.0.1",
"html-webpack-plugin": "^3.2.0",
"in-publish": "^2.0.0",
"jest": "^24.9.0",
"jest": "^25.1.0",
"lodash": "^4.17.11",
"nyc": "^14.1.1",
"ramda": "^0.26.1",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"rollup": "^1.26.3",
"nyc": "^15.0.0",
"ramda": "^0.27.0",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"rollup": "^2.0.2",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^5.1.2",
"rollup-plugin-typescript2": "^0.24.3",
"ts-jest": "^24.1.0",
"rollup-plugin-terser": "^5.2.0",
"rollup-plugin-typescript2": "^0.26.0",
"ts-jest": "^25.2.1",
"ts-loader": "^6.2.1",
"tslint": "^5.20.0",
"tslint": "^6.0.0",
"tslint-config-airbnb": "^5.11.2",
"tslint-loader": "^3.5.4",
"typescript": "^3.6.4",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0"
"typescript": "^3.8.3",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
},

@@ -77,3 +79,3 @@ "homepage": "https://github.com/planttheidea/fast-copy#readme",

"types": "index.d.ts",
"version": "2.0.4"
"version": "2.0.5"
}

@@ -202,3 +202,3 @@ # fast-copy

Standard practice, clone the repo and `npm i` to get the dependencies. The following npm scripts are available:
Standard practice, clone the repo and `yarn` (or `npm i`) to get the dependencies. The following npm scripts are available:

@@ -205,0 +205,0 @@ - benchmark => run benchmark tests against other equality libraries

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc