Skip to content

Commit

Permalink
param checking
Browse files Browse the repository at this point in the history
  • Loading branch information
MBR-0001 committed Feb 1, 2021
1 parent 9bf7157 commit 6f74b1a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,14 @@ class SourceQuery {
* @param {boolean} autoclose
*/
constructor(address, port, timeout = 1000, autoclose = true) {
if (!address) throw new Error("Invalid address");

let _port = Number(port);

if (_port == undefined || _port <= 0 || _port >= 65535 || isNaN(_port)) throw new Error("Invalid port");

this.address = String(address);
this.port = Number(port);
this.port = _port;
this.timeout = Number(timeout);
this.autoclose = Boolean(autoclose);

Expand Down

0 comments on commit 6f74b1a

Please sign in to comment.