mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-24 11:29:30 +08:00
_.where definition, moved _.zipObject
This commit is contained in:
+13
-1
@@ -28,6 +28,12 @@ interface IStoogesAge {
|
||||
age: number;
|
||||
}
|
||||
|
||||
interface IStoogesCombined {
|
||||
name: string;
|
||||
age: number;
|
||||
quotes: string[];
|
||||
}
|
||||
|
||||
interface IKey {
|
||||
dir: string;
|
||||
code: number;
|
||||
@@ -56,6 +62,11 @@ var stoogesAges: IStoogesAge[] = [
|
||||
{ 'name': 'larry', 'age': 50 }
|
||||
];
|
||||
|
||||
var stoogesCombined: IStoogesCombined[] = [
|
||||
{ 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] },
|
||||
{ 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] }
|
||||
];
|
||||
|
||||
var keys: IKey[] = [
|
||||
{ 'dir': 'left', 'code': 97 },
|
||||
{ 'dir': 'right', 'code': 100 }
|
||||
@@ -365,7 +376,8 @@ result = <string[]>_.sortBy(['banana', 'strawberry', 'apple'], 'length');
|
||||
|
||||
(function(a, b, c, d){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
|
||||
|
||||
|
||||
result = <IStoogesCombined[]>_.where(stoogesCombined, { 'age': 40 });
|
||||
result = <IStoogesCombined[]>_.where(stoogesCombined, { 'quotes': ['Poifect!'] });
|
||||
|
||||
|
||||
|
||||
|
||||
Vendored
+45
-43
@@ -451,7 +451,19 @@ declare module _ {
|
||||
fromIndex?: number): number;
|
||||
|
||||
/**
|
||||
* @see _.zipObject
|
||||
* Creates an object composed from arrays of keys and values. Provide either a single
|
||||
* two dimensional array, i.e. [[key1, value1], [key2, value2]] or two arrays, one of
|
||||
* keys and one of corresponding values.
|
||||
* @param keys The array of keys.
|
||||
* @param values The array of values.
|
||||
* @return An object composed of the given keys and corresponding values.
|
||||
**/
|
||||
export function zipObject<TResult extends {}>(
|
||||
keys: List<string>,
|
||||
values: List<any>): TResult;
|
||||
|
||||
/**
|
||||
* @see _.object
|
||||
**/
|
||||
export function object<TResult extends {}>(
|
||||
keys: List<string>,
|
||||
@@ -1668,43 +1680,43 @@ declare module _ {
|
||||
**/
|
||||
export function toArray<T>(collection: Collection<T>): T[];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Looks through each value in the list, returning an array of all the values that contain all
|
||||
* of the key-value pairs listed in properties.
|
||||
* @param list List to match elements again `properties`.
|
||||
* @param properties The properties to check for on each element within `list`.
|
||||
* @return The elements within `list` that contain the required `properties`.
|
||||
* Performs a deep comparison of each element in a collection to the given properties
|
||||
* object, returning an array of all elements that have equivalent property values.
|
||||
* @param collection The collection to iterate over.
|
||||
* @param properties The object of property values to filter by.
|
||||
* @return A new array of elements that have the given properties.
|
||||
**/
|
||||
export function where<T, U extends {}>(
|
||||
list: Collection<T>,
|
||||
properties: U): T[];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1738,17 +1750,7 @@ declare module _ {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates an object composed from arrays of keys and values. Provide either a single
|
||||
* two dimensional array, i.e. [[key1, value1], [key2, value2]] or two arrays, one of
|
||||
* keys and one of corresponding values.
|
||||
* @param keys The array of keys.
|
||||
* @param values The array of values.
|
||||
* @return An object composed of the given keys and corresponding values.
|
||||
**/
|
||||
export function zipObject<TResult extends {}>(
|
||||
keys: List<string>,
|
||||
values: List<any>): TResult;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user