Change extend function so that a value doesn't have to be returned

override should be used instead to override the return value.
This commit is contained in:
Toby Zerner 2015-05-05 17:04:42 +09:30
parent 7e1b343900
commit d4e8276b3f

View File

@ -1,16 +1,17 @@
export function extend(object, func, extension) { export function extend(object, func, extension) {
var oldFunc = object[func]; var original = object[func];
object[func] = function() { object[func] = function() {
var args = [].slice.apply(arguments); var args = [].slice.apply(arguments);
var value = oldFunc.apply(this, args); var value = original.apply(this, args);
return extension.apply(this, [value].concat(args)); extension.apply(this, [value].concat(args));
return value;
} }
}; };
export function override(object, func, override) { export function override(object, func, override) {
var parent = object[func]; var original = object[func];
object[func] = function() { object[func] = function() {
var args = [].slice.apply(arguments); var args = [].slice.apply(arguments);
return override.apply(this, [parent.bind(this)].concat(args)); return override.apply(this, [original.bind(this)].concat(args));
} }
} };