Skip to content

Instantly share code, notes, and snippets.

@robozevel
robozevel / ES5 Object.extend.js
Last active December 24, 2015 07:29 — forked from livingston/ES5 Extend & Clone Objects.js
ES5 Object.extend
Object.defineProperty(Object, "extend", {
enumerable: false,
value: function extend(obj) {
Array.prototype.slice.call(arguments, 1).forEach(function(current) {
Object.getOwnPropertyNames(current).forEach(function(key) {
Object.defineProperty(obj, key, Object.getOwnPropertyDescriptor(current, key));
});
});
return obj;
}
@robozevel
robozevel / deparam.js
Last active August 19, 2016 08:40 — forked from emilisto/deparam.js
// deparam
//
// Inverse of $.param()
//
// Taken from jquery-bbq by Ben Alman
// https://github.com/cowboy/jquery-bbq/blob/master/jquery.ba-bbq.js
var isArray = Array.isArray || function(obj) {
return Object.prototype.toString.call(obj) == '[object Array]';
};
@robozevel
robozevel / RegExp.Safe.js
Created November 25, 2012 00:15 — forked from nathansmith/escape_regex.js
Escape characters that could break regex.
(function(replace) {
var escape = [/[\-\[\]\/\\{}()*+?.^$|]/g, '\\$&'];
RegExp.Safe = function(pattern, flags) {
return new RegExp(replace.apply(String(pattern), escape), flags);
}
}(String.prototype.replace));
@robozevel
robozevel / inheritance.js
Created July 7, 2012 11:02 — forked from gunderwonder/inheritance.js
A simple JavaScript inheritance system
/*
* A simple JavaScript inheritance system
* (Like Prototype's `Class.create()`, only without the crazy method wrapping and function decompilation)
*
* Usage
* var A = Class.create({
* // `$init` is the constructor
* $init: function(x, y) {
* this.x = x;
* this.y = y;