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

keymbinatorial

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keymbinatorial

Module that generates the unique combinations of key values by taking a single value from each keys array

  • 1.1.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
50
decreased by-31.51%
Maintainers
2
Weekly downloads
 
Created
Source

Keymbinatorial

Version Downloads Build Status Open Issues License

Generates a unique combinations of key values by taking a single value from each keys array

Usage

npm install keymbinatorial
var keymbinatorial = require('keymbinatorial');

let objectToCombine = {
    a: ['a', 'b', 'c'],
    c: [1, 2],
    e: [{ a: '1'}, {b: '2'}]
};

// combinations will be an array of unique combinations based on each key and the values in the array
let combinations = keymbinatorial(objectToCombine);

console.log(combinations);
/*
will output:
[
  { a: 'a', c: 1, e: { a: '1' } },
  { a: 'a', c: 1, e: { b: '2' } },
  { a: 'a', c: 2, e: { a: '1' } },
  { a: 'a', c: 2, e: { b: '2' } },
  { a: 'b', c: 1, e: { a: '1' } },
  { a: 'b', c: 1, e: { b: '2' } },
  { a: 'b', c: 2, e: { a: '1' } },
  { a: 'b', c: 2, e: { b: '2' } },
  { a: 'c', c: 1, e: { a: '1' } },
  { a: 'c', c: 1, e: { b: '2' } },
  { a: 'c', c: 2, e: { a: '1' } },
  { a: 'c', c: 2, e: { b: '2' } }
]
*/

The keymbinatorial function takes in an Nx1 object, where N is a set of keys that map to an array.

For each key in the object, the function builds up a list of objects containing a unique combination of keys to values in the array.

Testing

npm test

License

Code licensed under the BSD 3-Clause license. See LICENSE file for terms.

Keywords

FAQs

Package last updated on 03 Dec 2020

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