{"name":"mimic-fn","version":"3.1.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":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["function","mimic","imitate","rename","copy","inherit","properties","name","func","fn","set","infer","change"],"devDependencies":{"ava":"^2.1.0","tsd":"^0.7.1","xo":"^0.24.0"},"gitHead":"2ada36ff62c03d97da9604c8a2f22a5153c87b06","bugs":{"url":"https://github.com/sindresorhus/mimic-fn/issues"},"homepage":"https://github.com/sindresorhus/mimic-fn#readme","_id":"mimic-fn@3.1.0","_nodeVersion":"14.5.0","_npmVersion":"6.14.5","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-Ysbi9uYW9hFyfrThdDEQuykN4Ey6BuwPD2kpI5ES/nFTDn/98yxYNLZJcgUAKPT/mcrLLKaGzJR9YVxJrIdASQ==","shasum":"65755145bbf3e36954b949c16450427451d5ca74","tarball":"http://registry-npm.ywwl.com/mimic-fn/download/mimic-fn-3.1.0.tgz","fileCount":5,"unpackedSize":8244,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfGqZBCRA9TVsSAnZWagAA9+EP/jPxwLw6SVZTo9Z19At9\n2Uh3/V+6tLuZHOdiaSSzOhqQWHzhuXmnmLe4jNOZ4LwTN7fGaD/HEkC6NqrR\njYGRL6KHDCaArr3RffVJ5Vqy8F2xBowYPwnOIKBbkBzVvmbFHmf708b9U8ed\nTb7ZLDRdNgyCS67GoX2Bs1SCNZJrCzFcjqcY/EP4vYeTxyEljpbamrsdLvZC\nlv4NA4/zGfABgynozKa3McBplcgOmBqM1TYjsTQ00ClluUbcb8954YNEDqal\nPqBYUocgQCbsdeYIuGlQWOLbB1IgFrb0hgRpr3m7igEHK3vURN4xf5KozpWa\nC24Mc0k8Nwq5D7FJ2Sdv1oJwqJk3kA5Br1alnBO4rgoySNc0kIagznbSBk+v\nfaEsJoVzhHzmIW+27fpFs/1nDim2CnCOijsyoGccuXxd+WWH/snFq7+wBsrs\n/MIrOIu0XiSOjZRIdKQec9/5N4XvwzBCGEtmb9Ti6K9h4cLEpZY65sKfSCP+\nW2jFzVzwbTBz2sihgvxNSKIi/bJZdzb78AxF84jcxd3p2xV6OrGjPBfES8dA\nt/SGJvsc39QQZRZxxEpTXKRphlthds18thJQiE+M0c6IdoJERnXLdVu476Az\nurwci7xIkB8lJHuyRzOpKk/iW3ulzoxL1nsarpioLOK1LBFZwurUuQgj0u1s\n9/1Y\r\n=UMkg\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB0rmkv1jTo6iYyuI44ph64qzMI8nS4dmjSJVWlV93DFAiEAlnF5HD7Cp13LhLKEidtHZY3CUu0Sn/bqxvCHTQfidOs="}],"size":3364,"noattachment":false,"key":"/mimic-fn/-/mimic-fn-3.1.0.tgz"},"maintainers":[{"email":"ehmicky@gmail.com","name":"ehmicky"},{"email":"sindresorhus@gmail.com","name":"sindresorhus"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mimic-fn_3.1.0_1595582016684_0.8596377806235356"},"_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":1595582016810,"_cnpm_publish_time":1595582016810,"dist-tags":{"latest":"5.0.0"}}