mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
definitions for _.initial and _.intersection
This commit is contained in:
+12
-2
@@ -105,6 +105,16 @@ result = <number>_.indexOf([1, 2, 3, 1, 2, 3], 2);
|
||||
result = <number>_.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
|
||||
result = <number>_.indexOf([1, 1, 2, 2, 3, 3], 2, true);
|
||||
|
||||
result = <number[]>_.initial([1, 2, 3]);
|
||||
result = <number[]>_.initial([1, 2, 3], 2);
|
||||
result = <number[]>_.initial([1, 2, 3], function(num) {
|
||||
return num > 1;
|
||||
});
|
||||
result = <IFoodOrganic[]>_.initial(foodsOrganic, 'organic');
|
||||
result = <IFoodType[]>_.initial(foodsType, { 'type': 'vegetable' });
|
||||
|
||||
result = <number[]>_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
//WHAT'S LEFT
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -174,7 +184,7 @@ _.size({ one: 1, two: 2, three: 3 });
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
_.initial([5, 4, 3, 2, 1]);
|
||||
|
||||
_.last([5, 4, 3, 2, 1]);
|
||||
|
||||
|
||||
@@ -183,7 +193,7 @@ _.last([5, 4, 3, 2, 1]);
|
||||
|
||||
_.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
|
||||
_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
|
||||
_.difference([1, 2, 3, 4, 5], [5, 2, 10]);
|
||||
_.uniq([1, 2, 1, 3, 1, 4]);
|
||||
_.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);
|
||||
|
||||
Vendored
+43
-4
@@ -710,15 +710,54 @@ declare module _ {
|
||||
whereValue: Dictionary<string>): T[];
|
||||
|
||||
/**
|
||||
* Returns everything but the last entry of the array. Especially useful on the arguments object.
|
||||
* Pass n to exclude the last n elements from the result.
|
||||
* @param array Retreive all elements except the last `n`.
|
||||
* Gets all but the last element or last n elements of an array. If a callback is provided
|
||||
* elements at the end of the array are excluded from the result as long as the callback
|
||||
* returns truey. The callback is bound to thisArg and invoked with three arguments;
|
||||
* (value, index, array).
|
||||
*
|
||||
* 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 array The array to query.
|
||||
* @param n Leaves this many elements behind, optional.
|
||||
* @return Returns everything but the last `n` elements of `array`.
|
||||
**/
|
||||
export function initial<T>(
|
||||
array: List<T>): T[];
|
||||
|
||||
/**
|
||||
* @see _.initial
|
||||
* @param n The number of elements to exclude.
|
||||
**/
|
||||
export function initial<T>(
|
||||
array: List<T>,
|
||||
n?: number): T[];
|
||||
n: number): T[];
|
||||
|
||||
/**
|
||||
* @see _.initial
|
||||
* @param callback The function called per element
|
||||
**/
|
||||
export function initial<T>(
|
||||
array: List<T>,
|
||||
callback: ListIterator<T, boolean>): T[];
|
||||
|
||||
/**
|
||||
* @see _.initial
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
export function initial<T>(
|
||||
array: List<T>,
|
||||
pluckValue: string): T[];
|
||||
|
||||
/**
|
||||
* @see _.initial
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
export function initial<T>(
|
||||
array: List<T>,
|
||||
whereValue: Dictionary<any>): T[];
|
||||
|
||||
/**
|
||||
* Returns the last element of an array. Passing n will return the last n elements of the array.
|
||||
|
||||
Reference in New Issue
Block a user