From 96c613b2cf23ce77524222ada3554b1c1f851bc0 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Thu, 8 Oct 2015 06:45:14 +0500 Subject: [PATCH] lodash: added signatures of the method _.dropRightWhile --- lodash/lodash-tests.ts | 48 ++++++++++++++++++--- lodash/lodash.d.ts | 94 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+), 6 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index db15ebc4a..fdc0016e4 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -240,6 +240,42 @@ module TestDropRight { result = _(list).dropRight(42).value(); } +// _.dropRightWhile +module TestDropRightWhile { + let array: TResult[]; + let list: _.List; + let predicateFn: (value: TResult, index: number, collection: _.List) => boolean; + let result: TResult[]; + + result = _.dropRightWhile(array); + result = _.dropRightWhile(array, predicateFn); + result = _.dropRightWhile(array, predicateFn, any); + result = _.dropRightWhile(array, ''); + result = _.dropRightWhile(array, '', any); + result = _.dropRightWhile<{a: number;}, TResult>(array, {a: 42}); + + result = _.dropRightWhile(list); + result = _.dropRightWhile(list, predicateFn); + result = _.dropRightWhile(list, predicateFn, any); + result = _.dropRightWhile(list, ''); + result = _.dropRightWhile(list, '', any); + result = _.dropRightWhile<{a: number;}, TResult>(list, {a: 42}); + + result = _(array).dropRightWhile().value(); + result = _(array).dropRightWhile(predicateFn).value(); + result = _(array).dropRightWhile(predicateFn, any).value(); + result = _(array).dropRightWhile('').value(); + result = _(array).dropRightWhile('', any).value(); + result = _(array).dropRightWhile<{a: number;}>({a: 42}).value(); + + result = _(list).dropRightWhile().value(); + result = _(list).dropRightWhile(predicateFn).value(); + result = _(list).dropRightWhile(predicateFn, any).value(); + result = _(list).dropRightWhile('').value(); + result = _(list).dropRightWhile('', any).value(); + result = _(list).dropRightWhile<{a: number;}, TResult>({a: 42}).value(); +} + // _.dropWhile module TestDropWhile { let array: TResult[]; @@ -250,14 +286,14 @@ module TestDropWhile { result = _.dropWhile(array); result = _.dropWhile(array, predicateFn); result = _.dropWhile(array, predicateFn, any); - result = _.dropWhile(array, '') + result = _.dropWhile(array, ''); result = _.dropWhile(array, '', any); result = _.dropWhile<{a: number;}, TResult>(array, {a: 42}); result = _.dropWhile(list); result = _.dropWhile(list, predicateFn); result = _.dropWhile(list, predicateFn, any); - result = _.dropWhile(list, '') + result = _.dropWhile(list, ''); result = _.dropWhile(list, '', any); result = _.dropWhile<{a: number;}, TResult>(list, {a: 42}); @@ -648,14 +684,14 @@ module TestTakeRightWhile { result = _.takeRightWhile(array); result = _.takeRightWhile(array, predicateFn); result = _.takeRightWhile(array, predicateFn, any); - result = _.takeRightWhile(array, '') + result = _.takeRightWhile(array, ''); result = _.takeRightWhile(array, '', any); result = _.takeRightWhile<{a: number;}, TResult>(array, {a: 42}); result = _.takeRightWhile(list); result = _.takeRightWhile(list, predicateFn); result = _.takeRightWhile(list, predicateFn, any); - result = _.takeRightWhile(list, '') + result = _.takeRightWhile(list, ''); result = _.takeRightWhile(list, '', any); result = _.takeRightWhile<{a: number;}, TResult>(list, {a: 42}); @@ -684,14 +720,14 @@ module TestTakeWhile { result = _.takeWhile(array); result = _.takeWhile(array, predicateFn); result = _.takeWhile(array, predicateFn, any); - result = _.takeWhile(array, '') + result = _.takeWhile(array, ''); result = _.takeWhile(array, '', any); result = _.takeWhile<{a: number;}, TResult>(array, {a: 42}); result = _.takeWhile(list); result = _.takeWhile(list, predicateFn); result = _.takeWhile(list, predicateFn, any); - result = _.takeWhile(list, '') + result = _.takeWhile(list, ''); result = _.takeWhile(list, '', any); result = _.takeWhile<{a: number;}, TResult>(list, {a: 42}); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 5a3e0df9e..dd084788e 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -457,6 +457,100 @@ declare module _ { dropRight(n?: number): LoDashArrayWrapper; } + //_.dropRightWhile + interface LoDashStatic { + /** + * Creates a slice of array excluding elements dropped from the end. Elements are dropped until predicate + * returns falsey. The predicate is bound to thisArg and invoked with three arguments: (value, index, array). + * + * If a property name is provided for predicate the created _.property style callback returns the property + * value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for + * elements that have a matching property value, else false. + * + * If an object is provided for predicate the created _.matches style callback returns true for elements that + * match the properties of the given object, else false. + * + * @param array The array to query. + * @param predicate The function invoked per iteration. + * @param thisArg The this binding of predicate. + * @return Returns the slice of array. + */ + dropRightWhile( + array: List, + predicate?: ListIterator, + thisArg?: any + ): TValue[]; + + /** + * @see _.dropRightWhile + */ + dropRightWhile( + array: List, + predicate?: string, + thisArg?: any + ): TValue[]; + + /** + * @see _.dropRightWhile + */ + dropRightWhile( + array: List, + predicate?: TWhere + ): TValue[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.dropRightWhile + */ + dropRightWhile( + predicate?: ListIterator, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.dropRightWhile + */ + dropRightWhile( + predicate?: string, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.dropRightWhile + */ + dropRightWhile( + predicate?: TWhere + ): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.dropRightWhile + */ + dropRightWhile( + predicate?: ListIterator, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.dropRightWhile + */ + dropRightWhile( + predicate?: string, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.dropRightWhile + */ + dropRightWhile( + predicate?: TWhere + ): LoDashArrayWrapper; + } + //_.dropWhile interface LoDashStatic { /**