You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Inverts an object, such that keys become values and values become keys, according to a transform function.
4056
-
*
4057
-
* ## Notes
4058
-
*
4059
-
* - The transform function is provided three arguments:
4060
-
*
4061
-
* - `key`: object key.
4062
-
* - `value`: object value corresponding to `key`.
4063
-
* - `obj`: the input object.
4064
-
*
4065
-
* - The value returned by a transform function should be a value which can be serialized as an object key. Hence, beware when providing objects having values which are themselves objects. The function relies on native object serialization (`#toString`) when converting transform function return values to keys.
4066
-
*
4067
-
* - In older JavaScript engines, insertion order is not guaranteed, as object key enumeration was not specified according to the ECMAScript specification in earlier editions. In practice, however, most older engines use insertion order to sort an object's keys, thus allowing for deterministic inversion.
4068
-
*
4069
-
* @param obj - input object
4070
-
* @param opts - function options
4071
-
* @param opts.duplicates - boolean indicating whether to store duplicate keys (default: true)
4072
-
* @param transform - transform function
4073
-
* @returns inverted object
4074
-
*
4075
-
* @example
4076
-
* function transform( key, value ) {
4077
-
* return value;
4078
-
* }
4079
-
*
4080
-
* var obj = {};
4081
-
* obj.a = 'beep';
4082
-
* obj.b = 'boop';
4083
-
* obj.c = 'beep'; // inserted after `a`
4084
-
*
4085
-
* var opts = {
4086
-
* 'duplicates': false
4087
-
* };
4088
-
* var out = ns.objectInverseBy( obj, opts, transform );
4089
-
* // returns { 'beep': 'c', 'boop': 'b' }
4090
-
*/
4091
-
objectInverseBy: typeofobjectInverseBy;
4092
-
4093
4053
/**
4094
4054
* Returns a partial object copy excluding specified keys.
0 commit comments