Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tyxla/object-flip
Exchange object property keys with their associated values.
https://github.com/tyxla/object-flip
Last synced: about 1 month ago
JSON representation
Exchange object property keys with their associated values.
- Host: GitHub
- URL: https://github.com/tyxla/object-flip
- Owner: tyxla
- License: mit
- Created: 2015-12-21T20:55:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-21T21:34:20.000Z (about 9 years ago)
- Last Synced: 2024-09-23T01:53:11.947Z (4 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# object-flip
Exchange object property keys with their associated values.
```
npm install object-flip
```[![Build Status](https://travis-ci.org/tyxla/object-flip.svg?branch=master)](https://travis-ci.org/tyxla/object-flip)
## About
This will swap each property key of the specified object with its corresponding value.
The swapping will work only for integer and string values, while other types will be omitted from the result object.
Please, note that properties with the same values will override each other, as there can be only one property with a certain key.
## Syntax
``` js
objectFlip(objectToFlip);
```#### objectToFlip
This is the object that you wish to flip.
## Usage
Pass the object you want to flip, and you will receive the flipped object with swapped keys and values.
``` js
var result = objectExtract({
foo: 123,
456: 'bar'
});console.log(result);
/*
{
123: 'foo',
'bar': '456'
}
*/```
## License
MIT