mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
added _.invert definition
This commit is contained in:
@@ -583,6 +583,8 @@ _.functions(_);
|
||||
|
||||
_.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
|
||||
|
||||
_.invert({ 'first': 'moe', 'second': 'larry' });
|
||||
|
||||
var mergeNames = {
|
||||
'stooges': [
|
||||
{ 'name': 'moe' },
|
||||
@@ -629,7 +631,6 @@ _.merge(mergeFood, mergeOtherFood, function(a, b) {
|
||||
_.keys({ one: 1, two: 2, three: 3 });
|
||||
_.values({ one: 1, two: 2, three: 3 });
|
||||
_.pairs({ one: 1, two: 2, three: 3 });
|
||||
_.invert({ Moe: "Moses", Larry: "Louis", Curly: "Jerome" });
|
||||
_.pick({ name: 'moe', age: 50, userid: 'moe1' }, 'name', 'age');
|
||||
_.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'name');
|
||||
_.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'name', 'age');
|
||||
|
||||
Vendored
+7
-8
@@ -2339,6 +2339,13 @@ declare module _ {
|
||||
**/
|
||||
export function has(object: any, property: string): boolean;
|
||||
|
||||
/**
|
||||
* Creates an object composed of the inverted keys and values of the given object.
|
||||
* @param object The object to invert.
|
||||
* @return The created inverted object.
|
||||
**/
|
||||
export function invert(object: any): any;
|
||||
|
||||
/**
|
||||
* Recursively merges own enumerable properties of the source object(s), that don't resolve
|
||||
* to undefined into the destination object. Subsequent sources will overwrite property
|
||||
@@ -2515,14 +2522,6 @@ declare module _ {
|
||||
**/
|
||||
export function pairs(object: any): any[][];
|
||||
|
||||
/**
|
||||
* Returns a copy of the object where the keys have become the values and the values the keys.
|
||||
* For this to work, all of your object's values should be unique and string serializable.
|
||||
* @param object Object to invert key/value pairs.
|
||||
* @return An inverted key/value paired version of `object`.
|
||||
**/
|
||||
export function invert(object: any): any;
|
||||
|
||||
/**
|
||||
* Return a copy of the object, filtered to only have values for the whitelisted keys
|
||||
* (or array of valid keys).
|
||||
|
||||
Reference in New Issue
Block a user