mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-25 11:11:46 +08:00
lodash: changed signatures of the method _.some (and alias _.any)
This commit is contained in:
+94
-8
@@ -961,6 +961,54 @@ module TestAll {
|
||||
result = _(dictionary).all<{a: number}>({a: 42});
|
||||
}
|
||||
|
||||
// _.any
|
||||
module TestAny {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
let dictionary: _.Dictionary<TResult>;
|
||||
|
||||
let listIterator: (value: TResult, index: number, collection: _.List<TResult>) => boolean;
|
||||
let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary<TResult>) => boolean;
|
||||
|
||||
let result: boolean;
|
||||
|
||||
result = _.any<TResult>(array);
|
||||
result = _.any<TResult>(array, listIterator);
|
||||
result = _.any<TResult>(array, listIterator, any);
|
||||
result = _.any<TResult>(array, '');
|
||||
result = _.any<{a: number}, TResult>(array, {a: 42});
|
||||
|
||||
result = _.any<TResult>(list);
|
||||
result = _.any<TResult>(list, listIterator);
|
||||
result = _.any<TResult>(list, listIterator, any);
|
||||
result = _.any<TResult>(list, '');
|
||||
result = _.any<{a: number}, TResult>(list, {a: 42});
|
||||
|
||||
result = _.any<TResult>(dictionary);
|
||||
result = _.any<TResult>(dictionary, dictionaryIterator);
|
||||
result = _.any<TResult>(dictionary, dictionaryIterator, any);
|
||||
result = _.any<TResult>(dictionary, '');
|
||||
result = _.any<{a: number}, TResult>(dictionary, {a: 42});
|
||||
|
||||
result = _(array).any();
|
||||
result = _(array).any(listIterator);
|
||||
result = _(array).any(listIterator, any);
|
||||
result = _(array).any('');
|
||||
result = _(array).any<{a: number}>({a: 42});
|
||||
|
||||
result = _(list).any<TResult>();
|
||||
result = _(list).any<TResult>(listIterator);
|
||||
result = _(list).any<TResult>(listIterator, any);
|
||||
result = _(list).any('');
|
||||
result = _(list).any<{a: number}>({a: 42});
|
||||
|
||||
result = _(dictionary).any<TResult>();
|
||||
result = _(dictionary).any<TResult>(dictionaryIterator);
|
||||
result = _(dictionary).any<TResult>(dictionaryIterator, any);
|
||||
result = _(dictionary).any('');
|
||||
result = _(dictionary).any<{a: number}>({a: 42});
|
||||
}
|
||||
|
||||
// _.at
|
||||
{
|
||||
let testAtArray: TResult[];
|
||||
@@ -1448,15 +1496,53 @@ result = <number>_.size({ 'one': 1, 'two': 2, 'three': 3 });
|
||||
result = <number>_({ 'one': 1, 'two': 2, 'three': 3 }).size();
|
||||
result = <number>_.size('curly');
|
||||
|
||||
result = <boolean>_.some([null, 0, 'yes', false], Boolean);
|
||||
result = <boolean>_.some(foodsCombined, 'organic');
|
||||
result = <boolean>_.some(foodsCombined, { 'type': 'meat' });
|
||||
result = <boolean>_.some(foodsOrganic[0]);
|
||||
// _.some
|
||||
module TestSome {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
let dictionary: _.Dictionary<TResult>;
|
||||
|
||||
result = <boolean>_.any([null, 0, 'yes', false], Boolean);
|
||||
result = <boolean>_.any(foodsCombined, 'organic');
|
||||
result = <boolean>_.any(foodsCombined, { 'type': 'meat' });
|
||||
result = <boolean>_.any(foodsOrganic[0]);
|
||||
let listIterator: (value: TResult, index: number, collection: _.List<TResult>) => boolean;
|
||||
let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary<TResult>) => boolean;
|
||||
|
||||
let result: boolean;
|
||||
|
||||
result = _.some<TResult>(array);
|
||||
result = _.some<TResult>(array, listIterator);
|
||||
result = _.some<TResult>(array, listIterator, any);
|
||||
result = _.some<TResult>(array, '');
|
||||
result = _.some<{a: number}, TResult>(array, {a: 42});
|
||||
|
||||
result = _.some<TResult>(list);
|
||||
result = _.some<TResult>(list, listIterator);
|
||||
result = _.some<TResult>(list, listIterator, any);
|
||||
result = _.some<TResult>(list, '');
|
||||
result = _.some<{a: number}, TResult>(list, {a: 42});
|
||||
|
||||
result = _.some<TResult>(dictionary);
|
||||
result = _.some<TResult>(dictionary, dictionaryIterator);
|
||||
result = _.some<TResult>(dictionary, dictionaryIterator, any);
|
||||
result = _.some<TResult>(dictionary, '');
|
||||
result = _.some<{a: number}, TResult>(dictionary, {a: 42});
|
||||
|
||||
result = _(array).some();
|
||||
result = _(array).some(listIterator);
|
||||
result = _(array).some(listIterator, any);
|
||||
result = _(array).some('');
|
||||
result = _(array).some<{a: number}>({a: 42});
|
||||
|
||||
result = _(list).some<TResult>();
|
||||
result = _(list).some<TResult>(listIterator);
|
||||
result = _(list).some<TResult>(listIterator, any);
|
||||
result = _(list).some('');
|
||||
result = _(list).some<{a: number}>({a: 42});
|
||||
|
||||
result = _(dictionary).some<TResult>();
|
||||
result = _(dictionary).some<TResult>(dictionaryIterator);
|
||||
result = _(dictionary).some<TResult>(dictionaryIterator, any);
|
||||
result = _(dictionary).some('');
|
||||
result = _(dictionary).some<{a: number}>({a: 42});
|
||||
}
|
||||
|
||||
result = <number[]>_.sortBy([1, 2, 3], function (num) { return Math.sin(num); });
|
||||
result = <number[]>_.sortBy([1, 2, 3], function (num) { return this.sin(num); }, Math);
|
||||
|
||||
Vendored
+174
-155
@@ -2419,6 +2419,94 @@ declare module _ {
|
||||
): boolean;
|
||||
}
|
||||
|
||||
//_.any
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
any<T>(
|
||||
collection: List<T>,
|
||||
predicate?: ListIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
any<T>(
|
||||
collection: Dictionary<T>,
|
||||
predicate?: DictionaryIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
any<T>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
predicate?: string,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
any<TObject extends {}, T>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
predicate?: TObject
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
any(
|
||||
predicate?: ListIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
any(
|
||||
predicate?: string,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
any<TObject extends {}>(
|
||||
predicate?: TObject
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
any<TResult>(
|
||||
predicate?: ListIterator<TResult, boolean>|DictionaryIterator<TResult, boolean>,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
any(
|
||||
predicate?: string,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
any<TObject extends {}>(
|
||||
predicate?: TObject
|
||||
): boolean;
|
||||
}
|
||||
|
||||
//_.at
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
@@ -5283,176 +5371,107 @@ declare module _ {
|
||||
//_.some
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Checks if the callback returns a truey value for any element of a collection. The function
|
||||
* returns as soon as it finds a passing value and does not iterate over the entire collection.
|
||||
* The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).
|
||||
*
|
||||
* If a property name is provided for callback the created "_.pluck" style callback will return
|
||||
* the property value of the given element.
|
||||
*
|
||||
* If an object is provided for callback the created "_.where" style callback will return true for
|
||||
* elements that have the properties of the given object, else false.
|
||||
* @param collection The collection to iterate over.
|
||||
* @param callback The function called per iteration.
|
||||
* @param thisArg The this binding of callback.
|
||||
* @return True if any element passed the callback check, else false.
|
||||
**/
|
||||
some<T>(
|
||||
collection: Array<T>,
|
||||
callback?: ListIterator<T, boolean>,
|
||||
thisArg?: any): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
**/
|
||||
* Checks if predicate returns truthy for any element of collection. The function returns as soon as it finds
|
||||
* a passing value and does not iterate over the entire collection. The predicate is bound to thisArg and
|
||||
* invoked with three arguments: (value, index|key, collection).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @alias _.any
|
||||
*
|
||||
* @param collection The collection to iterate over.
|
||||
* @param predicate The function invoked per iteration.
|
||||
* @param thisArg The this binding of predicate.
|
||||
* @return Returns true if any element passes the predicate check, else false.
|
||||
*/
|
||||
some<T>(
|
||||
collection: List<T>,
|
||||
callback?: ListIterator<T, boolean>,
|
||||
thisArg?: any): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
**/
|
||||
some<T>(
|
||||
collection: Dictionary<T>,
|
||||
callback?: DictionaryIterator<T, boolean>,
|
||||
thisArg?: any): boolean;
|
||||
predicate?: ListIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
**/
|
||||
*/
|
||||
some<T>(
|
||||
collection: Dictionary<T>,
|
||||
predicate?: DictionaryIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
some<T>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
predicate?: string,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
some<TObject extends {}, T>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
predicate?: TObject
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
some(
|
||||
collection: {},
|
||||
callback?: ListIterator<{}, boolean>,
|
||||
thisArg?: any): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
some<T>(
|
||||
collection: Array<T>,
|
||||
pluckValue: string): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
some<T>(
|
||||
collection: List<T>,
|
||||
pluckValue: string): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
some<T>(
|
||||
collection: Dictionary<T>,
|
||||
pluckValue: string): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
some<W, T>(
|
||||
collection: Array<T>,
|
||||
whereValue: W): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
some<W, T>(
|
||||
collection: List<T>,
|
||||
whereValue: W): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
some<W, T>(
|
||||
collection: Dictionary<T>,
|
||||
whereValue: W): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
**/
|
||||
any<T>(
|
||||
collection: Array<T>,
|
||||
callback?: ListIterator<T, boolean>,
|
||||
thisArg?: any): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
**/
|
||||
any<T>(
|
||||
collection: List<T>,
|
||||
callback?: ListIterator<T, boolean>,
|
||||
thisArg?: any): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
**/
|
||||
any<T>(
|
||||
collection: Dictionary<T>,
|
||||
callback?: DictionaryIterator<T, boolean>,
|
||||
thisArg?: any): boolean;
|
||||
predicate?: ListIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
**/
|
||||
any(
|
||||
collection: {},
|
||||
callback?: ListIterator<{}, boolean>,
|
||||
thisArg?: any): boolean;
|
||||
*/
|
||||
some(
|
||||
predicate?: string,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
any<T>(
|
||||
collection: Array<T>,
|
||||
pluckValue: string): boolean;
|
||||
* @see _.some
|
||||
*/
|
||||
some<TObject extends {}>(
|
||||
predicate?: TObject
|
||||
): boolean;
|
||||
}
|
||||
|
||||
interface LoDashObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
some<TResult>(
|
||||
predicate?: ListIterator<TResult, boolean>|DictionaryIterator<TResult, boolean>,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
any<T>(
|
||||
collection: List<T>,
|
||||
pluckValue: string): boolean;
|
||||
* @see _.some
|
||||
*/
|
||||
some(
|
||||
predicate?: string,
|
||||
thisArg?: any
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
any<T>(
|
||||
collection: Dictionary<T>,
|
||||
pluckValue: string): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
any<W, T>(
|
||||
collection: Array<T>,
|
||||
whereValue: W): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
any<W, T>(
|
||||
collection: List<T>,
|
||||
whereValue: W): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
any<W, T>(
|
||||
collection: Dictionary<T>,
|
||||
whereValue: W): boolean;
|
||||
* @see _.some
|
||||
*/
|
||||
some<TObject extends {}>(
|
||||
predicate?: TObject
|
||||
): boolean;
|
||||
}
|
||||
|
||||
//_.sortBy
|
||||
|
||||
Reference in New Issue
Block a user