{"name":"mimic-fn","version":"2.0.0","description":"Make a function mimic another one","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/mimic-fn.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["function","mimic","imitate","rename","copy","inherit","properties","name","func","fn","set","infer","change"],"devDependencies":{"ava":"^1.3.1","tsd-check":"^0.3.0","xo":"^0.24.0"},"gitHead":"aa885ea38acdc9bfb55c3e7fd0ff2bfa75ccda71","bugs":{"url":"https://github.com/sindresorhus/mimic-fn/issues"},"homepage":"https://github.com/sindresorhus/mimic-fn#readme","_id":"mimic-fn@2.0.0","_nodeVersion":"8.15.0","_npmVersion":"6.8.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-jbex9Yd/3lmICXwYT6gA/j2mNQGU48wCh/VzRd+/Y/PjYQtlg1gLMdZqvu9s/xH7qKvngxRObl56XZR609IMbA==","shasum":"0913ff0b121db44ef5848242c38bbb35d44cabde","tarball":"http://registry-npm.ywwl.com/mimic-fn/download/mimic-fn-2.0.0.tgz","fileCount":5,"unpackedSize":3582,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcgWo1CRA9TVsSAnZWagAAMroP/3gX8/w+muTYgS1KGl5D\nWXswvPjGUlwgiBqSmAs0sWif3ewB/SoKDKhnGIaOQDNV1TsMiNc8kKZOss2p\ny1IbanOW1ITLD6tfSWTtXaHCGKatDJFCxnPDxWD+w5+N4F8UMA98DMvL78p6\nLZih91DLSfe1MCn4oSRvunW++TSfZWOYDQrqyIM6639yqh5zD/Ki/Tk0bLJR\n2sFJSkxTPTBRUq7LicgH+tQaDCdbEF6eS3ioVSIar5qx3I2i4HqhZyVKTekp\na3T0E9dsyOxokJM7o3zGkXOuSf+R3CnHB/J31Y1ociwTaywdVq0N8mEn0xHo\nYKcpgLmfCB64uvVcBOxzAw8LuarzzbL/RtLygVxxRTl/+JsGrDLFt8yDKyiV\nqgyZY/qeenGskuvQNaiBK7BxdGNzPvnynSfWWP/JL01kGtERTOLTlVS/cAi3\njmQtd2kXIcEnrsBu6CtHLe4FOm6wodhRSpyrhB559IoDCGE6RpC38WFvzZp+\n6wRIAVV11ObhYaLqWKn8RadjUZWlAGRZZDOzSdFGP5fj7EnEPnpjOW4UZWKZ\nWyBGkNa5E9T7qKBSrM+xJTVBk+wBMuBjOh4Jd60fmx4yTsgZx3p/5hYOFmsf\nxvqXqyMc0zAx42sanZQGOD41uXRgdjL920k0lBI+EBDIU8shEa2FBVXa/UhA\n7hL+\r\n=BzEr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDblWghlQxfCf5yQGn3tv6yLmV8AwiMV/E/fOsQOAbnJgIgPO5GhuEF9QBc7xcCV/wOtGgBBABtpfZCfh3zZlD3cZI="}],"size":1909,"noattachment":false,"key":"/mimic-fn/-/mimic-fn-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-fn_2.0.0_1551985204769_0.7133439914854229"},"_hasShrinkwrap":false,"readme":"<img src=\"media/logo.svg\" alt=\"mimic-fn\" width=\"400\">\n<br>\n\n> Make a function mimic another one\n\nUseful when you wrap a function in another function and like to preserve the original name and other properties.\n\n## Install\n\n```\n$ npm install mimic-fn\n```\n\n## Usage\n\n```js\nimport mimicFunction from 'mimic-fn';\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\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\n---\n\n<div align=\"center\">\n\t<b>\n\t\t<a href=\"https://tidelift.com/subscription/pkg/npm-mimic-fn?utm_source=npm-mimic-fn&utm_medium=referral&utm_campaign=readme\">Get professional support for this package with a Tidelift subscription</a>\n\t</b>\n\t<br>\n\t<sub>\n\t\tTidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.\n\t</sub>\n</div>\n","publish_time":1551985204908,"_cnpm_publish_time":1551985204908,"dist-tags":{"latest":"5.0.0"}}