mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 21:43:38 +08:00
220c1ac2d1
override should be used instead to override the return value.
18 lines
502 B
JavaScript
18 lines
502 B
JavaScript
export function extend(object, func, extension) {
|
|
var original = object[func];
|
|
object[func] = function() {
|
|
var args = [].slice.apply(arguments);
|
|
var value = original.apply(this, args);
|
|
extension.apply(this, [value].concat(args));
|
|
return value;
|
|
}
|
|
};
|
|
|
|
export function override(object, func, override) {
|
|
var original = object[func];
|
|
object[func] = function() {
|
|
var args = [].slice.apply(arguments);
|
|
return override.apply(this, [original.bind(this)].concat(args));
|
|
}
|
|
};
|