This repository has been archived on 2024-02-25. You can view files and clone it, but cannot push or open issues or pull requests.
galaxygen/utils.js
Bram van der Veen 3a8803318b Updated the code to the new version found on loewald.com/galaxygen
(after some heavy refactoring)
2017-01-24 19:56:57 +01:00

22 lines
508 B
JavaScript

Math.clamp = function(a, min, max) {
return a < min ? min : (a > max ? max : a);
};
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;
};
String.prototype.capitalize = function() {
if (this) {
return this.substr(0, 1).toUpperCase() + this.substr(1);
} else {
return '';
}
};