Skip to content

Commit

Permalink
make the api>=3 check typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Nov 2, 2021
1 parent 6133ce1 commit 94d4065
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Uwave.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const has = require('has');
const EventEmitter = require('events');
const { promisify } = require('util');
const mongoose = require('mongoose');
Expand Down Expand Up @@ -248,7 +249,10 @@ class UwaveServer extends EventEmitter {
throw new TypeError(`Source plugin should be a function, got ${typeof sourceFactory}`);
}

if (typeof sourceFactory === 'function' && sourceFactory.api >= 3) {
if (typeof sourceFactory === 'function'
&& has(sourceFactory, 'api')
&& typeof sourceFactory.api === 'number'
&& sourceFactory.api >= 3) {
throw new TypeError('uw.source() only supports old-style source plugins.');
}

Expand Down

0 comments on commit 94d4065

Please sign in to comment.