2015-04-25 20:58:39 +08:00
|
|
|
export function extend(object, func, extension) {
|
|
|
|
var oldFunc = object[func];
|
|
|
|
object[func] = function() {
|
|
|
|
var args = [].slice.apply(arguments);
|
2015-05-02 07:16:38 +08:00
|
|
|
var value = oldFunc.apply(this, args);
|
2015-04-25 20:58:39 +08:00
|
|
|
return extension.apply(this, [value].concat(args));
|
|
|
|
}
|
|
|
|
};
|
2015-05-02 07:16:38 +08:00
|
|
|
|
|
|
|
export function override(object, func, override) {
|
|
|
|
var parent = object[func];
|
|
|
|
object[func] = function() {
|
|
|
|
var args = [].slice.apply(arguments);
|
2015-05-04 09:00:29 +08:00
|
|
|
return override.apply(this, [parent.bind(this)].concat(args));
|
2015-05-02 07:16:38 +08:00
|
|
|
}
|
|
|
|
}
|