framework/js/lib/extension-utils.js
Toby Zerner 220c1ac2d1 Change extend function so that a value doesn't have to be returned
override should be used instead to override the return value.
2015-05-05 17:04:42 +09:30

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));
}
};