lodash: changed _.every

This commit is contained in:
Ilya Mochalov
2016-02-03 20:17:22 +05:00
parent e69fe60f2d
commit 3d52090ef7
2 changed files with 86 additions and 77 deletions
+63 -41
View File
@@ -3407,52 +3407,68 @@ module TestEachRight {
}
// _.every
module TestEvery {
let array: TResult[];
let list: _.List<TResult>;
let dictionary: _.Dictionary<TResult>;
namespace TestEvery {
type SampleObject = {a: number; b: string; c: boolean;};
let listIterator: (value: TResult, index: number, collection: _.List<TResult>) => boolean;
let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary<TResult>) => boolean;
let array: SampleObject[];
let list: _.List<SampleObject>;
let dictionary: _.Dictionary<SampleObject>;
let numericDictionary: _.NumericDictionary<SampleObject>;
let listIterator: (value: SampleObject, index: number, collection: _.List<SampleObject>) => boolean;
let dictionaryIterator: (value: SampleObject, key: string, collection: _.Dictionary<SampleObject>) => boolean;
let numericDictionaryIterator: (value: SampleObject, key: number, collection: _.NumericDictionary<SampleObject>) => boolean;
{
let result: boolean;
result = _.every<TResult>(array);
result = _.every<TResult>(array, listIterator);
result = _.every<TResult>(array, listIterator, any);
result = _.every<TResult>(array, '');
result = _.every<{a: number}, TResult>(array, {a: 42});
result = _.every<SampleObject>(array);
result = _.every<SampleObject>(array, listIterator);
result = _.every<SampleObject>(array, 'a');
result = _.every<SampleObject>(array, ['a', 42]);
result = _.every<{a: number}, SampleObject>(array, {a: 42});
result = _.every<TResult>(list);
result = _.every<TResult>(list, listIterator);
result = _.every<TResult>(list, listIterator, any);
result = _.every<TResult>(list, '');
result = _.every<{a: number}, TResult>(list, {a: 42});
result = _.every<SampleObject>(list);
result = _.every<SampleObject>(list, listIterator);
result = _.every<SampleObject>(list, 'a');
result = _.every<SampleObject>(list, ['a', 42]);
result = _.every<{a: number}, SampleObject>(list, {a: 42});
result = _.every<TResult>(dictionary);
result = _.every<TResult>(dictionary, dictionaryIterator);
result = _.every<TResult>(dictionary, dictionaryIterator, any);
result = _.every<TResult>(dictionary, '');
result = _.every<{a: number}, TResult>(dictionary, {a: 42});
result = _.every<SampleObject>(dictionary);
result = _.every<SampleObject>(dictionary, dictionaryIterator);
result = _.every<SampleObject>(dictionary, 'a');
result = _.every<SampleObject>(dictionary, ['a', 42]);
result = _.every<{a: number}, SampleObject>(dictionary, {a: 42});
result = _.every<SampleObject>(numericDictionary);
result = _.every<SampleObject>(numericDictionary, numericDictionaryIterator);
result = _.every<SampleObject>(numericDictionary, 'a');
result = _.every<SampleObject>(numericDictionary, ['a', 42]);
result = _.every<{a: number}, SampleObject>(numericDictionary, {a: 42});
result = _(array).every();
result = _(array).every(listIterator);
result = _(array).every(listIterator, any);
result = _(array).every('');
result = _(array).every('a');
result = _(array).every(['a', 42]);
result = _(array).every<{a: number}>({a: 42});
result = _(list).every<TResult>();
result = _(list).every<TResult>(listIterator);
result = _(list).every<TResult>(listIterator, any);
result = _(list).every('');
result = _(list).every<SampleObject>();
result = _(list).every<SampleObject>(listIterator);
result = _(list).every('a');
result = _(list).every(['a', 42]);
result = _(list).every<{a: number}>({a: 42});
result = _(dictionary).every<TResult>();
result = _(dictionary).every<TResult>(dictionaryIterator);
result = _(dictionary).every<TResult>(dictionaryIterator, any);
result = _(dictionary).every('');
result = _(dictionary).every<SampleObject>();
result = _(dictionary).every<SampleObject>(dictionaryIterator);
result = _(dictionary).every('a');
result = _(dictionary).every(['a', 42]);
result = _(dictionary).every<{a: number}>({a: 42});
result = _(numericDictionary).every<SampleObject>();
result = _(numericDictionary).every<SampleObject>(numericDictionaryIterator);
result = _(numericDictionary).every('a');
result = _(numericDictionary).every(['a', 42]);
result = _(numericDictionary).every<{a: number}>({a: 42});
}
{
@@ -3460,21 +3476,27 @@ module TestEvery {
result = _(array).chain().every();
result = _(array).chain().every(listIterator);
result = _(array).chain().every(listIterator, any);
result = _(array).chain().every('');
result = _(array).chain().every('a');
result = _(array).chain().every(['a', 42]);
result = _(array).chain().every<{a: number}>({a: 42});
result = _(list).chain().every<TResult>();
result = _(list).chain().every<TResult>(listIterator);
result = _(list).chain().every<TResult>(listIterator, any);
result = _(list).chain().every('');
result = _(list).chain().every<SampleObject>();
result = _(list).chain().every<SampleObject>(listIterator);
result = _(list).chain().every('a');
result = _(list).chain().every(['a', 42]);
result = _(list).chain().every<{a: number}>({a: 42});
result = _(dictionary).chain().every<TResult>();
result = _(dictionary).chain().every<TResult>(dictionaryIterator);
result = _(dictionary).chain().every<TResult>(dictionaryIterator, any);
result = _(dictionary).chain().every('');
result = _(dictionary).chain().every<SampleObject>();
result = _(dictionary).chain().every<SampleObject>(dictionaryIterator);
result = _(dictionary).chain().every('a');
result = _(dictionary).chain().every(['a', 42]);
result = _(dictionary).chain().every<{a: number}>({a: 42});
result = _(numericDictionary).chain().every<SampleObject>();
result = _(numericDictionary).chain().every<SampleObject>(numericDictionaryIterator);
result = _(numericDictionary).chain().every('a');
result = _(numericDictionary).chain().every(['a', 42]);
result = _(numericDictionary).chain().every<{a: number}>({a: 42});
}
}
+23 -36
View File
@@ -6049,27 +6049,16 @@ declare module _ {
//_.every
interface LoDashStatic {
/**
* Checks if predicate returns truthy for all elements of 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.
* Checks if predicate returns truthy for all elements of collection. Iteration is stopped once predicate
* returns falsey. The predicate is invoked with three arguments: (value, index|key, collection).
*
* @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 all elements pass the predicate check, else false.
*/
every<T>(
collection: List<T>,
predicate?: ListIterator<T, boolean>,
thisArg?: any
predicate?: ListIterator<T, boolean>
): boolean;
/**
@@ -6077,24 +6066,30 @@ declare module _ {
*/
every<T>(
collection: Dictionary<T>,
predicate?: DictionaryIterator<T, boolean>,
thisArg?: any
predicate?: DictionaryIterator<T, boolean>
): boolean;
/**
* @see _.every
*/
every<T>(
collection: List<T>|Dictionary<T>,
predicate?: string,
thisArg?: any
collection: NumericDictionary<T>,
predicate?: NumericDictionaryIterator<T, boolean>
): boolean;
/**
* @see _.every
*/
every<T>(
collection: List<T>|Dictionary<T>|NumericDictionary<T>,
predicate?: string|any[]
): boolean;
/**
* @see _.every
*/
every<TObject extends {}, T>(
collection: List<T>|Dictionary<T>,
collection: List<T>|Dictionary<T>|NumericDictionary<T>,
predicate?: TObject
): boolean;
}
@@ -6104,16 +6099,14 @@ declare module _ {
* @see _.every
*/
every(
predicate?: ListIterator<T, boolean>,
thisArg?: any
predicate?: ListIterator<T, boolean>|NumericDictionaryIterator<T, boolean>
): boolean;
/**
* @see _.every
*/
every(
predicate?: string,
thisArg?: any
predicate?: string|any[]
): boolean;
/**
@@ -6129,16 +6122,14 @@ declare module _ {
* @see _.every
*/
every<TResult>(
predicate?: ListIterator<TResult, boolean>|DictionaryIterator<TResult, boolean>,
thisArg?: any
predicate?: ListIterator<TResult, boolean>|DictionaryIterator<TResult, boolean>|NumericDictionaryIterator<T, boolean>
): boolean;
/**
* @see _.every
*/
every(
predicate?: string,
thisArg?: any
predicate?: string|any[]
): boolean;
/**
@@ -6154,16 +6145,14 @@ declare module _ {
* @see _.every
*/
every(
predicate?: ListIterator<T, boolean>,
thisArg?: any
predicate?: ListIterator<T, boolean>|NumericDictionaryIterator<T, boolean>
): LoDashExplicitWrapper<boolean>;
/**
* @see _.every
*/
every(
predicate?: string,
thisArg?: any
predicate?: string|any[]
): LoDashExplicitWrapper<boolean>;
/**
@@ -6179,16 +6168,14 @@ declare module _ {
* @see _.every
*/
every<TResult>(
predicate?: ListIterator<TResult, boolean>|DictionaryIterator<TResult, boolean>,
thisArg?: any
predicate?: ListIterator<TResult, boolean>|DictionaryIterator<TResult, boolean>|NumericDictionaryIterator<T, boolean>
): LoDashExplicitWrapper<boolean>;
/**
* @see _.every
*/
every(
predicate?: string,
thisArg?: any
predicate?: string|any[]
): LoDashExplicitWrapper<boolean>;
/**