Merge pull request #6054 from chrootsu/lodash-last

lodash: changed _.last() method
This commit is contained in:
Masahiro Wakame
2015-10-05 22:31:08 +09:00
2 changed files with 25 additions and 8 deletions
+11 -2
View File
@@ -357,8 +357,17 @@ module TestIndexOf {
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
@@ -817,20 +817,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 {
/**