Skip to content

Instantly share code, notes, and snippets.

View letsgetrandy's full-sized avatar

Randy letsgetrandy

View GitHub Profile
function Handler(fn) {
this.func = fn;
return this;
}
Handler.prototype.handle = function(errMsg, callback) {
this.exceptions[errMsg] = callback;
}
Handler.prototype.try = function(context) {
context = context || this;
try {
// return an array of argument names
function getArgNames(fn) {
var matches = fn.toString().match(/\(([a-z_, ]+)\)/i);
if (matches.length > 1) {
return matches[1].replace(/\s+/g, '').split(',');
}
return [];
}
// some sample implementation
'use strict';
var INTERVAL = 50;
class Bubble {
constructor() {
this.x = parseInt(window.innerWidth * Math.random(), 10);
this.y = parseInt(window.innerHeight * Math.random(), 10);
this.xDir = Math.random() > 0.5 ? 1 : -1;
this.yDir = Math.random() > 0.5 ? 1 : -1;
this.size = parseInt(Math.random() * 100) + 40;