diff options
Diffstat (limited to 'js/lib/prototypes.js')
-rw-r--r-- | js/lib/prototypes.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/js/lib/prototypes.js b/js/lib/prototypes.js new file mode 100644 index 000000000..0f0014818 --- /dev/null +++ b/js/lib/prototypes.js @@ -0,0 +1,44 @@ +/** + * + */ +if (!Array.prototype.every) { + Array.prototype.every = function(callback) { + var len = this.length, i; + + for (i = 0; i < len; i++) { + if (i in this && !callback.call(null, this[i], i)) { + return false; + } + } + + return true; + }; +} + +/** + * + */ +if (!Array.prototype.forEach) { + Array.prototype.forEach = function(callback) { + var len = this.length, i; + + for (i = 0; i < len; i++) { + if (i in this) { + callback.call(null, this[i], i); + } + } + }; +} + +/** + * + */ +if (!String.prototype.ltrim) { + String.prototype.ltrim = function(str) { + if (this.indexOf(str) === 0) { + return this.substring(str.length); + } else { + return this; + } + }; +}
\ No newline at end of file |