updeep-remeda/types/constant.d.ts
2019-01-18 19:51:59 -05:00

31 lines
680 B
TypeScript

/**
* Returns a function that always returns the supplied value.
*
* Useful for replacing an object outright rather than merging it.
*
* @memberOf u
*
* @example
* var alwaysFour = u.constant(4);
* expect(alwaysFour(32)).toEqual(4);
*
* @example
* var user = {
* name: 'Mitch',
* favorites: {
* band: 'Nirvana',
* movie: 'The Matrix'
* }
* };
*
* var newFavorites = {
* band: 'Coldplay'
* };
*
* var result = u({ favorites: u.constant(newFavorites) }, user);
*
* expect(result).toEqual({ name: 'Mitch', favorites: { band: 'Coldplay' } });
*/
export declare function constant<A>(value: A): (...args: any[]) => A;
export default constant;