I'm using node.js currently, and i would like to find / try all the unique possibilities resulting from the combinations of data stored in an array.
Example :
// source array
var array = [0,1,2];
// what i need :
0
1
2
00
01
02
10
11
12
20
21
22
000
001
002
etc, up to a configurable length.
I've looked on the forums and didn't manage to find something like this.
I've searched on npm and found some librairies that are doing similar things, but never all the possibilities i need. I'm feeling like my need is very similar to a bubble sorting algorithm, but i don't know how to do this.
Also it would be very much better to do it without storing the whole output in a variable at the same time, as the idea is that my code needs to work with larger arrays.
Any idea or solution i missed would help at this point !
Edit : Also, i would like to continuously try combination until i decide it's enough, such as 500 try or if the last combination length is 5 for example.