Add strings.js

This commit is contained in:
Christoph Diehl 2017-04-12 23:23:15 +03:00
parent b25df1051a
commit 44fef815d1

31
make/strings.js Normal file
View file

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