mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
_.reject definitions
This commit is contained in:
+14
-20
@@ -302,11 +302,13 @@ result = <any[]>_.map(stoogesAges, 'name');
|
||||
|
||||
result = <number>_.max([4, 2, 8, 6]);
|
||||
result = <IStoogesAge>_.max(stoogesAges, function(stooge) { return stooge.age; });
|
||||
result = <IStoogesAge>_.max(stooges, 'age');
|
||||
result = <IStoogesAge>_.max(stoogesAges, 'age');
|
||||
|
||||
result = <number>_.min([4, 2, 8, 6]);
|
||||
result = <IStoogesAge>_.min(stoogesAges, function(stooge) { return stooge.age; });
|
||||
result = <IStoogesAge>_.min(stooges, 'age');
|
||||
result = <IStoogesAge>_.min(stoogesAges, 'age');
|
||||
|
||||
result = <string[]>_.pluck(stoogesAges, 'name');
|
||||
|
||||
result = <any>_.reduce([1, 2, 3], function(sum, num) {
|
||||
return sum + num;
|
||||
@@ -336,6 +338,10 @@ result = <any>_.reduceRight([[0, 1], [2, 3], [4, 5]], function(a, b) { return a.
|
||||
|
||||
result = <any>_.foldr([[0, 1], [2, 3], [4, 5]], function(a, b) { return a.concat(b); }, []);
|
||||
|
||||
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' });
|
||||
|
||||
result = <boolean>_.some([null, 0, 'yes', false], Boolean);
|
||||
result = <boolean>_.some(foodsCombined, 'organic');
|
||||
result = <boolean>_.some(foodsCombined, { 'type': 'meat' });
|
||||
@@ -358,27 +364,15 @@ _.where(listOfPlays, { author: "Shakespeare", year: 1611 });
|
||||
|
||||
var odds = _.reject([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0);
|
||||
|
||||
_.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
|
||||
|
||||
var stooges = [{ name: 'moe', age: 40 }, { name: 'larry', age: 50 }, { name: 'curly', age: 60 }];
|
||||
_.pluck(stooges, 'name');
|
||||
|
||||
_.max(stooges, (stooge) => stooge.age);
|
||||
|
||||
_.max([1, 2, 3, 4, 5]);
|
||||
|
||||
var numbers = [10, 5, 100, 2, 1000];
|
||||
_.min(numbers);
|
||||
|
||||
_.sortBy([1, 2, 3, 4, 5, 6], (num) => Math.sin(num));
|
||||
|
||||
|
||||
_.indexBy(stooges, 'age')['40'].age;
|
||||
_(stooges).indexBy('age')['40'].name;
|
||||
_(stooges)
|
||||
.chain()
|
||||
.indexBy('age')
|
||||
.value()['40'].age;
|
||||
// _.indexBy(stooges, 'age')['40'].age;
|
||||
// _(stooges).indexBy('age')['40'].name;
|
||||
// _(stooges)
|
||||
// .chain()
|
||||
// .indexBy('age')
|
||||
// .value()['40'].age;
|
||||
|
||||
_.shuffle([1, 2, 3, 4, 5, 6]);
|
||||
|
||||
|
||||
Vendored
+50
-38
@@ -1416,6 +1416,16 @@ declare module _ {
|
||||
collection: Collection<T>,
|
||||
whereValue: Dictionary<any>): T;
|
||||
|
||||
/**
|
||||
* Retrieves the value of a specified property from all elements in the collection.
|
||||
* @param collection The collection to iterate over.
|
||||
* @param property The property to pluck.
|
||||
* @return A new array of property values.
|
||||
**/
|
||||
export function pluck<T extends {}>(
|
||||
collection: Collection<T>,
|
||||
property: string): any[];
|
||||
|
||||
/**
|
||||
* Reduces a collection to a value which is the accumulated result of running each
|
||||
* element in the collection through the callback, where each successive callback execution
|
||||
@@ -1467,14 +1477,49 @@ declare module _ {
|
||||
accumulator?: TResult,
|
||||
thisArg?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.reduceRight
|
||||
**/
|
||||
export function foldr<T, TResult>(
|
||||
collection: Collection<T>,
|
||||
callback: MemoIterator<T, TResult>,
|
||||
accumulator?: TResult,
|
||||
thisArg?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.reduceRight
|
||||
* 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.
|
||||
**/
|
||||
export function foldr<T, TResult>(
|
||||
export function reject<T>(
|
||||
collection: Collection<T>,
|
||||
callback: MemoIterator<T, TResult>,
|
||||
accumulator?: TResult,
|
||||
thisArg?: any): TResult;
|
||||
callback: ListIterator<T, boolean>,
|
||||
thisArg?: any): T[];
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
export function reject<T>(
|
||||
collection: Collection<T>,
|
||||
pluckValue: string): T[];
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
export function reject<T>(
|
||||
collection: Collection<T>,
|
||||
whereValue: Dictionary<any>): T[];
|
||||
|
||||
/**
|
||||
* Checks if the callback returns a truey value for any element of a collection. The function
|
||||
@@ -1575,39 +1620,6 @@ declare module _ {
|
||||
list: Collection<T>,
|
||||
properties: U): T[];
|
||||
|
||||
/**
|
||||
* Returns the values in list without the elements that the truth test (iterator) passes.
|
||||
* The opposite of filter.
|
||||
* Return all the elements for which a truth test fails.
|
||||
* @param list Reject elements within this list.
|
||||
* @param iterator Reject iterator function for each element in `list`.
|
||||
* @param context `this` object in `iterator`, optional.
|
||||
* @return The rejected list of elements.
|
||||
**/
|
||||
export function reject<T>(
|
||||
list: Collection<T>,
|
||||
iterator: ListIterator<T, boolean>,
|
||||
context?: any): T[];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A convenient version of what is perhaps the most common use-case for map: extracting a list of
|
||||
* property values.
|
||||
* @param list The list to pluck elements out of that have the property `propertyName`.
|
||||
* @param propertyName The property to look for on each element within `list`.
|
||||
* @return The list of elements within `list` that have the property `propertyName`.
|
||||
**/
|
||||
export function pluck<T extends {}>(
|
||||
list: Collection<T>,
|
||||
propertyName: string): T[];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a sorted copy of list, ranked in ascending order by the results of running each value
|
||||
* through iterator. Iterator may also be the string name of the property to sort by (eg. length).
|
||||
|
||||
Reference in New Issue
Block a user