wrap

Function
since 0.1.0

Arguments

  • * The value to wrap.
  • Function The wrapper function.

Returns

Function the new function.

Creates a function that provides value to wrapper as its first argument. Any additional arguments provided to the function are appended to those provided to the wrapper. The wrapper is invoked with the this binding of the created function.

Example of Lodash _.wrap

var p = _.wrap(_.escape, function(func, text) {
  return '<p>' + func(text) + '</p>';
});

p('fred, barney, & pebbles');
// => '<p>fred, barney, &amp; pebbles</p>'