mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add _.mapObject
This commit is contained in:
@@ -182,6 +182,10 @@ _.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'name');
|
||||
_.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'name', 'age');
|
||||
_.omit({ name: 'moe', age: 50, userid: 'moe1' }, ['name', 'age']);
|
||||
|
||||
_.mapObject({ a: 1, b: 2 }, val => val * 2) === _.mapObject({ a: 2, b: 4 }, _.identity);
|
||||
_.mapObject({ a: 1, b: 2 }, (val, key, o) => o[key] * 2) === _.mapObject({ a: 2, b: 4}, _.identity);
|
||||
_.mapObject({ x: "string 1", y: "string 2" }, 'length') === _.mapObject({ x: "string 1", y: "string 2"}, _.property('length'));
|
||||
|
||||
var iceCream = { flavor: "chocolate" };
|
||||
_.defaults(iceCream, { flavor: "vanilla", sprinkles: "lots" });
|
||||
|
||||
|
||||
Vendored
+25
@@ -1170,6 +1170,31 @@ interface UnderscoreStatic {
|
||||
* @return List of all the values on `object`.
|
||||
**/
|
||||
values(object: any): any[];
|
||||
|
||||
/**
|
||||
* Like map, but for objects. Transform the value of each property in turn.
|
||||
* @param object The object to transform
|
||||
* @param iteratee The function that transforms property values
|
||||
* @param context The optional context (value of `this`) to bind to
|
||||
* @return a new _.Dictionary of property values
|
||||
*/
|
||||
mapObject<T, U>(object: _.Dictionary<T>, iteratee: (val: T, key: string, object: _.Dictionary<T>) => U, context?: any): _.Dictionary<U>;
|
||||
|
||||
/**
|
||||
* Like map, but for objects. Transform the value of each property in turn.
|
||||
* @param object The object to transform
|
||||
* @param iteratee The function that tranforms property values
|
||||
* @param context The optional context (value of `this`) to bind to
|
||||
*/
|
||||
mapObject<T>(object: any, iteratee: (val: any, key: string, object: any) => T, context?: any): _.Dictionary<T>;
|
||||
|
||||
/**
|
||||
* Like map, but for objects. Retrieves a property from each entry in the object, as if by _.property
|
||||
* @param object The object to transform
|
||||
* @param iteratee The property name to retrieve
|
||||
* @param context The optional context (value of `this`) to bind to
|
||||
*/
|
||||
mapObject(object: any, iteratee: string, context?: any): _.Dictionary<any>;
|
||||
|
||||
/**
|
||||
* Convert an object into a list of [key, value] pairs.
|
||||
|
||||
Reference in New Issue
Block a user