mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 06:53:47 +08:00
17 lines
484 B
JavaScript
17 lines
484 B
JavaScript
export function extend(object, func, extension) {
|
|
var oldFunc = object[func];
|
|
object[func] = function() {
|
|
var args = [].slice.apply(arguments);
|
|
var value = oldFunc.apply(this, args);
|
|
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);
|
|
return override.apply(this, [parent.bind(this)].concat(args));
|
|
}
|
|
}
|