UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

32 lines (31 loc) 647 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.constant = void 0; /** * Creates a function that returns `value`. * * * * @since 5.0.0 * @category Util * @param value The value to return from the new function. * @returns Returns the new constant function. * @example * * ```js * 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; }; } exports.constant = constant; exports.default = constant;