The object that owns the method
The name or names of the method(s) to extend
A callback which mutates the method's output
Rest
...args: Parameters<T[K]>Example usage of extending one method.
extend(Discussion.prototype, 'badges', function(badges) {
// do something with `badges`
});
Example usage of extending multiple methods.
extend(IndexPage.prototype, ['oncreate', 'onupdate'], function(vnode) {
// something that needs to be run on creation and update
});
Generated using TypeDoc v0.24.8
Extend an object's method by running its output through a mutating callback every time it is called.
The callback accepts the method's return value and should perform any mutations directly on this value. For this reason, this function will not be effective on methods which return scalar values (numbers, strings, booleans).
Care should be taken to extend the correct object – in most cases, a class' prototype will be the desired target of extension, not the class itself.