Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

once.js 665B

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;