New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

deep-clone-fn

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-clone-fn - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

25

deep-clone-fn.js

@@ -1,2 +0,1 @@

/* eslint-disable @typescript-eslint/no-base-to-string */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */

@@ -7,5 +6,4 @@ /* eslint-disable @typescript-eslint/ban-types */

const copyProperty = (to, from, property, ignoreNonConfigurable) => {
// `Function#length` should reflect the parameters of `to` not `from` since we keep its body.
// `Function#prototype` is non-writable and non-configurable so can never be modified.
if (property === 'length' || property === 'prototype') {
if (property === 'prototype') {
return;

@@ -22,6 +20,6 @@ }

}
Object.defineProperty(to, property, {
...fromDescriptor,
value: clone(fromDescriptor?.value),
});
Object.defineProperty(to, property, fromDescriptor);
if (fromDescriptor.writable) {
to[property] = clone(from[property]);
}
};

@@ -46,3 +44,3 @@ // `Object.defineProperty()` throws if the property exists, is not configurable and either:

};
const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\n${fromBody}`;
const clonedToString = (fromBody) => fromBody;
const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');

@@ -53,6 +51,6 @@ const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');

// Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.
const changeToString = (to, from, name) => {
const withName = name === '' ? '' : `with ${name.trim()}() `;
const newToString = wrappedToString.bind(null, withName, from.toString());
// Ensure `to.toString.toString` is non-enumerable and has the same `same`
const changeToString = (to, from) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
const newToString = clonedToString.bind(null, from.toString());
// Ensure `to.toString.toString` is non-enumerable and has the same `name`
Object.defineProperty(newToString, 'name', toStringName);

@@ -66,3 +64,2 @@ Object.defineProperty(to, 'toString', {

const fnToClone = fn;
const { name } = fnToClone;
function clonedFn(...args) {

@@ -76,5 +73,5 @@ // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call

changePrototype(clonedFn, fnToClone);
changeToString(clonedFn, fnToClone, name);
changeToString(clonedFn, fnToClone);
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return clonedFn;
}
{
"name": "deep-clone-fn",
"version": "1.0.2",
"version": "1.0.3",
"description": "Deep clone a function.",

@@ -5,0 +5,0 @@ "license": "MIT",

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