bruteforce
v0.0.2
Published
generate every possible permutation of characters
Downloads
691
Maintainers
Readme
bruteforce
Generate all possible character permutations.
Example:
var bf = require('bruteforce');
bf({
len: 2,
chars: ['a', 'b'],
step: console.log
});
This example will produce the output:
a
aa
ab
b
ba
bb
Installation
via npm:
$ npm install --save bruteforce
API
bruteForce(params)
Return a list of character permutations. params
is an object with the following keys:
len
: maximum length of the permutationschars
: list of characters to usefilterSimilarChars
: filter out permutations in which the same character appears consecutively (see #1)prefix
(optional): a prefix that is added to all the permutations. This is a part of the length of each permutation, so it must be less than or equal tolen
.step
(optional): a function to call every time a permuation is generated. It is called with one parameter: the permutation that was generatedend
(optional): a function to call after all permutations have been generated. It is called with one argument: the list of all permutations that were generated, which will also be returned
License
MIT License. See ./LICENSE
for details.