1.2.3 • Published 4 years ago

@drewkimberly/permutations v1.2.3

Weekly downloads
10
License
Apache-2.0
Repository
github
Last release
4 years ago

NodeJS Object Permutations

Function to generate all permutations of data given zero or more arrays associated with properties in an object

Build Status Code Style: Google

Installation

npm install @drewkimberly/permutations

Usage

import {generatePermutations} from "@drewkimbery/permutations";

const obj = {
  pilot: ["Han Solo", "Lando Calrissian"],
    copilot: ["Chewbacca", "Rey"],
    ship: "Falcon",
    speed: "1.5c"
};

console.log(generatePermutations(obj));

The above will output:

[
  {
    "pilot": "Han Solo",
    "copilot": "Chewbacca",
    "ship": "Falcon",
    "speed": "1.5c"
  },
  {
    "pilot": "Han Solo",
    "copilot": "Rey",
    "ship": "Falcon",
    "speed": "1.5c"
  },
  {
    "pilot": "Lando Calrissian",
    "copilot": "Chewbacca",
    "ship": "Falcon",
    "speed": "1.5c"
  },
  {
    "pilot": "Lando Calrissian",
    "copilot": "Rey",
    "ship": "Falcon",
    "speed": "1.5c"
  }
]

Performance

Performance starts to tail off as 1,000,000 permutations is closed in on. After that it's quite computationally expensive and you'll quickly run into heap memory issues. Check out the "Performance Testing" test suite (commented out by default) to play around.

Development

Requirements

  • NodeJS

Installing Dependencies

npm i

Running Code Lint

npm run check

Running Tests

npm run test

Running the Build process

npm run build

CI/CD

CI/CD is performed with TravisCI. When a tag is pushed Travis will publish the tag to NPM. See travis.yml for details.

1.2.3

4 years ago

2.0.1

4 years ago

1.2.2

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.2.1

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

0.1.0

4 years ago