-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrandom.js
55 lines (54 loc) · 1.3 KB
/
random.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Generated by CoffeeScript 2.0.0-beta7
void function () {
var randomElement, randomInt, randomLineTerminator;
exports.randomBool = function (parm = 0.5) {
return Math.random() < parm;
};
exports.randomInt = randomInt = function (max) {
return Math.floor(Math.random() * (max + 1));
};
exports.randomElement = randomElement = function (list) {
return list[randomInt(list.length - 1)];
};
exports.randomWhitespace = function () {
return randomElement([
'\t',
'\x0B',
'\f',
'\ufeff',
' ',
'\xa0',
'\u180e',
'\u2000',
'\u2001',
'\u2002',
'\u2003',
'\u2004',
'\u2005',
'\u2006',
'\u2007',
'\u2008',
'\u2009',
'\u200a',
'\u202f',
'\u205f',
'\u3000'
]);
};
randomLineTerminator = function () {
return randomElement([
'\n',
'\r',
'\u2028',
'\u2029'
]);
};
exports.randomString = randomString = function () {
return function (accum$) {
while (Math.random() < .9) {
accum$.push(String.fromCharCode(32 + randomInt(94)));
}
return accum$;
}.call(this, []).join('');
}
}.call(this);