diff --git a/src/js/tech/tech.js b/src/js/tech/tech.js index 4c31873f90..b1d8f18fd9 100644 --- a/src/js/tech/tech.js +++ b/src/js/tech/tech.js @@ -572,32 +572,25 @@ Tech.withSourceHandlers = function(_Tech){ * When using a source handler, prefer its implementation of * any function normally provided by the tech. */ - let techProto = _Tech.prototype; let deferrable = [ 'seekable', 'duration' ]; - Object.keys(techProto) - .filter(function onlyFunctions(key) { - return typeof this[key] === 'function'; - }, techProto) - .filter(function onlyDeferrableKeys(key) { - return Boolean(deferrable.indexOf(key) + 1); - }, techProto) - .map(function getFunctions(key) { - return this[key]; - }, techProto) - .forEach(function wrapFunctions(originalFn) { - let fnName = originalFn.name; - - this[fnName] = function() { - if (this.sourceHandler_ && this.sourceHandler_[fnName]) { - return this.sourceHandler_[fnName].apply(this.sourceHandler_, arguments); - } - return originalFn.apply(this, arguments); - }; - }, techProto); + deferrable.forEach(function (fnName) { + let originalFn = this[fnName]; + + if (typeof originalFn !== 'function') { + return; + } + + this[fnName] = function() { + if (this.sourceHandler_ && this.sourceHandler_[fnName]) { + return this.sourceHandler_[fnName].apply(this.sourceHandler_, arguments); + } + return originalFn.apply(this, arguments); + }; + }, _Tech.prototype); /* * Create a function for setting the source using a source object