fix tests and optional argument for reduce functions

This commit is contained in:
Greg Weber
2013-10-30 10:38:29 -07:00
parent 01932853df
commit 9dd9da44d5
2 changed files with 71 additions and 24 deletions
+13 -20
View File
@@ -144,28 +144,21 @@ result = <number[]>_.difference([1, 2, 3, 4, 5], [5, 2, 10]);
result = <number[]>_.rest([1, 2, 3]);
result = <number[]>_.rest([1, 2, 3], 2);
result = <number[]>_.rest([1, 2, 3], function(num) {
return num < 3;
});
result = <number[]>_.rest([1, 2, 3], (num) => num < 3)
result = <IFoodOrganic[]>_.rest(foodsOrganic, 'test');
var result : any;
result = <IFoodType[]>_.rest(foodsType, { 'test': 'value' });
result = <IFoodType[]>_.rest(foodsType, { 'type': 'value' });
result = <number[]>_.drop([1, 2, 3]);
result = <number[]>_.drop([1, 2, 3], 2);
result = <number[]>_.drop([1, 2, 3], function(num) {
return num < 3;
});
result = <IFoodOrganic[]>_.drop(foodsOrganic, 'test');
result = <IFoodType[]>_.drop(foodsType, { 'test': 'value' });
result = <number[]>_.drop([1, 2, 3]);
result = <number[]>_.drop([1, 2, 3], 2);
result = <number[]>_.drop([1, 2, 3], (num) => num < 3)
result = <IFoodOrganic[]>_.drop(foodsOrganic, 'test');
result = <IFoodType[]>_.drop(foodsType, { 'type': 'value' });
result = <number[]>_.tail([1, 2, 3]);
result = <number[]>_.tail([1, 2, 3], 2);
result = <number[]>_.tail([1, 2, 3], function(num) {
return num < 3;
});
result = <IFoodOrganic[]>_.tail(foodsOrganic, 'test');
result = <IFoodType[]>_.tail(foodsType, { 'test': 'value' });
result = <number[]>_.tail([1, 2, 3])
result = <number[]>_.tail([1, 2, 3], 2)
result = <number[]>_.tail([1, 2, 3], (num) => num < 3)
result = <IFoodOrganic[]>_.tail(foodsOrganic, 'test')
result = <IFoodType[]> _.tail(foodsType, { 'type': 'value' })
result = <number>_.findIndex(['apple', 'banana', 'beet'], function(f) {
return /^b/.test(f);
@@ -203,9 +196,9 @@ result = <IFoodType[]>_.first(foodsType, { 'type': 'fruit' });
result = <number[]>_.flatten([1, [2], [3, [[4]]]]);
result = <any[]>_.flatten([1, [2], [3, [[4]]]], true);
var result: any
result = <string[]>_.flatten(stoogesQuotes, 'quotes');
var result: any
result = <_.LoDashArrayWrapper<number>>_([1, [2], [3, [[4]]]]).flatten();
result = <_.LoDashArrayWrapper<number>>_([1, [2], [3, [[4]]]]).flatten(true);
result = <_.LoDashArrayWrapper<string>>_(stoogesQuotes).flatten('quotes');
+58 -4
View File
@@ -780,7 +780,7 @@ declare module _ {
**/
rest<T>(
array: List<T>,
callback: (elem: T) => boolean,
callback: ListIterator<T, boolean>,
thisArg?: any): T[];
/**
@@ -800,10 +800,13 @@ declare module _ {
/**
* @see _.rest
**/
rest<W, T extends W>(
rest<W, T extends W>(
array: List<T>,
whereValue: W): T[];
/**
* @see _.rest
**/
drop<T>(array: List<T>): T[];
/**
@@ -811,7 +814,7 @@ declare module _ {
**/
drop<T>(
array: List<T>,
callback: (elem: T) => boolean,
callback: ListIterator<T, boolean>,
thisArg?: any): T[];
/**
@@ -835,6 +838,9 @@ declare module _ {
array: List<T>,
whereValue: W): T[];
/**
* @see _.rest
**/
tail<T>(array: List<T>): T[];
/**
@@ -842,7 +848,7 @@ declare module _ {
**/
tail<T>(
array: List<T>,
callback: (elem: T) => boolean,
callback: ListIterator<T, boolean>,
thisArg?: any): T[];
/**
@@ -1916,6 +1922,14 @@ declare module _ {
accumulator?: TResult,
thisArg?: any): TResult;
/**
* @see _.reduce
**/
reduce<T, TResult>(
collection: Collection<T>,
callback: MemoIterator<T, TResult>,
thisArg?: any): TResult;
/**
* @see _.reduce
**/
@@ -1925,6 +1939,14 @@ declare module _ {
accumulator?: TResult,
thisArg?: any): TResult;
/**
* @see _.reduce
**/
inject<T, TResult>(
collection: Collection<T>,
callback: MemoIterator<T, TResult>,
thisArg?: any): TResult;
/**
* @see _.reduce
**/
@@ -1933,6 +1955,14 @@ declare module _ {
callback: MemoIterator<T, TResult>,
accumulator?: TResult,
thisArg?: any): TResult;
/**
* @see _.reduce
**/
foldl<T, TResult>(
collection: Collection<T>,
callback: MemoIterator<T, TResult>,
thisArg?: any): TResult;
}
//_.reduceRight
@@ -1952,6 +1982,14 @@ declare module _ {
accumulator?: TResult,
thisArg?: any): TResult;
/**
* @see _.reduceRight
**/
reduceRight<T, TResult>(
collection: Collection<T>,
callback: MemoIterator<T, TResult>,
thisArg?: any): TResult;
/**
* @see _.reduceRight
**/
@@ -1960,6 +1998,14 @@ declare module _ {
callback: MemoIterator<T, TResult>,
accumulator?: TResult,
thisArg?: any): TResult;
/**
* @see _.reduceRight
**/
foldr<T, TResult>(
collection: Collection<T>,
callback: MemoIterator<T, TResult>,
thisArg?: any): TResult;
}
//_.reject
@@ -3621,6 +3667,14 @@ declare module _ {
callback?: MemoIterator<T, any>,
accumulator?: any,
thisArg?: any): any;
/**
* @see _.transform
**/
transform<T>(
collection: Collection<T>,
callback?: MemoIterator<T, any>,
thisArg?: any): any;
}
//_.values