summaryrefslogtreecommitdiff
path: root/js/utility.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/utility.js')
-rw-r--r--js/utility.js30
1 files changed, 24 insertions, 6 deletions
diff --git a/js/utility.js b/js/utility.js
index a59841f..fe1d0f1 100644
--- a/js/utility.js
+++ b/js/utility.js
@@ -5,10 +5,28 @@
* @param {Number} max
* @return {Number}
*/
-Math.rangeInt = function(min, max){
- if (max == undefined) {
- max = min;
- min = 0;
- }
- return Math.floor(Math.random() * (max - min + 1)) + min;
+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;
+ }
}