rekey()
Modifies keys of an object or augments the object with more keys for the same values.
This function is valid in v2.19.0 to v2.24.3. This function has been downloaded 42 times.rekey()
.obj
. If this is an object the keys will correspond to the current keys and values will correspond to the new keys. If this is an array then each value must be an array where the first item is used to match current keys and the second item is used to define the new keys. An array at times may be preferred so that you can target one or more current keys using a function (which is passed just passed each current key and should return a value indicating whether it should be modified) or a regular expression. If the property values or each array item's second value is a function, it will be called with the value of the current key that is to be modified or augmented and the return value will be used as the new key or additional key.false
true
then the returned object or array will be an augmented version of obj
. Otherwise any keys that are found in obj
because of keyMap
values will simply be replaced according to the corresponding values in keyMap
.obj
is undefined
or null
a partial function which will allow for obj
to be defined will be returned. If obj
is array-like a new array will be returned. Otherwise a new object will be returned. In the case that an array or an object is returned the keys will be based on the keys from obj
and the values determined by keyMap
.This function directly requires the following functions which are included automatically:
has()
isArrayLike()