{"_id":"mimic-function","_rev":"1-84b4ebaa26ffb8377848e72bbf3a6701","name":"mimic-function","dist-tags":{"latest":"5.0.1"},"versions":{"5.0.0":{"name":"mimic-function","version":"5.0.0","description":"Make a function mimic another one","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/mimic-function.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsd"},"keywords":["function","mimic","imitate","rename","copy","inherit","properties","name","func","fn","set","infer","change"],"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"7748ad022edb602feb1d6ab1920c1097e63785c5","bugs":{"url":"https://github.com/sindresorhus/mimic-function/issues"},"homepage":"https://github.com/sindresorhus/mimic-function#readme","_id":"mimic-function@5.0.0","_nodeVersion":"20.9.0","_npmVersion":"9.2.0","dist":{"integrity":"sha512-RBfQ+9X9DpXdEoK7Bu+KeEU6vFhumEIiXKWECPzRBmDserEq4uR2b/VCm0LwpMSosoq2k+Zuxj/GzOr0Fn6h/g==","shasum":"6cb5a922d17923ee58cf2f7d904f3eb350e0c87a","tarball":"https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.0.tgz","fileCount":5,"unpackedSize":7961,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICRzsiPwJ43fqQ9JNLz2GxPNSU6Oa0poknBSRtP9uJOYAiEA3jxHV1klDU00BI4Sfptv0Jd46z6MRKAAfujPLRZo6TY="}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-function_5.0.0_1699213989270_0.19737321168271826"},"_hasShrinkwrap":false},"5.0.1":{"name":"mimic-function","version":"5.0.1","description":"Make a function mimic another one","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/mimic-function.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsd"},"keywords":["function","mimic","imitate","rename","copy","inherit","properties","name","func","fn","set","infer","change"],"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"e451d0af761bed2cde0b9bc252dc6a2dfeb35844","bugs":{"url":"https://github.com/sindresorhus/mimic-function/issues"},"homepage":"https://github.com/sindresorhus/mimic-function#readme","_id":"mimic-function@5.0.1","_nodeVersion":"20.11.1","_npmVersion":"9.2.0","dist":{"integrity":"sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==","shasum":"acbe2b3349f99b9deaca7fb70e48b83e94e67076","tarball":"https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz","fileCount":5,"unpackedSize":8096,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDqi2cYXNmieqqlagx5nZGl3Dscqv7WuVspDts/6JSGvwIgbdoOPPFR/AMDNG74GZ5pK6dJm9dYlxhDheknUMvAuRo="}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-function_5.0.1_1710405462144_0.5510414973189222"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-05T19:53:09.269Z","5.0.0":"2023-11-05T19:53:09.458Z","modified":"2024-03-14T08:37:42.724Z","5.0.1":"2024-03-14T08:37:42.297Z"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"description":"Make a function mimic another one","homepage":"https://github.com/sindresorhus/mimic-function#readme","keywords":["function","mimic","imitate","rename","copy","inherit","properties","name","func","fn","set","infer","change"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/mimic-function.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"bugs":{"url":"https://github.com/sindresorhus/mimic-function/issues"},"license":"MIT","readme":"\n\t\n\t\"mimic-function\n\n
\n\n> Make a function mimic another one\n\nUseful when you wrap a function in another function and you would like to preserve the original name and other properties.\n\n## Install\n\n```sh\nnpm install mimic-function\n```\n\n## Usage\n\n```js\nimport mimicFunction from 'mimic-function';\n\nfunction foo() {}\nfoo.unicorn = '🦄';\n\nfunction wrapper() {\n\treturn foo();\n}\n\nconsole.log(wrapper.name);\n//=> 'wrapper'\n\nmimicFunction(wrapper, foo);\n\nconsole.log(wrapper.name);\n//=> 'foo'\n\nconsole.log(wrapper.unicorn);\n//=> '🦄'\n\nconsole.log(String(wrapper));\n//=> '/* Wrapped with wrapper() */\\nfunction foo() {}'\n```\n\n## API\n\n### mimicFunction(to, from, options?)\n\nModifies the `to` function to mimic the `from` function. Returns the `to` function.\n\n`name`, `displayName`, and any other properties of `from` are copied. The `length` property is not copied. Prototype, class, and inherited properties are copied.\n\n`to.toString()` will return the same as `from.toString()` but prepended with a `Wrapped with to()` comment.\n\n#### to\n\nType: `Function`\n\nMimicking function.\n\n#### from\n\nType: `Function`\n\nFunction to mimic.\n\n#### options\n\nType: `object`\n\n##### ignoreNonConfigurable\n\nType: `boolean`\\\nDefault: `false`\n\nSkip modifying [non-configurable properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor#Description) instead of throwing an error.\n\n## Related\n\n- [rename-fn](https://github.com/sindresorhus/rename-fn) - Rename a function\n- [keep-func-props](https://github.com/ehmicky/keep-func-props) - Wrap a function without changing its name and other properties\n","readmeFilename":"readme.md"}