added _.invert definition

This commit is contained in:
Brian Zengel
2013-10-20 12:48:14 -04:00
parent d53a4df2a2
commit b9925510b0
2 changed files with 9 additions and 9 deletions
+2 -1
View File
@@ -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');
+7 -8
View File
@@ -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).