mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-19 13:32:17 +08:00
Merge pull request #5094 from mdekrey/lodash-updates
Partial updates for lodash to 3.10.0
This commit is contained in:
@@ -240,19 +240,19 @@ result = <number[]>_([1, 2, 3]).head(function (num) {
|
||||
result = <IFoodOrganic[]>_(foodsOrganic).head('organic').value();
|
||||
result = <IFoodType[]>_(foodsType).head({ 'type': 'fruit' }).value();
|
||||
|
||||
result = <number>_.take([1, 2, 3]);
|
||||
result = <number[]>_.take([1, 2, 3]);
|
||||
result = <number[]>_.take([1, 2, 3], 2);
|
||||
result = <number[]>_.take([1, 2, 3], (num) => num < 3);
|
||||
result = <IFoodOrganic[]>_.take(foodsOrganic, 'organic');
|
||||
result = <IFoodType[]>_.take(foodsType, { 'type': 'fruit' });
|
||||
result = <number[]>_.takeWhile([1, 2, 3], (num) => num < 3);
|
||||
result = <boolean[]>_.takeWhile(foodsOrganic, 'organic');
|
||||
result = <IFoodType[]>_.takeWhile(foodsType, { 'type': 'fruit' });
|
||||
|
||||
result = <number>_([1, 2, 3]).take();
|
||||
result = <number[]>_([1, 2, 3]).take().value();
|
||||
result = <number[]>_([1, 2, 3]).take(2).value();
|
||||
result = <number[]>_([1, 2, 3]).take(function (num) {
|
||||
result = <number[]>_([1, 2, 3]).takeWhile(function (num) {
|
||||
return num < 3;
|
||||
}).value();
|
||||
result = <IFoodOrganic[]>_(foodsOrganic).take('organic').value();
|
||||
result = <IFoodType[]>_(foodsType).take({ 'type': 'fruit' }).value();
|
||||
result = <boolean[]>_(foodsType).takeWhile('organic').value();
|
||||
result = <IFoodType[]>_(foodsType).takeWhile({ 'type': 'fruit' }).value();
|
||||
|
||||
result = <Array<number>>_.flatten([[1, 2], [3, 4]]);
|
||||
result = <Array<number>>_.flatten([[1, 2], [3, 4], 5, 6]);
|
||||
@@ -329,6 +329,8 @@ result = <number>_.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function
|
||||
|
||||
result = <number[]>_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
|
||||
result = <number[]>_([1, 2, 3]).union([101, 2, 1, 10], [2, 1]).value();
|
||||
|
||||
result = <number[]>_.uniq([1, 2, 1, 3, 1]);
|
||||
result = <number[]>_.uniq([1, 1, 2, 2, 3], true);
|
||||
result = <string[]>_.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) {
|
||||
@@ -438,6 +440,7 @@ result = <boolean>_.all([true, 1, null, 'yes'], Boolean);
|
||||
result = <boolean>_.all(stoogesAges, 'age');
|
||||
result = <boolean>_.all(stoogesAges, { 'age': 50 });
|
||||
|
||||
result = <number[]>_.filter([1, 2, 3, 4, 5, 6]);
|
||||
result = <number[]>_.filter([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; });
|
||||
result = <IFoodCombined[]>_.filter(foodsCombined, 'organic');
|
||||
result = <IFoodCombined[]>_.filter(foodsCombined, { 'type': 'fruit' });
|
||||
@@ -742,6 +745,7 @@ result = <IStoogesAge[]>_.sortByOrder(stoogesAges, ['name', function(stooge) { r
|
||||
result = <number[]>_([1, 2, 3]).sortBy(function (num) { return Math.sin(num); }).value();
|
||||
result = <number[]>_([1, 2, 3]).sortBy(function (num) { return this.sin(num); }, Math).value();
|
||||
result = <string[]>_(['banana', 'strawberry', 'apple']).sortBy('length').value();
|
||||
result = <IFoodOrganic[]>_(foodsOrganic).sortByAll('organic', (food) => food.name, { organic: true }).value();
|
||||
|
||||
(function (a: number, b: number, c: number, d: number): Array<number> { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
|
||||
result = <number[]>_.toArray([1, 2, 3, 4]);
|
||||
|
||||
134
lodash/lodash.d.ts
vendored
134
lodash/lodash.d.ts
vendored
@@ -664,12 +664,12 @@ declare module _ {
|
||||
/**
|
||||
* @see _.first
|
||||
**/
|
||||
take<T>(array: Array<T>): T;
|
||||
take<T>(array: Array<T>): T[];
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
**/
|
||||
take<T>(array: List<T>): T;
|
||||
take<T>(array: List<T>): T[];
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
@@ -686,48 +686,36 @@ declare module _ {
|
||||
n: number): T[];
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
**/
|
||||
take<T>(
|
||||
array: Array<T>,
|
||||
callback: ListIterator<T, boolean>,
|
||||
thisArg?: any): T[];
|
||||
|
||||
* Takes the first items from an array or list based on a predicate
|
||||
* @param array The array or list of items on which the result set will be based
|
||||
* @param predicate A predicate function to determine whether a value will be taken. Optional; defaults to identity.
|
||||
* @param [thisArg] The this binding of predicate.
|
||||
*/
|
||||
takeWhile<T>(
|
||||
array: (Array<T>|List<T>),
|
||||
predicate?: ListIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
**/
|
||||
take<T>(
|
||||
array: List<T>,
|
||||
callback: ListIterator<T, boolean>,
|
||||
thisArg?: any): T[];
|
||||
|
||||
* Takes the first items from an array or list based on a predicate
|
||||
* @param array The array or list of items on which the result set will be based
|
||||
* @param pluckValue Uses a _.property style callback to return the property value of the given element
|
||||
*/
|
||||
takeWhile<T>(
|
||||
array: (Array<T>|List<T>),
|
||||
pluckValue: string
|
||||
): any[];
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
**/
|
||||
take<T>(
|
||||
array: Array<T>,
|
||||
pluckValue: string): T[];
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
**/
|
||||
take<T>(
|
||||
array: List<T>,
|
||||
pluckValue: string): T[];
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
**/
|
||||
take<W, T>(
|
||||
array: Array<T>,
|
||||
whereValue: W): T[];
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
**/
|
||||
take<W, T>(
|
||||
array: List<T>,
|
||||
whereValue: W): T[];
|
||||
* Takes the first items from an array or list based on a predicate
|
||||
* @param array The array or list of items on which the result set will be based
|
||||
* @param whereValue Uses a _.matches style callback to return the first elements that match the given value
|
||||
*/
|
||||
takeWhile<W, T>(
|
||||
array: (Array<T>|List<T>),
|
||||
whereValue: W
|
||||
): T[];
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
@@ -798,7 +786,7 @@ declare module _ {
|
||||
/**
|
||||
* @see _.first
|
||||
**/
|
||||
take(): T;
|
||||
take(): LoDashArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
@@ -807,25 +795,28 @@ declare module _ {
|
||||
take(n: number): LoDashArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
* @param callback The function called per element.
|
||||
* Takes the first items based on a predicate
|
||||
* @param predicate The function called per element.
|
||||
* @param [thisArg] The this binding of callback.
|
||||
**/
|
||||
take(
|
||||
callback: ListIterator<T, boolean>,
|
||||
takeWhile(
|
||||
predicate: ListIterator<T, boolean>,
|
||||
thisArg?: any): LoDashArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
* @param pluckValue "_.pluck" style callback value
|
||||
* Takes the first items based on a predicate
|
||||
* @param pluckValue Uses a _.property style callback to return the property value of the given element
|
||||
**/
|
||||
take(pluckValue: string): LoDashArrayWrapper<T>;
|
||||
takeWhile<T>(
|
||||
pluckValue: string): LoDashArrayWrapper<any>;
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
* @param whereValue "_.where" style callback value
|
||||
* Takes the first items based on a predicate
|
||||
* @param whereValue Uses a _.matches style callback to return the first elements that match the given value
|
||||
**/
|
||||
take<W>(whereValue: W): LoDashArrayWrapper<T>;
|
||||
takeWhile<W, T>(
|
||||
whereValue: W): LoDashArrayWrapper<T>;
|
||||
|
||||
}
|
||||
|
||||
interface MaybeNestedList<T> extends List<T|List<T>> { }
|
||||
@@ -1536,6 +1527,13 @@ declare module _ {
|
||||
**/
|
||||
union<T>(...arrays: List<T>[]): T[];
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.union
|
||||
**/
|
||||
union<T>(...arrays: (Array<T>|List<T>)[]): LoDashArrayWrapper<T>;
|
||||
}
|
||||
|
||||
//_.uniq
|
||||
interface LoDashStatic {
|
||||
@@ -2517,6 +2515,16 @@ declare module _ {
|
||||
|
||||
//_.filter
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Iterates over elements of a collection, returning an array of all elements the
|
||||
* identity function returns truey for.
|
||||
*
|
||||
* @param collection The collection to iterate over.
|
||||
* @return Returns a new array of elements that passed the callback check.
|
||||
**/
|
||||
filter<T>(
|
||||
collection: (Array<T>|List<T>)): T[];
|
||||
|
||||
/**
|
||||
* Iterates over elements of a collection, returning an array of all elements the
|
||||
* callback returns truey for. The callback is bound to thisArg and invoked with three
|
||||
@@ -2675,6 +2683,11 @@ declare module _ {
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.filter
|
||||
**/
|
||||
filter(): LoDashArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.filter
|
||||
**/
|
||||
@@ -4939,6 +4952,15 @@ declare module _ {
|
||||
sortBy<W, T>(
|
||||
collection: List<T>,
|
||||
whereValue: W): T[];
|
||||
|
||||
/**
|
||||
* Sorts by all the given arguments, using either ListIterator, pluckValue, or whereValue foramts
|
||||
* @param args The rules by which to sort
|
||||
*/
|
||||
sortByAll<T>(
|
||||
collection: (Array<T>|List<T>),
|
||||
...args: (ListIterator<T, boolean>|Object|string)[]
|
||||
): T[];
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
@@ -4960,6 +4982,12 @@ declare module _ {
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
sortBy<W>(whereValue: W): LoDashArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* Sorts by all the given arguments, using either ListIterator, pluckValue, or whereValue foramts
|
||||
* @param args The rules by which to sort
|
||||
*/
|
||||
sortByAll(...args: (ListIterator<T, boolean>|Object|string)[]): LoDashArrayWrapper<T>;
|
||||
}
|
||||
|
||||
//_.sortByAll
|
||||
|
||||
Reference in New Issue
Block a user