Description
Hey Drew , I hope that you're doing well.
Thank you for your incredible working. I use your library for a small time ago, I found it really usefull and helpful.
Otherwise, for a use case, I need to generate all the possible combinations of letters and numbers. and I see that the results is random and it is not sorted. I need to sort them by my own and that cost memory and time to do this with javascript native sorting function.
For example
const regex = '[a-e][0-5]';
const expander = expand(regex);
console.log(expander);
// output => Expansion { getIterator: [Function: beginIterating], count: 30 }
in this small example I have just 30 examples ,
If I use expandN , it will give me a randomize order
const regex = '[a-e][0-5]';
const expander = expandN(regex,5);
/*
first run => [ 'b4', 'e3', 'a2', 'b3', 'b1' ]
second run => [ 'b5', 'c3', 'c0', 'b3', 'b0' ]
*/
I tried to use a workaround method using sort() and slice() like this
const regex = '[a-e][0-5]';
const expander = expandAll(regex).sort().slice(0, 5);
console.log(expander);
// output => [ 'a0', 'a1', 'a2', 'a3', 'a4' ]
But this is not practical, imagine I have millions of results, It will cost time and ressource to do this, and causing a memory leak in javascript.
It is better to add sorting for expand, expandAll() and expandN().
I don't know if already exists, please to add this feature.
otherwise, You can give me a clue how I can add it in the library and contribute with you.
My Best.