🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

id-permutations

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

id-permutations

ID <-> Permutations

latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

id-permutations

Blazing fast algorithms for generating a list of permutations for a given id, or the id from its corresponding permutation.

Example

const N_POSITIONS = 10;
const {
  getPermutationsFromId,
  getIdFromPermutations,
} = require('id-permutations')(N_POSITIONS);

getPermutationsFromId(0);       // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
getPermutationsFromId(1); // => [1, 0, 2, 3, 4, 5, 6, 7, 8, 9]
getPermutationsFromId(2); // => [2, 0, 1, 3, 4, 5, 6, 7, 8, 9]
getPermutationsFromId(3628799); // => [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

getIdFromPermutations([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); // => 0
getIdFromPermutations([1, 0, 2, 3, 4, 5, 6, 7, 8, 9]); // => 1
getIdFromPermutations([2, 0, 1, 3, 4, 5, 6, 7, 8, 9]); // => 2
getIdFromPermutations([9, 8, 7, 6, 5, 4, 3, 2, 1, 0]); // => 3628799

FAQs

Package last updated on 05 Nov 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