permutate-array
Randomly permutate an array from an optinal seed, generating set of arrays that similar to the seed array
Last updated 4 months ago by phayes .
AGPL · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install permutate-array 
SYNC missed versions from official npm registry.

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' ] ]

Current Tags

  • 1.1.1                                ...           latest (4 months ago)

6 Versions

  • 1.1.1                                ...           4 months ago
  • 1.1.0                                ...           4 months ago
  • 1.0.3                                ...           4 months ago
  • 1.0.2                                ...           4 months ago
  • 1.0.1                                ...           4 months ago
  • 1.0.0                                ...           4 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |