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

22 lines
508 B
JavaScript
Raw Normal View History

Math.clamp = function(a, min, max) {
return a < min ? min : (a > max ? max : a);
};
2016-06-28 16:13:28 +02:00
2016-06-28 16:16:05 +02:00
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);
2016-06-28 16:16:05 +02:00
} else {
return '';
2016-06-28 16:16:05 +02:00
}
};