2017-04-22 22:49:49 +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/. */
|
|
|
|
|
|
|
|
make.strings = {
|
|
|
|
toString: function (object) {
|
2017-04-25 22:21:31 +00:00
|
|
|
return object ? object.toSource() : '' + object
|
2017-04-22 22:49:49 +00:00
|
|
|
},
|
|
|
|
string: function (maxlen) {
|
2017-04-25 22:21:31 +00:00
|
|
|
let s = ''
|
2017-04-22 22:49:49 +00:00
|
|
|
|
2017-04-25 15:22:15 +00:00
|
|
|
if (maxlen === null || maxlen === undefined) {
|
2017-04-25 22:21:31 +00:00
|
|
|
maxlen = make.number.rangeNumber()
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = 0; i < maxlen; i++) {
|
2017-04-25 22:21:31 +00:00
|
|
|
// Todo: s += String.fromCodePoint(Random.pick(make.fonts.layoutCharCodes));
|
|
|
|
s += 'A'
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
|
|
|
|
2017-04-25 22:21:31 +00:00
|
|
|
return s
|
2017-04-22 22:49:49 +00:00
|
|
|
},
|
|
|
|
quotedString: function (maxlen) {
|
2017-04-25 22:21:31 +00:00
|
|
|
return utils.common.quote(make.strings.string(maxlen))
|
2017-04-22 22:49:49 +00:00
|
|
|
},
|
|
|
|
stringFromBlocks: function (set, maxlen) {
|
2017-04-25 22:21:31 +00:00
|
|
|
let s = ''
|
2017-04-22 22:49:49 +00:00
|
|
|
|
|
|
|
for (let i = 0; i < random.number(maxlen || 255); i++) {
|
2017-04-25 22:21:31 +00:00
|
|
|
s += random.pick(set)
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
|
|
|
|
2017-04-25 22:21:31 +00:00
|
|
|
return s
|
2017-04-22 22:49:49 +00:00
|
|
|
},
|
|
|
|
digitsHex: function (n) {
|
2017-04-25 22:21:31 +00:00
|
|
|
let s = ''
|
2017-04-22 22:49:49 +00:00
|
|
|
while (n-- > 0) {
|
2017-04-25 22:21:31 +00:00
|
|
|
s += (random.number(16)).toString(16)
|
2017-04-22 22:49:49 +00:00
|
|
|
}
|
2017-04-25 22:21:31 +00:00
|
|
|
return s
|
|
|
|
}
|
|
|
|
}
|