f0908de8f68a6657641fc75ceaf5a949f5fcb3e0f411bec08580d61230b2c7b05284607ba4985bd423daa12d65343df71d5988a39e6c9afe3f8e5b718b501a 665 B

12345678910111213141516171819202122232425
  1. var before = require('./before');
  2. /**
  3. * Creates a function that is restricted to invoking `func` once. Repeat calls
  4. * to the function return the value of the first invocation. The `func` is
  5. * invoked with the `this` binding and arguments of the created function.
  6. *
  7. * @static
  8. * @memberOf _
  9. * @since 0.1.0
  10. * @category Function
  11. * @param {Function} func The function to restrict.
  12. * @returns {Function} Returns the new restricted function.
  13. * @example
  14. *
  15. * var initialize = _.once(createApplication);
  16. * initialize();
  17. * initialize();
  18. * // => `createApplication` is invoked once
  19. */
  20. function once(func) {
  21. return before(2, func);
  22. }
  23. module.exports = once;