Projekt

Obecné

Profil

Stáhnout (665 Bajtů) Statistiky
| Větev: | Revize:
1
var before = require('./before');
2

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

    
25
module.exports = once;
(454-454/590)