lodash: added signatures of the method _.dropWhile

This commit is contained in:
Ilya Mochalov
2015-10-07 04:36:06 +05:00
parent a6732bf1c0
commit 6f121ced82
2 changed files with 130 additions and 0 deletions
+36
View File
@@ -240,6 +240,42 @@ module TestDropRight {
result = _(list).dropRight<TResult>(42).value();
}
// _.dropWhile
module TestDropWhile {
let array: TResult[];
let list: _.List<TResult>;
let predicateFn: (value: TResult, index: number, collection: _.List<TResult>) => boolean;
let result: TResult[];
result = _.dropWhile<TResult>(array);
result = _.dropWhile<TResult>(array, predicateFn);
result = _.dropWhile<TResult>(array, predicateFn, any);
result = _.dropWhile<TResult>(array, '')
result = _.dropWhile<TResult>(array, '', any);
result = _.dropWhile<{a: number;}, TResult>(array, {a: 42});
result = _.dropWhile<TResult>(list);
result = _.dropWhile<TResult>(list, predicateFn);
result = _.dropWhile<TResult>(list, predicateFn, any);
result = _.dropWhile<TResult>(list, '')
result = _.dropWhile<TResult>(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<TResult>().value();
result = _(list).dropWhile<TResult>(predicateFn).value();
result = _(list).dropWhile<TResult>(predicateFn, any).value();
result = _(list).dropWhile<TResult>('').value();
result = _(list).dropWhile<TResult>('', any).value();
result = _(list).dropWhile<{a: number;}, TResult>({a: 42}).value();
}
result = <number[]>_.rest([1, 2, 3]);
result = <number[]>_.rest([1, 2, 3], 2);
result = <number[]>_.rest([1, 2, 3], (num) => num < 3)
+94
View File
@@ -457,6 +457,100 @@ declare module _ {
dropRight<TResult>(n?: number): LoDashArrayWrapper<TResult>;
}
//_.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<TValue>(
array: List<TValue>,
predicate?: ListIterator<TValue, boolean>,
thisArg?: any
): TValue[];
/**
* @see _.dropWhile
*/
dropWhile<TValue>(
array: List<TValue>,
predicate?: string,
thisArg?: any
): TValue[];
/**
* @see _.dropWhile
*/
dropWhile<TWhere, TValue>(
array: List<TValue>,
predicate?: TWhere
): TValue[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.dropWhile
*/
dropWhile(
predicate?: ListIterator<T, boolean>,
thisArg?: any
): LoDashArrayWrapper<T>;
/**
* @see _.dropWhile
*/
dropWhile(
predicate?: string,
thisArg?: any
): LoDashArrayWrapper<T>;
/**
* @see _.dropWhile
*/
dropWhile<TWhere>(
predicate?: TWhere
): LoDashArrayWrapper<T>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.dropWhile
*/
dropWhile<TValue>(
predicate?: ListIterator<TValue, boolean>,
thisArg?: any
): LoDashArrayWrapper<TValue>;
/**
* @see _.dropWhile
*/
dropWhile<TValue>(
predicate?: string,
thisArg?: any
): LoDashArrayWrapper<TValue>;
/**
* @see _.dropWhile
*/
dropWhile<TWhere, TValue>(
predicate?: TWhere
): LoDashArrayWrapper<TValue>;
}
//_.findIndex
interface LoDashStatic {
/**