mirror of https://github.com/lukechilds/node.git
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.
24 lines
441 B
24 lines
441 B
10 years ago
|
/**
|
||
|
* Creates a function that returns `value`.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
9 years ago
|
* @category Util
|
||
10 years ago
|
* @param {*} value The value to return from the new function.
|
||
|
* @returns {Function} Returns the new function.
|
||
|
* @example
|
||
|
*
|
||
|
* var object = { 'user': 'fred' };
|
||
|
* var getter = _.constant(object);
|
||
|
*
|
||
|
* getter() === object;
|
||
|
* // => true
|
||
|
*/
|
||
|
function constant(value) {
|
||
|
return function() {
|
||
|
return value;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
module.exports = constant;
|