DEV Community

ehmicky
ehmicky

Posted on

1 1

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

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

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay