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

invert-kv

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

invert-kv - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

license

12

index.js
'use strict';
module.exports = function (obj) {
if (typeof obj !== 'object') {
module.exports = object => {
if (typeof object !== 'object') {
throw new TypeError('Expected an object');
}
var ret = {};
const ret = {};
for (var key in obj) {
var val = obj[key];
ret[val] = key;
for (const key of Object.keys(object)) {
const value = object[key];
ret[value] = key;
}

@@ -13,0 +13,0 @@

{
"name": "invert-kv",
"version": "1.0.0",
"description": "Invert the key/value of an object. Example: {foo: 'bar'} → {bar: 'foo'}",
"license": "MIT",
"repository": "sindresorhus/invert-kv",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"files": [
"index.js"
],
"keywords": [
"object",
"obj",
"key",
"value",
"val",
"kv",
"invert"
],
"devDependencies": {
"mocha": "*"
}
"name": "invert-kv",
"version": "2.0.0",
"description": "Invert the key/value of an object. Example: `{foo: 'bar'}` → `{bar: 'foo'}`",
"license": "MIT",
"repository": "sindresorhus/invert-kv",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"object",
"key",
"value",
"kv",
"invert"
],
"devDependencies": {
"ava": "*",
"xo": "*"
}
}

@@ -8,5 +8,5 @@ # invert-kv [![Build Status](https://travis-ci.org/sindresorhus/invert-kv.svg?branch=master)](https://travis-ci.org/sindresorhus/invert-kv)

```sh
$ npm install --save invert-kv
```
$ npm install invert-kv
```

@@ -17,3 +17,3 @@

```js
var invertKv = require('invert-kv');
const invertKv = require('invert-kv');

@@ -27,2 +27,2 @@ invertKv({foo: 'bar', unicorn: 'rainbow'});

MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)
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