framework/js/lib/extension-utils.js

17 lines
484 B
JavaScript
Raw Normal View History

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);
var value = oldFunc.apply(this, args);
2015-04-25 20:58:39 +08:00
return extension.apply(this, [value].concat(args));
}
};
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));
}
}