Properly check whether an Opus engine exists (#1150)

* Properly check whether an Opus engine exists

I think I'm retarded

* Fix eslint error

* Update OpusEngineList.js
This commit is contained in:
Programmix
2017-01-30 13:38:47 -08:00
committed by Schuyler Cebulskie
parent 7ed58f5f7f
commit 78dafb9480

View File

@@ -3,6 +3,8 @@ const list = [
require('./OpusScriptEngine'),
];
let opusEngineFound;
function fetch(Encoder) {
try {
return new Encoder();
@@ -24,5 +26,6 @@ exports.fetch = () => {
};
exports.guaranteeOpusEngine = () => {
if (!this.opusEncoder) throw new Error('Couldn\'t find an Opus engine.');
if (typeof opusEngineFound === 'undefined') opusEngineFound = Boolean(exports.fetch());
if (!opusEngineFound) throw new Error('Couldn\'t find an Opus engine.');
};