@oat-sa/tao-item-runner-qti
Version:
TAO QTI Item Runner modules
21 lines (20 loc) • 884 B
JavaScript
//@todo : need refactoring of qti item mixin with lodash.mixin()
export default {
augment: function(targetClass, methods, options) {
if (typeof targetClass === 'function' && typeof methods === 'object') {
for (var methodName in methods) {
if (!Object.hasOwnProperty(targetClass.prototype, methodName)) {
targetClass.prototype[methodName] = methods[methodName];
} else {
if (options && options.append) {
var _parent = targetClass.prototype[methodName];
targetClass.prototype[methodName] = function() {
methods[methodName].apply(this, arguments);
return _parent.apply(this, arguments);
};
}
}
}
}
}
};