From 6484b9869c5d63f11e59f76fc7325fedd6b78b34 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Tue, 6 Apr 2021 15:35:59 +0200 Subject: [PATCH] chore: apply suggestions from code review Co-authored-by: Hugo Dias --- src/ip-port-to-multiaddr.js | 5 +++-- src/stream-to-ma-conn.js | 4 ++-- tsconfig.json | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ip-port-to-multiaddr.js b/src/ip-port-to-multiaddr.js index 85a9751..7540f2e 100644 --- a/src/ip-port-to-multiaddr.js +++ b/src/ip-port-to-multiaddr.js @@ -21,8 +21,9 @@ function ipPortToMultiaddr (ip, port) { throw errCode(new Error(`invalid ip provided: ${ip}`), errors.ERR_INVALID_IP_PARAMETER) } - // @ts-ignore parseInt expects only string - port = parseInt(port) + if (typeof port === 'string') { + port = parseInt(port) + } if (isNaN(port)) { throw errCode(new Error(`invalid port provided: ${port}`), errors.ERR_INVALID_PORT_PARAMETER) diff --git a/src/stream-to-ma-conn.js b/src/stream-to-ma-conn.js index 55be5bb..e1ce4ab 100644 --- a/src/stream-to-ma-conn.js +++ b/src/stream-to-ma-conn.js @@ -1,6 +1,6 @@ 'use strict' -const abortable = require('abortable-iterator') +const { source: abortable } = require('abortable-iterator') const debug = require('debug') const log = debug('libp2p:stream:converter') @@ -34,7 +34,7 @@ function streamToMaConnection ({ stream, remoteAddr, localAddr }, options = {}) */ async sink (source) { if (options.signal) { - // @ts-ignore abortable has no type definitions + // @ts-ignore ts infers source template will be a number source = abortable(source, options.signal) } diff --git a/tsconfig.json b/tsconfig.json index 5b9a618..5fe8ea4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,9 @@ { - "extends": "./node_modules/aegir/src/config/tsconfig.aegir.json", + "extends": "aegir/src/config/tsconfig.aegir.json", "compilerOptions": { "outDir": "dist" }, "include": [ "src" ] -} \ No newline at end of file +}