public
Last active

The heart of pd

  • Download Gist
0usage.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
var Parent = {
constructor: function constructor(magic) {
this.isMagic = magic
return this
},
method: function method() { }
}
 
var Mixin = {
mixinMethod: function () { }
}
 
var Child = extend({}, Parent, Mixin, {
constructor: function constructor(magic, count) {
this.count = count
return Parent.constructor.call(this, magic)
},
anotherMethod: function () { }
})
 
var instance = extend({}, Child).constructor(true, 10)
1pd.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14
var slice = Array.prototype.slice;
 
function extend(object) {
slice.call(arguments, 1).forEach(copyProperties);
return object;
 
function copyProperties(source) {
Object.getOwnPropertyNames(source).forEach(copyProperty);
 
function copyProperty(name) {
object[name] = source[name];
}
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.