Skip to content

Instantly share code, notes, and snippets.

View owenroberts's full-sized avatar

Owen Roberts owenroberts

View GitHub Profile
@owenroberts
owenroberts / cool.js
Last active March 7, 2024 15:43
Some helpers for various projects
/* some helpers */
Array.prototype.insert = function(index, item) {
this.splice(index, 0, item);
};
Number.prototype.clamp = function(min, max) {
return max > min ?
Math.min(Math.max(this, min), max) :
Math.min(Math.max(this, max), min);
};