octo-deno/make/strings.js
2017-04-22 22:02:38 +03:00

38 lines
827 B
JavaScript

make.strings = {
toString: function (object) {
return object ? object.toSource() : '' + object
},
string: function (maxlen) {
let s = "";
if (maxlen == null || maxlen === undefined) {
maxlen = make.numbers.rangeNumber();
}
for (let i = 0; i < maxlen; i++) {
//s += String.fromCodePoint(Random.pick(make.fonts.layoutCharCodes));
s += "A"
}
return s;
},
quotedString: function (maxlen) {
return utils.common.quote(make.strings.string(maxlen));
},
stringFromBlocks: function (set, maxlen) {
let s = "";
for (let i = 0; i < random.number(maxlen || 255); i++) {
s += random.pick(set);
}
return s;
},
digitsHex: function (n) {
let s = '';
while (n-- > 0) {
s += (random.number(16)).toString(16);
}
return s;
},
};