From 4168e725434f998bc920787f0979b3c43bb74076 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 9 Sep 2015 04:45:46 +0500 Subject: [PATCH] lodash: changed _.invert() method --- lodash/lodash-tests.ts | 11 +++++++---- lodash/lodash.d.ts | 20 +++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5b9add244..6ff0f4287 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1552,11 +1552,14 @@ result = _({}).has(42); result = _({}).has(true); result = _({}).has(['', 42, true]); -interface FirstSecond { - first: string; - second: string; +// _.invert +{ + let result: TResult; + result = _.invert({}); + result = _.invert({}, true); + result = _({}).invert().value(); + result = _({}).invert(true).value(); } -result = _.invert({ 'first': 'moe', 'second': 'larry' }); // _.isEqual (alias: _.eq) result = _.isEqual(1, 1); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b6c95710b..1755d9d06 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -7190,11 +7190,21 @@ declare module _ { //_.invert interface LoDashStatic { /** - * 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. - **/ - invert(object: any): any; + * Creates an object composed of the inverted keys and values of object. If object contains duplicate values, + * subsequent values overwrite property assignments of previous values unless multiValue is true. + * + * @param object The object to invert. + * @param multiValue Allow multiple values per key. + * @return Returns the new inverted object. + */ + invert(object: T, multiValue?: boolean): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.invert + */ + invert(multiValue?: boolean): LoDashObjectWrapper; } //_.isEqual