Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reverse-object

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reverse-object

"A utility function to create an object with keys as original objects values, and values as the original object's respective keys."

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

reverse-object

A utility function to create an object with keys as original objects values, and values as the original object's respective keys.

Install

$ npm install --save reverse-object

Usage

var reverseObject = require('reverse-object');

reverseObject({"key1": "val1", "key2": "val2"});
//=> {"val1": "key1", "val2": "key2"}

reverseObject({"key1": "val1", "key2": "val2", "key3": "val1"});
//=> {"val1": "key3", "val2": "key2"}

reverseObject(["key1", "key2", "key3"]);
//=> {"key1": "0", "key2": "1", "key3": "2"}

reverseObject("abc");
//=> {"a": "0", "b": "1", "c": "2"}

with noOverwrite true

var reverseObject = require('reverse-object');

reverseObject({"key1": "val1", "key2": "val2"}, true);
//=> {"val1": ["key1"], "val2": ["key2"]}

reverseObject({"key1": "val1", "key2": "val2", "key3": "val1"}, true);
//=> {"val1": ["key1","key3"], "val2": ["key2"]}

reverseObject(["key1", "key2", "key1"], true);
//=> {"key1": ["0","2"], "key2": ["1"]}

reverseObject("aba", true);
//=> {"a": ["0","2"], "b": ["1"]}

Keywords

FAQs

Package last updated on 13 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc