first commit

This commit is contained in:
Stefan Hacker
2026-04-03 09:38:48 +02:00
commit 37ad745546
47450 changed files with 3120798 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.randomString = void 0;
function randomString(token) {
if (typeof token === 'string')
return token;
const rnd = Math.random();
switch (token[0]) {
case 'pick': {
const set = token[1];
return set[Math.floor(rnd * set.length)];
}
case 'repeat': {
const min = token[1];
const max = token[2];
const pattern = token[3];
const count = Math.floor(rnd * (max - min + 1)) + min;
let str = '';
for (let i = 0; i < count; i++)
str += randomString(pattern);
return str;
}
case 'range': {
const min = token[1];
const max = token[2];
const codePoint = Math.floor(rnd * (max - min + 1)) + min;
return String.fromCodePoint(codePoint);
}
case 'list':
return token[1].map(randomString).join('');
default:
throw new Error('Invalid token type');
}
}
exports.randomString = randomString;
//# sourceMappingURL=string.js.map