mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-27 11:40:08 +08:00
Merge pull request #2994 from motemen/lodash-chainable
Add Lo-Dash chainable methods
This commit is contained in:
@@ -326,6 +326,8 @@ result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4, 5]).xor([5, 2, 10], [4, 5,
|
||||
|
||||
result = <any[][]>_.zip(['moe', 'larry'], [30, 40], [true, false]);
|
||||
result = <any[][]>_.unzip(['moe', 'larry'], [30, 40], [true, false]);
|
||||
result = <any[][]>_(['moe', 'larry']).zip([30, 40], [true, false]).value();
|
||||
result = <any[][]>_(['moe', 'larry']).unzip([30, 40], [true, false]).value();
|
||||
|
||||
// /* *************
|
||||
// * Collections *
|
||||
@@ -381,6 +383,11 @@ result = <number>_.find([1, 2, 3, 4], function (num) {
|
||||
});
|
||||
result = <IFoodCombined>_.find(foodsCombined, { 'type': 'vegetable' });
|
||||
result = <IFoodCombined>_.find(foodsCombined, 'organic');
|
||||
result = <number>_([1, 2, 3, 4]).find(function (num) {
|
||||
return num % 2 == 0;
|
||||
});
|
||||
result = <IFoodCombined>_(foodsCombined).find({ 'type': 'vegetable' });
|
||||
result = <IFoodCombined>_(foodsCombined).find('organic');
|
||||
|
||||
result = <number>_.detect([1, 2, 3, 4], function (num) {
|
||||
return num % 2 == 0;
|
||||
@@ -400,6 +407,12 @@ result = <number>_.findLast([1, 2, 3, 4], function (num) {
|
||||
result = <IFoodCombined>_.findLast(foodsCombined, { 'type': 'vegetable' });
|
||||
result = <IFoodCombined>_.findLast(foodsCombined, 'organic');
|
||||
|
||||
result = <number>_([1, 2, 3, 4]).findLast(function (num) {
|
||||
return num % 2 == 0;
|
||||
});
|
||||
result = <IFoodCombined>_(foodsCombined).findLast({ 'type': 'vegetable' });
|
||||
result = <IFoodCombined>_(foodsCombined).findLast('organic');
|
||||
|
||||
result = <number[]>_.forEach([1, 2, 3], function (num) { console.log(num); });
|
||||
result = <_.Dictionary<number>>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); });
|
||||
result = <IFoodType>_.forEach<IFoodType, string>({ name: 'apple', type: 'fruit' }, function (value, key) { console.log(value, key) });
|
||||
@@ -468,10 +481,16 @@ result = <IStoogesAge[]>_(stoogesAges).collect('name').value();
|
||||
result = <number>_.max([4, 2, 8, 6]);
|
||||
result = <IStoogesAge>_.max(stoogesAges, function (stooge) { return stooge.age; });
|
||||
result = <IStoogesAge>_.max(stoogesAges, 'age');
|
||||
result = <_.LoDashWrapper<number>>_([4, 2, 8, 6]).max();
|
||||
result = <_.LoDashWrapper<IStoogesAge>>_(stoogesAges).max(function (stooge) { return stooge.age; });
|
||||
result = <_.LoDashWrapper<IStoogesAge>>_(stoogesAges).max('age');
|
||||
|
||||
result = <number>_.min([4, 2, 8, 6]);
|
||||
result = <IStoogesAge>_.min(stoogesAges, function (stooge) { return stooge.age; });
|
||||
result = <IStoogesAge>_.min(stoogesAges, 'age');
|
||||
result = <_.LoDashWrapper<number>>_([4, 2, 8, 6]).min();
|
||||
result = <_.LoDashWrapper<IStoogesAge>>_(stoogesAges).min(function (stooge) { return stooge.age; });
|
||||
result = <_.LoDashWrapper<IStoogesAge>>_(stoogesAges).min('age');
|
||||
|
||||
result = <string[]>_.pluck(stoogesAges, 'name');
|
||||
result = <string[]>_(stoogesAges).pluck('name').value();
|
||||
|
||||
Vendored
+102
@@ -2027,6 +2027,18 @@ declare module _ {
|
||||
unzip(...arrays: any[]): any[];
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.zip
|
||||
**/
|
||||
zip(...arrays: any[][]): _.LoDashArrayWrapper<any[][]>;
|
||||
|
||||
/**
|
||||
* @see _.zip
|
||||
**/
|
||||
unzip(...arrays: any[]): _.LoDashArrayWrapper<any[][]>;
|
||||
}
|
||||
|
||||
//_.zipObject
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
@@ -2860,6 +2872,28 @@ declare module _ {
|
||||
pluckValue: string): T;
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.find
|
||||
*/
|
||||
find(
|
||||
callback: ListIterator<T, boolean>,
|
||||
thisArg?: any): T;
|
||||
/**
|
||||
* @see _.find
|
||||
* @param _.where style callback
|
||||
*/
|
||||
find<W>(
|
||||
whereValue: W): T;
|
||||
|
||||
/**
|
||||
* @see _.find
|
||||
* @param _.where style callback
|
||||
*/
|
||||
find(
|
||||
pluckValue: string): T;
|
||||
}
|
||||
|
||||
//_.findLast
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
@@ -2940,6 +2974,28 @@ declare module _ {
|
||||
pluckValue: string): T;
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.findLast
|
||||
*/
|
||||
findLast(
|
||||
callback: ListIterator<T, boolean>,
|
||||
thisArg?: any): T;
|
||||
/**
|
||||
* @see _.findLast
|
||||
* @param _.where style callback
|
||||
*/
|
||||
findLast<W>(
|
||||
whereValue: W): T;
|
||||
|
||||
/**
|
||||
* @see _.findLast
|
||||
* @param _.where style callback
|
||||
*/
|
||||
findLast(
|
||||
pluckValue: string): T;
|
||||
}
|
||||
|
||||
//_.forEach
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
@@ -3620,6 +3676,29 @@ declare module _ {
|
||||
whereValue: W): T;
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.max
|
||||
**/
|
||||
max(
|
||||
callback?: ListIterator<T, any>,
|
||||
thisArg?: any): LoDashWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.max
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
max(
|
||||
pluckValue: string): LoDashWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.max
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
max<W>(
|
||||
whereValue: W): LoDashWrapper<T>;
|
||||
}
|
||||
|
||||
//_.min
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
@@ -3708,6 +3787,29 @@ declare module _ {
|
||||
whereValue: W): T;
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.min
|
||||
**/
|
||||
min(
|
||||
callback?: ListIterator<T, any>,
|
||||
thisArg?: any): LoDashWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.min
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
min(
|
||||
pluckValue: string): LoDashWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.min
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
min<W>(
|
||||
whereValue: W): LoDashWrapper<T>;
|
||||
}
|
||||
|
||||
//_.pluck
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user