permutate-array
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

npm

permutate-array

Permutate a seed to get a bunch of randomly similar permutations

Example

 
import { generateSeed, permutateArray } from 'permutate-array';
 
// Some corpus of allowed values
let corpus = ['a', 'b', 'c', 'd', 'e'];
 
// Generate a seed array with 3 values picked from the corpus of allowed values
let seed = generateSeed(corpus, 3);
 
// Get a set of permutations from the seed using the corpus of allowed values, the result will never incude the seed.
let result = permutateArray(seed, corpus, 3);
 
// Peek at the values
console.log(seed)
// [ 'a', 'd', 'e' ]
 
console.log(result)
// [ [ 'a', 'd', 'a' ], [ 'c', 'd', 'e' ], [ 'a', 'd', 'c' ] ]

Readme

Keywords

none

Package Sidebar

Install

npm i permutate-array

Weekly Downloads

1

Version

1.1.1

License

AGPL

Unpacked Size

41.5 kB

Total Files

8

Last publish

Collaborators

  • phayes