Files
lodash/once.js
John-David Dalton d46bcaa98d Bump to v4.7.0.
2016-03-31 00:33:47 -07:00

27 lines
716 B
JavaScript

define(['./before'], function(before) {
/**
* Creates a function that is restricted to invoking `func` once. Repeat calls
* to the function return the value of the first invocation. The `func` is
* invoked with the `this` binding and arguments of the created function.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to restrict.
* @returns {Function} Returns the new restricted function.
* @example
*
* var initialize = _.once(createApplication);
* initialize();
* initialize();
* // `initialize` invokes `createApplication` once
*/
function once(func) {
return before(2, func);
}
return once;
});