DEV Community

loading...

Wrap a JavaScript function without changing its name/properties (by sindresorhus)

ehmicky
・1 min read

Wrapping a JavaScript function is not as simple as one might think. Some of the issues you might encounter include:

  • keeping the original function name
  • keeping the original function static properties and inherited properties
  • showing the original function's body when using String(function)

mimic-fn is a small utility by sindresorhus tackling this issue.

https://github.com/sindresorhus/mimic-fn

Discussion (0)