New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zipmap

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zipmap

Returns a map with the keys mapped to the corresponding vals.

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status

zipmap

Returns a map with the keys mapped to the corresponding vals. zipmap also accepts a single value of objects or pairs.

Note: If you use objects, you must use the props key and value

/**
 * Returns a map with the keys mapped to the corresponding vals.
 *
 * @param {array} keys
 * @param {array} [vals]
 *
 * @return {object}
 */
function zipmap(keys, vals) { }

Install

npm i -S zipmap

Usage

var assert = require('assert');
var zipmap = require('zipmap');

var keys = ['a', 'b', 'c'];
var vals = [1, 2, 3];

var map = zipmap(keys, vals);
assert.deepEqual(map, { a: 1, b: 2, c: 3 });

Or use an array of objects

var objs = [
  { key: 'foo', value: 'bar' },
  { key: 'hi', value: 'bye' },
];

var out = {
  foo: ',
  hi: 'bye'
};

var map = zipmap(objs);
assert.deepEqual(map, out);

or use an array of pairs

var pairs = [
  ['foo', 'bar'],
  ['hi', 'bye']
];

var out = {
  foo: 'bar',
  hi: 'bye'
};

var map = zipmap(pairs);
assert.deepEqual(map, out);

Changelog

1.1.1
  • Return empty obj when given an array of len 0
1.1.0
  • Add single argument handling which allows objects or pairs

Keywords

FAQs

Package last updated on 17 Nov 2014

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