lodash: added _.value aliases (_.run, _.toJSON)

This commit is contained in:
Ilya Mochalov
2015-07-21 14:16:56 +05:00
parent 8f51d25ad3
commit e0167145c3
2 changed files with 21 additions and 15 deletions
+4 -8
View File
@@ -135,15 +135,11 @@ result = <string>_('test').toString();
result = <string>_([1, 2, 3]).toString();
result = <string>_({ 'key1': 'test1', 'key2': 'test2' }).toString();
result = <string>_('test').valueOf();
result = <number[]>_([1, 2, 3]).valueOf();
result = <_.Dictionary<string>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).valueOf();
// _.value (aliases: _.run, _.toJSON, _.valueOf)
result = <string>_('test').value();
result = <number[]>_([1, 2, 3]).value();
result = <_.Dictionary<string>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).value();
result = <_.Dictionary<number>>_({ a: 1, b: 2}).mapValues(function(num: number) { return num * 2; }).value();
result = <number[]>_([1, 2, 3]).run();
result = <_.Dictionary<string>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).toJSON();
result = <_.Dictionary<number>>_({ a: 1, b: 2}).mapValues(function(num: number) { return num * 2; }).valueOf();
// /*************
// * Arrays *
+17 -7
View File
@@ -177,15 +177,25 @@ declare module _ {
toString(): string;
/**
* Extracts the wrapped value.
* @return The wrapped value.
**/
valueOf(): T;
/**
* @see valueOf
* Executes the chained sequence to extract the unwrapped value.
* @return Returns the resolved unwrapped value.
**/
value(): T;
/**
* @see _.value
**/
run(): T;
/**
* @see _.value
**/
toJSON(): T;
/**
* @see _.value
**/
valueOf(): T;
}
interface LoDashWrapper<T> extends LoDashWrapperBase<T, LoDashWrapper<T>> { }