mirror of
https://github.com/samsonjs/batteries.git
synced 2026-03-25 09:15:46 +00:00
18 lines
547 B
JavaScript
18 lines
547 B
JavaScript
exports.createExt = function() {
|
|
return new Ext()
|
|
}
|
|
|
|
var Ext = exports.Ext = function(){}
|
|
Ext.prototype = {
|
|
extend: function(obj) {
|
|
Object.keys(this).forEach(function(k) {
|
|
if (obj[k]) return // don't overwrite existing members
|
|
var fn = this[k]
|
|
obj[k] = function() {
|
|
// Like JavaScript itself functions effectively take `this` as the first param
|
|
var args = [].slice.call(arguments).shift(this)
|
|
fn.apply(null, args)
|
|
}
|
|
})
|
|
}
|
|
}
|