Urara-Blog/node_modules/.pnpm-store/v3/files/38/f0908de8f68a6657641fc75ceaf5a949f5fcb3e0f411bec08580d61230b2c7b05284607ba4985bd423daa12d65343df71d5988a39e6c9afe3f8e5b718b501a
2022-08-14 01:14:53 +08:00

25 lines
665 B
Text

var before = require('./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();
* // => `createApplication` is invoked once
*/
function once(func) {
return before(2, func);
}
module.exports = once;