lodash: added _.dropRight() method

This commit is contained in:
Ilya Mochalov 2015-09-21 02:05:22 +05:00
parent 54f064352a
commit edaac0e687
2 changed files with 44 additions and 0 deletions

View File

@ -208,6 +208,21 @@ result = <_.LoDashArrayWrapper<any>>_([0, 1, false, 2, '', 3]).compact();
result = _(testDropList).drop<TResult>(42).value();
}
// _.dropRight
module TestDropRight {
let array: TResult[];
let list: _.List<TResult>;
let result: TResult[];
result = _.dropRight<TResult>(array);
result = _.dropRight<TResult>(array, 42);
result = _.dropRight<TResult>(list);
result = _.dropRight<TResult>(list, 42);
result = _(array).dropRight().value();
result = _(array).dropRight(42).value();
result = _(list).dropRight<TResult>().value();
result = _(list).dropRight<TResult>(42).value();
}
result = <number[]>_.rest([1, 2, 3]);
result = <number[]>_.rest([1, 2, 3], 2);
result = <number[]>_.rest([1, 2, 3], (num) => num < 3)

29
lodash/lodash.d.ts vendored
View File

@ -419,6 +419,35 @@ declare module _ {
drop<TResult>(n?: number): LoDashArrayWrapper<TResult>;
}
//_.dropRight
interface LoDashStatic {
/**
* Creates a slice of array with n elements dropped from the end.
*
* @param array The array to query.
* @param n The number of elements to drop.
* @return Returns the slice of array.
*/
dropRight<T>(
array: List<T>,
n?: number
): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.dropRight
*/
dropRight(n?: number): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.dropRight
*/
dropRight<TResult>(n?: number): LoDashArrayWrapper<TResult>;
}
//_.findIndex
interface LoDashStatic {
/**