invert-obj

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
1 KB
Returns a new object with the keys of the given object as values, and the values of the given object, which are coerced to strings, as keys.
1 contributor
Install invert-obj as a package?
Copied
npm i @bit/justin-capalbo.ramda.invert-obj
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
invertObj (
obj:Object
) : Object

Returns a new object with the keys of the given object as values, and the values of the given object, which are coerced to strings, as keys. Note that the last key found is preferred when handling the same value.

Example
const raceResults = {
       first: 'alice',
       second: 'jake'
     };
     R.invertObj(raceResults);
     //=> { 'alice': 'first', 'jake':'second' }

     // Alternatively:
     const raceResults = ['alice', 'jake'];
     R.invertObj(raceResults);
     //=> { 'alice': '0', 'jake':'1' }
Argument
obj: Object

The object or array to invert

Returns
Object

out A new object

Help and resources