basant307/AI_Governance_Project
045
1# mimic-fn [](https://travis-ci.org/sindresorhus/mimic-fn)2 3> Make a function mimic another one4 5Useful when you wrap a function in another function and like to preserve the original name and other properties.6 7 8## Install9 10```11$ npm install mimic-fn12```13 14 15## Usage16 17```js18const mimicFn = require('mimic-fn');19 20function foo() {}21foo.unicorn = '🦄';22 23function wrapper() {24 return foo();25}26 27console.log(wrapper.name);28//=> 'wrapper'29 30mimicFn(wrapper, foo);31 32console.log(wrapper.name);33//=> 'foo'34 35console.log(wrapper.unicorn);36//=> '🦄'37```38 39 40## API41 42It will copy over the properties `name`, `length`, `displayName`, and any custom properties you may have set.43 44### mimicFn(to, from)45 46Modifies the `to` function and returns it.47 48#### to49 50Type: `Function`51 52Mimicking function.53 54#### from55 56Type: `Function`57 58Function to mimic.59 60 61## Related62 63- [rename-fn](https://github.com/sindresorhus/rename-fn) - Rename a function64- [keep-func-props](https://github.com/ehmicky/keep-func-props) - Wrap a function without changing its name, length and other properties65 66 67## License68 69MIT © [Sindre Sorhus](https://sindresorhus.com)70 