From edaac0e687e3237ebd0955077bcf35cff2eae6fc Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 21 Sep 2015 02:05:22 +0500 Subject: [PATCH] lodash: added _.dropRight() 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 8bc80cb683..5528d67cf1 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -208,6 +208,21 @@ result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); result = _(testDropList).drop(42).value(); } +// _.dropRight +module TestDropRight { + let array: TResult[]; + let list: _.List; + let result: TResult[]; + result = _.dropRight(array); + result = _.dropRight(array, 42); + result = _.dropRight(list); + result = _.dropRight(list, 42); + result = _(array).dropRight().value(); + result = _(array).dropRight(42).value(); + result = _(list).dropRight().value(); + result = _(list).dropRight(42).value(); +} + result = _.rest([1, 2, 3]); result = _.rest([1, 2, 3], 2); result = _.rest([1, 2, 3], (num) => num < 3) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 172a250506..f970b13827 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -419,6 +419,35 @@ declare module _ { drop(n?: number): LoDashArrayWrapper; } + //_.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( + array: List, + n?: number + ): T[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.dropRight + */ + dropRight(n?: number): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.dropRight + */ + dropRight(n?: number): LoDashArrayWrapper; + } + //_.findIndex interface LoDashStatic { /**