lodash: changed _.last() method

This commit is contained in:
Ilya Mochalov
2015-09-29 13:12:16 +05:00
parent ffceea9dd1
commit f0237f4199
2 changed files with 25 additions and 8 deletions
+11 -2
View File
@@ -345,8 +345,17 @@ result = <number>_.indexOf([1, 1, 2, 2, 3, 3], 2, true);
result = _(testIntersectionList).intersection<TResult>(testIntersectionList, testIntersectionArray).value();
}
result = <number>_.last([1, 2, 3]);
result = <number>_([1, 2, 3]).last();
// _.last
module TestLast {
let array: TResult[];
let list: _.List<TResult>;
let result: TResult;
result = _.last<TResult>(array);
result = _.last<TResult>(list);
result = _<TResult>(array).last();
result = _(list).last<TResult>();
}
result = <number>_.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
result = <number>_.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
+14 -6
View File
@@ -872,20 +872,28 @@ declare module _ {
//_.last
interface LoDashStatic {
/**
* Gets the last element of an array.
* @param array The array to query.
* @return Returns the last element of array.
**/
last<T>(array: Array<T>): T;
* Gets the last element of array.
*
* @param array The array to query.
* @return Returns the last element of array.
*/
last<T>(array: List<T>): T;
}
interface LoDashArrayWrapper<T> {
/**
* @see _.last
**/
*/
last(): T;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.last
*/
last<T>(): T;
}
//_.lastIndexOf
interface LoDashStatic {
/**