diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 8be3a0ef0..6a8349a67 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -240,6 +240,42 @@ module TestDropRight { result = _(list).dropRight(42).value(); } +// _.dropWhile +module TestDropWhile { + let array: TResult[]; + let list: _.List; + let predicateFn: (value: TResult, index: number, collection: _.List) => boolean; + let result: TResult[]; + + result = _.dropWhile(array); + result = _.dropWhile(array, predicateFn); + result = _.dropWhile(array, predicateFn, any); + 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, '', any); + result = _.dropWhile<{a: number;}, TResult>(list, {a: 42}); + + result = _(array).dropWhile().value(); + result = _(array).dropWhile(predicateFn).value(); + result = _(array).dropWhile(predicateFn, any).value(); + result = _(array).dropWhile('').value(); + result = _(array).dropWhile('', any).value(); + result = _(array).dropWhile<{a: number;}>({a: 42}).value(); + + result = _(list).dropWhile().value(); + result = _(list).dropWhile(predicateFn).value(); + result = _(list).dropWhile(predicateFn, any).value(); + result = _(list).dropWhile('').value(); + result = _(list).dropWhile('', any).value(); + result = _(list).dropWhile<{a: number;}, TResult>({a: 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 e18e5f6b3..a81bbfc78 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -457,6 +457,100 @@ declare module _ { dropRight(n?: number): LoDashArrayWrapper; } + //_.dropWhile + interface LoDashStatic { + /** + * Creates a slice of array excluding elements dropped from the beginning. 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 + * have 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. + */ + dropWhile( + array: List, + predicate?: ListIterator, + thisArg?: any + ): TValue[]; + + /** + * @see _.dropWhile + */ + dropWhile( + array: List, + predicate?: string, + thisArg?: any + ): TValue[]; + + /** + * @see _.dropWhile + */ + dropWhile( + array: List, + predicate?: TWhere + ): TValue[]; + } + + interface LoDashArrayWrapper { + /** + * @see _.dropWhile + */ + dropWhile( + predicate?: ListIterator, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.dropWhile + */ + dropWhile( + predicate?: string, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.dropWhile + */ + dropWhile( + predicate?: TWhere + ): LoDashArrayWrapper; + } + + interface LoDashObjectWrapper { + /** + * @see _.dropWhile + */ + dropWhile( + predicate?: ListIterator, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.dropWhile + */ + dropWhile( + predicate?: string, + thisArg?: any + ): LoDashArrayWrapper; + + /** + * @see _.dropWhile + */ + dropWhile( + predicate?: TWhere + ): LoDashArrayWrapper; + } + //_.findIndex interface LoDashStatic { /**