-
Notifications
You must be signed in to change notification settings - Fork 275
Expand file tree
/
Copy pathcommon.js
More file actions
59 lines (53 loc) · 1.35 KB
/
Copy pathcommon.js
File metadata and controls
59 lines (53 loc) · 1.35 KB
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
56
57
58
59
'use strict';
/**
* Server ip addresses that get used during the tests
* NOTE! Make sure you configure empty servers as they
* will get flushed!.
*
* If your memcache hosts is not the default one
* (10.211.55.5), you can pass another one using the
* environment variable MEMCACHED__HOST. E.g.:
*
* MEMCACHED__HOST=localhost npm test
*
* @type {Object}
* @api public
*/
var testMemcachedHost = process.env.MEMCACHED__HOST || '10.211.55.5';
var testMemcachedSocketPath = process.env.MEMCACHED__SOCKET_PATH;
exports.servers = {
single: testMemcachedHost + ':11211',
singleSocket: testMemcachedSocketPath
, multi: [
testMemcachedHost + ':11211'
, testMemcachedHost + ':11212'
, testMemcachedHost + ':11213'
, testMemcachedSocketPath
]
};
/**
* Generate a random alphabetical string.
*
* @param {Number} n The length of the generated string
* @returns {String} a random generated string
* @api public
*/
exports.alphabet = function alphabet(n){
for (var a = '', i = 0; i < n; i++) {
a += String.fromCharCode(97 + Math.floor(Math.random() * 26));
}
return a;
};
/**
* Generate a bunch of random numbers
*
* @param {Number} n the amount of numbers
* @returns {Number}
* @api public
*/
exports.numbers = function numbers(n){
for (var a = 0, i = 0; i < n; i++) {
a += Math.floor(Math.random() * 26);
}
return a;
};