Skip to content

Commit 94d4065

Browse files
committed
make the api>=3 check typecheck
1 parent 6133ce1 commit 94d4065

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Uwave.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

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

251-
if (typeof sourceFactory === 'function' && sourceFactory.api >= 3) {
252+
if (typeof sourceFactory === 'function'
253+
&& has(sourceFactory, 'api')
254+
&& typeof sourceFactory.api === 'number'
255+
&& sourceFactory.api >= 3) {
252256
throw new TypeError('uw.source() only supports old-style source plugins.');
253257
}
254258

0 commit comments

Comments
 (0)