Huge News!Announcing our $40M Series B led by Abstract Ventures.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.1 to 1.0.2

2

deep-clone-fn.d.ts

@@ -8,2 +8,2 @@ export interface DeepCloneFunctionOptions {

}
export default function deepCloneFunction<ArgumentsType extends unknown[], ReturnType, FunctionType extends (...args: ArgumentsType) => ReturnType>(fn: FunctionType, { ignoreNonConfigurable }?: DeepCloneFunctionOptions): FunctionType;
export default function deepCloneFunction<F>(fn: F, { ignoreNonConfigurable }?: DeepCloneFunctionOptions): F;

@@ -61,13 +61,15 @@ /* eslint-disable @typescript-eslint/no-base-to-string */

export default function deepCloneFunction(fn, { ignoreNonConfigurable = false } = {}) {
const { name } = fn;
const fnToClone = fn;
const { name } = fnToClone;
function clonedFn(...args) {
return fn(...args);
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
return fnToClone(...args);
}
for (const property of Reflect.ownKeys(fn)) {
copyProperty(clonedFn, fn, property, ignoreNonConfigurable);
for (const property of Reflect.ownKeys(fnToClone)) {
copyProperty(clonedFn, fnToClone, property, ignoreNonConfigurable);
}
changePrototype(clonedFn, fn);
changeToString(clonedFn, fn, name);
changePrototype(clonedFn, fnToClone);
changeToString(clonedFn, fnToClone, name);
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return clonedFn;
}
{
"name": "deep-clone-fn",
"version": "1.0.1",
"version": "1.0.2",
"description": "Deep clone a function.",

@@ -61,3 +61,3 @@ "license": "MIT",

},
"readme": "# deep-clone-fn\n\nA modification of Sindre Sorhus' excellent [mimic-fn](https://www.npmjs.com/package/mimic-fn) for deep cloning functions.\n\n## Installation\n\n```shell\nnpm install deep-clone-fn\n```\n\n## Usage\n\n```typescript\nimport deepCloneFunction from 'deep-clone-fn';\n\nfunction f(x) {\n return x;\n}\n\nf.myProperty = { foo: 'bar' };\n\nconst g = deepCloneFunction(f);\n\nf.myProperty.foo = 'baz';\n\nconsole.log(g.myProperty); // { foo: 'bar' }\nconsole.log(g('foo')); // foo\n```\n"
"readme": "# deep-clone-fn\n\nA modification of Sindre Sorhus's excellent [mimic-fn](https://www.npmjs.com/package/mimic-fn) for deep cloning functions.\n\n## Installation\n\n```shell\nnpm install deep-clone-fn\n```\n\n## Usage\n\n```typescript\nimport deepCloneFunction from 'deep-clone-fn';\n\nfunction f(x) {\n return x;\n}\n\nf.myProperty = { foo: 'bar' };\n\nconst g = deepCloneFunction(f);\n\nf.myProperty.foo = 'baz';\n\nconsole.log(g.myProperty); // { foo: 'bar' }\nconsole.log(g('foo')); // foo\n```\n"
}
# deep-clone-fn
A modification of Sindre Sorhus' excellent [mimic-fn](https://www.npmjs.com/package/mimic-fn) for deep cloning functions.
A modification of Sindre Sorhus's excellent [mimic-fn](https://www.npmjs.com/package/mimic-fn) for deep cloning functions.

@@ -5,0 +5,0 @@ ## Installation

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