src code

instance method Function#wrap

Function#wrap(wrapperFunction) → Function
  • wrapperFunction (Function) – The function to act as a wrapper.

Returns a function "wrapped" around the original function.

Function#wrap distills the essence of aspect-oriented programming into a single method, letting you easily build on existing functions by specifying before and after behavior, transforming the return value, or even preventing the original function from being called.