From e0bd145548a91ef60c717e55ced7983841bf2c9c Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Sun, 20 Sep 2015 04:17:13 +0500 Subject: [PATCH] lodash: added _.takeRight() method --- lodash/lodash-tests.ts | 15 +++++++++++++++ lodash/lodash.d.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index fc36241c58..cf1bdaf6fc 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -327,6 +327,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 db2405580a..45f4804245 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1487,6 +1487,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 { /**