Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

123456789101112131415161718192021222324252627282930
  1. var castFunction = require('./_castFunction'),
  2. partial = require('./partial');
  3. /**
  4. * Creates a function that provides `value` to `wrapper` as its first
  5. * argument. Any additional arguments provided to the function are appended
  6. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  7. * binding of the created function.
  8. *
  9. * @static
  10. * @memberOf _
  11. * @since 0.1.0
  12. * @category Function
  13. * @param {*} value The value to wrap.
  14. * @param {Function} [wrapper=identity] The wrapper function.
  15. * @returns {Function} Returns the new function.
  16. * @example
  17. *
  18. * var p = _.wrap(_.escape, function(func, text) {
  19. * return '<p>' + func(text) + '</p>';
  20. * });
  21. *
  22. * p('fred, barney, & pebbles');
  23. * // => '<p>fred, barney, &amp; pebbles</p>'
  24. */
  25. function wrap(value, wrapper) {
  26. return partial(castFunction(wrapper), value);
  27. }
  28. module.exports = wrap;