Skip to content

Commit

Permalink
Catch and ignore errors importing wrap_native.js (uses async* N/A on …
Browse files Browse the repository at this point in the history
…Node 8)
  • Loading branch information
davedoesdev committed Feb 11, 2020
1 parent eed2e0e commit 202df0c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
13 changes: 10 additions & 3 deletions aedes/qlobber-sub.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,16 @@ QlobberSub.prototype.clear = function ()

QlobberSub.set_native = function (qlobber_native)
{
const wrap_native = require('../lib/wrap_native.js');
QlobberSub.native = wrap_native(qlobber_native.QlobberSub, QlobberSub);
return module.exports;
// wrap_native.js uses 'async *' which isn't available on Node 8
try
{
const wrap_native = require('../lib/wrap_native.js');
QlobberSub.native = wrap_native(qlobber_native.QlobberSub, QlobberSub);
return module.exports;
}
catch (ex)
{
}
};

module.exports = QlobberSub;
20 changes: 14 additions & 6 deletions lib/qlobber.js
Original file line number Diff line number Diff line change
Expand Up @@ -1070,12 +1070,20 @@ Add [qlobber-native](https://www.npmjs.com/package/qlobber-native) to qlobber.
*/
function set_native(qlobber_native)
{
const wrap_native = require('./wrap_native.js');
Qlobber.nativeString = wrap_native(qlobber_native.QlobberString, Qlobber);
Qlobber.nativeNumber = wrap_native(qlobber_native.QlobberNumber, Qlobber);
QlobberDedup.nativeString = wrap_native(qlobber_native.QlobberDedupString, QlobberDedup);
QlobberDedup.nativeNumber = wrap_native(qlobber_native.QlobberDedupNumber, QlobberDedup);
QlobberTrue.native = wrap_native(qlobber_native.QlobberTrue, QlobberTrue);
// wrap_native.js uses 'async *' which isn't available on Node 8
try
{
const wrap_native = require('./wrap_native.js');
Qlobber.nativeString = wrap_native(qlobber_native.QlobberString, Qlobber);
Qlobber.nativeNumber = wrap_native(qlobber_native.QlobberNumber, Qlobber);
QlobberDedup.nativeString = wrap_native(qlobber_native.QlobberDedupString, QlobberDedup);
QlobberDedup.nativeNumber = wrap_native(qlobber_native.QlobberDedupNumber, QlobberDedup);
QlobberTrue.native = wrap_native(qlobber_native.QlobberTrue, QlobberTrue);
}
catch (ex)
{
}

return exports;
}

Expand Down

0 comments on commit 202df0c

Please sign in to comment.