lodash: changed _.constant() method (added to a chainable wrapper, added tests)

This commit is contained in:
Ilya Mochalov
2015-07-28 16:29:41 +05:00
parent 73e4b46719
commit 155c6de20b
2 changed files with 23 additions and 2 deletions
+12
View File
@@ -1255,6 +1255,18 @@ result = <string[]>_.words('fred, barney, & pebbles', /[^, ]+/g);
* Utilities *
***********/
// _.constant
result = <() => number>_.constant<number>(1);
result = <() => string>_.constant<string>('a');
result = <() => boolean>_.constant<boolean>(true);
result = <() => any[]>_.constant<any[]>([]);
result = <() => {}>_.constant<{}>({});
result = <() => number>_(1).constant<number>();
result = <() => string>_('a').constant<string>();
result = <() => boolean>_(true).constant<boolean>();
result = <() => any[]>_(['a']).constant<any[]>();
result = <() => {}>_({}).constant<{}>();
result = <string>_.VERSION;
result = <_.Support>_.support;
result = <_.TemplateSettings>_.templateSettings;
+11 -2
View File
@@ -6626,11 +6626,20 @@ declare module _ {
//_.constant
interface LoDashStatic {
/**
* Creates a function that returns value..
**/
* Creates a function that returns value.
* @param value The value to return from the new function.
* @return Returns the new function.
*/
constant<T>(value: T): () => T;
}
interface LoDashWrapperBase<T, TWrapper> {
/**
* @see _.constant
*/
constant<TResult>(): () => TResult;
}
//_.create
interface LoDashStatic {
/**