From b9925510b007cb06b311a563ba74f60ea03a8411 Mon Sep 17 00:00:00 2001 From: Brian Zengel Date: Sun, 20 Oct 2013 12:48:14 -0400 Subject: [PATCH] added _.invert definition --- lodash/lodash-tests.ts | 3 ++- lodash/lodash.d.ts | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5cf424f19..9c65cb832 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -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'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 6252417a8..641acbd88 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -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).