summaryrefslogtreecommitdiff
path: root/js/utility.js
blob: fe1d0f19a2bb2586461df857be227225cbfe2431 (plain)
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
/**
 * Returns a random integer between min and max
 *
 * @param {Number} min
 * @param {Number} max
 * @return {Number}
 */
if (typeof Math.rangeInt != 'function') {
  Math.rangeInt = function(min, max){
  	if (max == undefined) {
  		max = min;
  		min = 0;
  	}
  	return Math.floor(Math.random() * (max - min + 1)) + min;
  }
}

/**
 * Mege two objects
 *
 * @param {Object} o1 Object 1
 * @param {Object} o2 Object 2
 * @return {Object}
 */
if (typeof Object.merge != 'function') {
  Object.merge = function(o1, o2) {
    for (var i in o1) {
      o2[i] = o1[i];
    }
    return o2;
  }
}