octo-deno/make/strings.js

43 lines
1 KiB
JavaScript
Raw Normal View History

2017-04-22 20:16:47 +00:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
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
};