lodash: changed _.invert() method

This commit is contained in:
Ilya Mochalov
2015-09-16 01:03:35 +05:00
parent 52b0ea5c97
commit 4168e72543
2 changed files with 22 additions and 9 deletions
+7 -4
View File
@@ -1552,11 +1552,14 @@ result = <boolean>_({}).has(42);
result = <boolean>_({}).has(true);
result = <boolean>_({}).has(['', 42, true]);
interface FirstSecond {
first: string;
second: string;
// _.invert
{
let result: TResult;
result = _.invert<Object, TResult>({});
result = _.invert<Object, TResult>({}, true);
result = _({}).invert<TResult>().value();
result = _({}).invert<TResult>(true).value();
}
result = <FirstSecond>_.invert({ 'first': 'moe', 'second': 'larry' });
// _.isEqual (alias: _.eq)
result = <boolean>_.isEqual(1, 1);
+15 -5
View File
@@ -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<T extends {}, TResult extends {}>(object: T, multiValue?: boolean): TResult;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.invert
*/
invert<TResult extends {}>(multiValue?: boolean): LoDashObjectWrapper<TResult>;
}
//_.isEqual