diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index db407ec7a5..2f05d5bc3d 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -428,6 +428,21 @@ result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function return this.wordToNumber[word]; }, sortedIndexDict); +// _.takeRight +{ + let testTakeRightArray: TResult[]; + let testTakeRightList: _.List; + let result: TResult[]; + result = _.takeRight(testTakeRightArray); + result = _.takeRight(testTakeRightArray, 42); + result = _.takeRight(testTakeRightList); + result = _.takeRight(testTakeRightList, 42); + result = _(testTakeRightArray).takeRight().value(); + result = _(testTakeRightArray).takeRight(42).value(); + result = _(testTakeRightList).takeRight().value(); + result = _(testTakeRightList).takeRight(42).value(); +} + result = _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); result = _([1, 2, 3]).union([101, 2, 1, 10], [2, 1]).value(); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index cad3331b7f..ad97c101b2 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1442,6 +1442,35 @@ declare module _ { whereValue: W): number; } + //_.takeRight + interface LoDashStatic { + /** + * Creates a slice of array with n elements taken from the end. + * + * @param array The array to query. + * @param n The number of elements to take. + * @return Returns the slice of array. + */ + takeRight( + array: T[]|List, + n?: number + ): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.takeRight + */ + takeRight(n?: number): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.takeRight + */ + takeRight(n?: number): LoDashArrayWrapper; + } + //_.union interface LoDashStatic { /**