Urara-Blog/node_modules/.pnpm-store/v3/files/fa/73f6905b659e75ed34c390137443b503fa761f0a6f7e120337c5e3d3d22373f16e6e6e8da0c12291dbba89af0be5de0b1bd67640723152b13df6d395e0d265
2022-08-14 01:14:53 +08:00

26 lines
528 B
Text

/**
* Creates a function that returns `value`.
*
* @static
* @memberOf _
* @since 2.4.0
* @category Util
* @param {*} value The value to return from the new function.
* @returns {Function} Returns the new constant function.
* @example
*
* var objects = _.times(2, _.constant({ 'a': 1 }));
*
* console.log(objects);
* // => [{ 'a': 1 }, { 'a': 1 }]
*
* console.log(objects[0] === objects[1]);
* // => true
*/
function constant(value) {
return function() {
return value;
};
}
module.exports = constant;