mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-23 11:50:15 +08:00
Merge pull request #6761 from chrootsu/lodash-reject
lodash: signatures of the method _.reject have been changed
This commit is contained in:
+96
-6
@@ -3574,13 +3574,103 @@ result = <ABC>_({ 'a': 1, 'b': 2, 'c': 3 }).inject<number, ABC>(function (r: ABC
|
||||
result = <number[]>_.reduceRight([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, <number[]>[]);
|
||||
result = <number[]>_.foldr([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, <number[]>[]);
|
||||
|
||||
result = <number[]>_.reject([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; });
|
||||
result = <IFoodCombined[]>_.reject(foodsCombined, 'organic');
|
||||
result = <IFoodCombined[]>_.reject(foodsCombined, { 'type': 'fruit' });
|
||||
// _.reject
|
||||
module TestReject {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
let dictionary: _.Dictionary<TResult>;
|
||||
|
||||
result = <number[]>_([1, 2, 3, 4, 5, 6]).reject(function (num) { return num % 2 == 0; }).value();
|
||||
result = <IFoodCombined[]>_(foodsCombined).reject('organic').value();
|
||||
result = <IFoodCombined[]>_(foodsCombined).reject({ 'type': 'fruit' }).value();
|
||||
let stringIterator: (char: string, index: number, string: string) => any;
|
||||
let listIterator: (value: TResult, index: number, collection: _.List<TResult>) => any;
|
||||
let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary<TResult>) => any;
|
||||
|
||||
{
|
||||
let result: string[];
|
||||
|
||||
result = _.reject('', stringIterator);
|
||||
result = _.reject('', stringIterator, any);
|
||||
}
|
||||
|
||||
{
|
||||
let result: TResult[];
|
||||
|
||||
result = _.reject<TResult>(array, listIterator);
|
||||
result = _.reject<TResult>(array, listIterator, any);
|
||||
result = _.reject<TResult>(array, '');
|
||||
result = _.reject<TResult>(array, '', any);
|
||||
result = _.reject<{a: number}, TResult>(array, {a: 42});
|
||||
|
||||
result = _.reject<TResult>(list, listIterator);
|
||||
result = _.reject<TResult>(list, listIterator, any);
|
||||
result = _.reject<TResult>(list, '');
|
||||
result = _.reject<TResult>(list, '', any);
|
||||
result = _.reject<{a: number}, TResult>(list, {a: 42});
|
||||
|
||||
result = _.reject<TResult>(dictionary, dictionaryIterator);
|
||||
result = _.reject<TResult>(dictionary, dictionaryIterator, any);
|
||||
result = _.reject<TResult>(dictionary, '');
|
||||
result = _.reject<TResult>(dictionary, '', any);
|
||||
result = _.reject<{a: number}, TResult>(dictionary, {a: 42});
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitArrayWrapper<string>;
|
||||
|
||||
result = _('').reject(stringIterator);
|
||||
result = _('').reject(stringIterator, any);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).reject(listIterator);
|
||||
result = _(array).reject(listIterator, any);
|
||||
result = _(array).reject('');
|
||||
result = _(array).reject('', any);
|
||||
result = _(array).reject<{a: number}>({a: 42});
|
||||
|
||||
result = _(list).reject<TResult>(listIterator);
|
||||
result = _(list).reject<TResult>(listIterator, any);
|
||||
result = _(list).reject<TResult>('');
|
||||
result = _(list).reject<TResult>('', any);
|
||||
result = _(list).reject<{a: number}, TResult>({a: 42});
|
||||
|
||||
result = _(dictionary).reject<TResult>(dictionaryIterator);
|
||||
result = _(dictionary).reject<TResult>(dictionaryIterator, any);
|
||||
result = _(dictionary).reject<TResult>('');
|
||||
result = _(dictionary).reject<TResult>('', any);
|
||||
result = _(dictionary).reject<{a: number}, TResult>({a: 42});
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitArrayWrapper<string>;
|
||||
|
||||
result = _('').chain().reject(stringIterator);
|
||||
result = _('').chain().reject(stringIterator, any);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).chain().reject(listIterator);
|
||||
result = _(array).chain().reject(listIterator, any);
|
||||
result = _(array).chain().reject('');
|
||||
result = _(array).chain().reject('', any);
|
||||
result = _(array).chain().reject<{a: number}>({a: 42});
|
||||
|
||||
result = _(list).chain().reject<TResult>(listIterator);
|
||||
result = _(list).chain().reject<TResult>(listIterator, any);
|
||||
result = _(list).chain().reject<TResult>('');
|
||||
result = _(list).chain().reject<TResult>('', any);
|
||||
result = _(list).chain().reject<{a: number}, TResult>({a: 42});
|
||||
|
||||
result = _(dictionary).chain().reject<TResult>(dictionaryIterator);
|
||||
result = _(dictionary).chain().reject<TResult>(dictionaryIterator, any);
|
||||
result = _(dictionary).chain().reject<TResult>('');
|
||||
result = _(dictionary).chain().reject<TResult>('', any);
|
||||
result = _(dictionary).chain().reject<{a: number}, TResult>({a: 42});
|
||||
}
|
||||
}
|
||||
|
||||
result = <number>_.sample([1, 2, 3, 4]);
|
||||
result = <number[]>_.sample([1, 2, 3, 4], 2);
|
||||
|
||||
Vendored
+138
-80
@@ -6431,108 +6431,166 @@ declare module _ {
|
||||
//_.reject
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* The opposite of _.filter this method returns the elements of a collection that
|
||||
* the callback does not return truey for.
|
||||
*
|
||||
* 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 A new array of elements that failed the callback check.
|
||||
**/
|
||||
reject<T>(
|
||||
collection: Array<T>,
|
||||
callback: ListIterator<T, boolean>,
|
||||
thisArg?: any): T[];
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
**/
|
||||
* The opposite of _.filter; this method returns the elements of collection that predicate does not return
|
||||
* truthy for.
|
||||
*
|
||||
* @param collection The collection to iterate over.
|
||||
* @param predicate The function invoked per iteration.
|
||||
* @param thisArg The this binding of predicate.
|
||||
* @return Returns the new filtered array.
|
||||
*/
|
||||
reject<T>(
|
||||
collection: List<T>,
|
||||
callback: ListIterator<T, boolean>,
|
||||
thisArg?: any): T[];
|
||||
predicate?: ListIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
**/
|
||||
* @see _.reject
|
||||
*/
|
||||
reject<T>(
|
||||
collection: Dictionary<T>,
|
||||
callback: DictionaryIterator<T, boolean>,
|
||||
thisArg?: any): T[];
|
||||
predicate?: DictionaryIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
* @see _.reject
|
||||
*/
|
||||
reject(
|
||||
collection: string,
|
||||
predicate?: StringIterator<boolean>,
|
||||
thisArg?: any
|
||||
): string[];
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
*/
|
||||
reject<T>(
|
||||
collection: Array<T>,
|
||||
pluckValue: string): T[];
|
||||
collection: List<T>|Dictionary<T>,
|
||||
predicate: string,
|
||||
thisArg?: any
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
reject<T>(
|
||||
collection: List<T>,
|
||||
pluckValue: string): T[];
|
||||
* @see _.reject
|
||||
*/
|
||||
reject<W extends {}, T>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
predicate: W
|
||||
): T[];
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.reject
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
reject<T>(
|
||||
collection: Dictionary<T>,
|
||||
pluckValue: string): T[];
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
reject<W, T>(
|
||||
collection: Array<T>,
|
||||
whereValue: W): T[];
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
reject<W, T>(
|
||||
collection: List<T>,
|
||||
whereValue: W): T[];
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
reject<W, T>(
|
||||
collection: Dictionary<T>,
|
||||
whereValue: W): T[];
|
||||
* @see _.reject
|
||||
*/
|
||||
reject(
|
||||
predicate?: StringIterator<boolean>,
|
||||
thisArg?: any
|
||||
): LoDashImplicitArrayWrapper<string>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.reject
|
||||
**/
|
||||
* @see _.reject
|
||||
*/
|
||||
reject(
|
||||
callback: ListIterator<T, boolean>,
|
||||
thisArg?: any): LoDashImplicitArrayWrapper<T>;
|
||||
predicate: ListIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
reject(pluckValue: string): LoDashImplicitArrayWrapper<T>;
|
||||
* @see _.reject
|
||||
*/
|
||||
reject(
|
||||
predicate: string,
|
||||
thisArg?: any
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
reject<W>(whereValue: W): LoDashImplicitArrayWrapper<T>;
|
||||
* @see _.reject
|
||||
*/
|
||||
reject<W>(predicate: W): LoDashImplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.reject
|
||||
*/
|
||||
reject<T>(
|
||||
predicate: ListIterator<T, boolean>|DictionaryIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
*/
|
||||
reject<T>(
|
||||
predicate: string,
|
||||
thisArg?: any
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
*/
|
||||
reject<W, T>(predicate: W): LoDashImplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.reject
|
||||
*/
|
||||
reject(
|
||||
predicate?: StringIterator<boolean>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitArrayWrapper<string>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.reject
|
||||
*/
|
||||
reject(
|
||||
predicate: ListIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
*/
|
||||
reject(
|
||||
predicate: string,
|
||||
thisArg?: any
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
*/
|
||||
reject<W>(predicate: W): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.reject
|
||||
*/
|
||||
reject<T>(
|
||||
predicate: ListIterator<T, boolean>|DictionaryIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
*/
|
||||
reject<T>(
|
||||
predicate: string,
|
||||
thisArg?: any
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
*/
|
||||
reject<W, T>(predicate: W): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
//_.sample
|
||||
|
||||
Reference in New Issue
Block a user