octo-deno/make/strings.js

39 lines
827 B
JavaScript
Raw Normal View History

2017-04-12 20:23:15 +00:00
make.strings = {
toString: function (object) {
return object ? object.toSource() : '' + object
},
string: function (maxlen) {
let s = "";
if (maxlen == null || maxlen === undefined) {
2017-04-22 19:02:38 +00:00
maxlen = make.numbers.rangeNumber();
2017-04-12 20:23:15 +00:00
}
for (let i = 0; i < maxlen; i++) {
2017-04-22 19:02:38 +00:00
//s += String.fromCodePoint(Random.pick(make.fonts.layoutCharCodes));
2017-04-12 20:23:15 +00:00
s += "A"
}
return s;
},
quotedString: function (maxlen) {
2017-04-22 19:02:38 +00:00
return utils.common.quote(make.strings.string(maxlen));
2017-04-12 20:23:15 +00:00
},
stringFromBlocks: function (set, maxlen) {
let s = "";
for (let i = 0; i < random.number(maxlen || 255); i++) {
s += random.pick(set);
}
return s;
},
2017-04-13 00:05:17 +00:00
digitsHex: function (n) {
let s = '';
while (n-- > 0) {
2017-04-13 02:14:02 +00:00
s += (random.number(16)).toString(16);
2017-04-13 00:05:17 +00:00
}
return s;
},
2017-04-13 02:14:02 +00:00
};