Commit | Line | Data |
---|---|---|
1 | function randString() | |
2 | { | |
3 | return Math.random().toString(36).substr(2); // remove `0.` | |
4 | } | |
5 | ||
6 | module.exports = function(tlen) | |
7 | { | |
8 | let res = ""; | |
9 | let nbRands = Math.ceil(tlen/10); //10 = min length of a rand() string | |
10 | for (let i = 0; i < nbRands; i++) | |
11 | res += randString(); | |
12 | return res.substr(0, tlen); | |
13 | } |