mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-15 22:34:55 +08:00
Fix 'every' and 'all' definitions for underscore
The underscore documentation shows that the iterator parameter is optional and is implemented that way as well.
This commit is contained in:
@@ -23,6 +23,7 @@ _.where(listOfPlays, { author: "Shakespeare", year: 1611 });
|
||||
var odds = _.reject([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0);
|
||||
|
||||
_.all([true, 1, null, 'yes'], _.identity);
|
||||
_.all([true, 1, null, 'yes']);
|
||||
|
||||
_.any([null, 0, 'yes', false]);
|
||||
|
||||
@@ -266,4 +267,4 @@ template2({ name: "Mustache" });
|
||||
_.template("Using 'with': <%= data.answer %>", { answer: 'no' }, { variable: 'data' });
|
||||
|
||||
|
||||
_(['test', 'test']).pick(['test2', 'test2']);
|
||||
_(['test', 'test']).pick(['test2', 'test2']);
|
||||
|
||||
8
underscore/underscore.d.ts
vendored
8
underscore/underscore.d.ts
vendored
@@ -295,13 +295,13 @@ declare module _ {
|
||||
* Returns true if all of the values in the list pass the iterator truth test. Delegates to the
|
||||
* native method every, if present.
|
||||
* @param list Truth test against all elements within this list.
|
||||
* @param iterator Trust test iterator function for each element in `list`.
|
||||
* @param iterator Trust test iterator function for each element in `list`, optional.
|
||||
* @param context `this` object in `iterator`, optional.
|
||||
* @return True if all elements passed the truth test, otherwise false.
|
||||
**/
|
||||
export function all<T>(
|
||||
list: Collection<T>,
|
||||
iterator: ListIterator<T, boolean>,
|
||||
iterator?: ListIterator<T, boolean>,
|
||||
context?: any): boolean;
|
||||
|
||||
/**
|
||||
@@ -309,7 +309,7 @@ declare module _ {
|
||||
**/
|
||||
export function every<T>(
|
||||
list: Collection<T>,
|
||||
iterator: ListIterator<T, boolean>,
|
||||
iterator?: ListIterator<T, boolean>,
|
||||
context?: any): boolean;
|
||||
|
||||
/**
|
||||
@@ -799,7 +799,7 @@ declare module _ {
|
||||
start: number,
|
||||
stop: number,
|
||||
step?: number): number[];
|
||||
|
||||
|
||||
/**
|
||||
* @see _.range
|
||||
* @param stop Stop here.
|
||||
|
||||
Reference in New Issue
Block a user