Add strings.js
This commit is contained in:
parent
b25df1051a
commit
44fef815d1
1 changed files with 31 additions and 0 deletions
31
make/strings.js
Normal file
31
make/strings.js
Normal 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;
|
||||
},
|
||||
}
|
Loading…
Reference in a new issue