From 555e2f3345743410509914e60fb616e436fec726 Mon Sep 17 00:00:00 2001 From: Bram van der Veen <96aa48@gmail.com> Date: Tue, 28 Jun 2016 16:16:05 +0200 Subject: [PATCH] Moved prototype extenders to utils.js --- index.js | 26 -------------------------- utils.js | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/index.js b/index.js index f15952b..fe646ae 100644 --- a/index.js +++ b/index.js @@ -62,30 +62,4 @@ function generate() { console.log('generate elapsed', (((new Date()).getTime() - start) * 0.001).toFixed(3) + "s"); } -Array.prototype.indexContains = function(word) { - for (var idx = 0; idx < this.length; idx++) { - var test = this[idx]; - if (test.indexOf(word) >= 0 || word.indexOf(test) >= 0) { - return idx; - } - } - return -1; -} - -Math.clamp = function(a, min, max) { - return a < min ? min : (a > max ? max : a); -}; - -Array.prototype.insertAt = function(where, what) { - if (where < 0) { - this.splice(0, 0, what); - } else { - var tail = this.splice(where); - this.push(what) - for (var i = 0; i < tail.length; i++) { - this.push(tail[i]); - } - } -} - generate(); diff --git a/utils.js b/utils.js index c303816..e9c0c50 100644 --- a/utils.js +++ b/utils.js @@ -67,6 +67,32 @@ function kappatalize(str) { return str.charAt(0).toUpperCase() + str.slice(1); } +Array.prototype.indexContains = function(word) { + for (var idx = 0; idx < this.length; idx++) { + var test = this[idx]; + if (test.indexOf(word) >= 0 || word.indexOf(test) >= 0) { + return idx; + } + } + return -1; +} + +Math.clamp = function(a, min, max) { + return a < min ? min : (a > max ? max : a); +}; + +Array.prototype.insertAt = function(where, what) { + if (where < 0) { + this.splice(0, 0, what); + } else { + var tail = this.splice(where); + this.push(what) + for (var i = 0; i < tail.length; i++) { + this.push(tail[i]); + } + } +} + module.exports = { "random_name": random_name, "gravity": gravity,