From eb5b4dc8edf86618d6525726e09fada47ec2d02d Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Wed, 9 Dec 2020 11:42:24 +0100 Subject: [PATCH] chore: apply suggestions from code review Co-authored-by: Irakli Gozalishvili --- .github/workflows/main.yml | 4 ++-- src/circuit/circuit/stop.js | 4 ++-- src/circuit/circuit/stream-handler.js | 1 + src/connection-manager/index.js | 1 - src/content-routing.js | 6 +++--- src/ping/index.js | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8641a8a52d..ade1dcbcc0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v2 - run: yarn - run: yarn lint - # - uses: gozala/typescript-error-reporter-action@v1.0.4 + - uses: gozala/typescript-error-reporter-action@v1.0.8 - run: yarn build - run: yarn aegir dep-check - uses: ipfs/aegir/actions/bundle-size@master @@ -64,4 +64,4 @@ jobs: steps: - uses: actions/checkout@v2 - run: yarn - - run: cd examples && yarn && npm run test -- auto-relay \ No newline at end of file + - run: cd examples && yarn && npm run test -- auto-relay diff --git a/src/circuit/circuit/stop.js b/src/circuit/circuit/stop.js index 16192ad563..827d68d3ad 100644 --- a/src/circuit/circuit/stop.js +++ b/src/circuit/circuit/stop.js @@ -19,7 +19,7 @@ const { validateAddrs } = require('./utils') * Handles incoming STOP requests * * @private - * @param {object} options + * @param {Object} options * @param {Connection} options.connection * @param {CircuitPB} options.request - The CircuitRelay protobuf request (unencoded) * @param {StreamHandler} options.streamHandler @@ -50,7 +50,7 @@ module.exports.handleStop = function handleStop ({ * Creates a STOP request * * @private - * @param {object} options + * @param {Object} options * @param {Connection} options.connection * @param {CircuitPB} options.request - The CircuitRelay protobuf request (unencoded) * @returns {Promise} Resolves a duplex iterable diff --git a/src/circuit/circuit/stream-handler.js b/src/circuit/circuit/stream-handler.js index b63dcbff4e..d94576c5ce 100644 --- a/src/circuit/circuit/stream-handler.js +++ b/src/circuit/circuit/stream-handler.js @@ -48,6 +48,7 @@ class StreamHandler { * Encode and write array of buffers * * @param {CircuitPB} msg - An unencoded CircuitRelay protobuf message + * @returns {void} */ write (msg) { log('write message type %s', msg.type) diff --git a/src/connection-manager/index.js b/src/connection-manager/index.js index 4ebbd8371e..4add4840e1 100644 --- a/src/connection-manager/index.js +++ b/src/connection-manager/index.js @@ -52,7 +52,6 @@ const defaultOptions = { */ /** - * @extends EventEmitter * * @fires ConnectionManager#peer:connect Emitted when a new peer is connected. * @fires ConnectionManager#peer:disconnect Emitted when a peer is disconnected. diff --git a/src/content-routing.js b/src/content-routing.js index d2989d817c..63599be567 100644 --- a/src/content-routing.js +++ b/src/content-routing.js @@ -72,7 +72,7 @@ class ContentRouting { * @param {CID} key - The CID key of the content to find * @returns {Promise} */ - async provide (key) { // eslint-disable-line require-await + provide (key) { if (!this.routers.length) { throw errCode(new Error('No content routers available'), 'NO_ROUTERS_AVAILABLE') } @@ -89,7 +89,7 @@ class ContentRouting { * @param {number} [options.minPeers] - minimum number of peers required to successfully put * @returns {Promise} */ - async put (key, value, options) { // eslint-disable-line require-await + put (key, value, options) { if (!this.libp2p.isStarted() || !this.dht.isStarted) { throw errCode(new Error(messages.NOT_STARTED_YET), codes.DHT_NOT_STARTED) } @@ -106,7 +106,7 @@ class ContentRouting { * @param {number} [options.timeout] - optional timeout (default: 60000) * @returns {Promise} */ - async get (key, options) { // eslint-disable-line require-await + get (key, options) { if (!this.libp2p.isStarted() || !this.dht.isStarted) { throw errCode(new Error(messages.NOT_STARTED_YET), codes.DHT_NOT_STARTED) } diff --git a/src/ping/index.js b/src/ping/index.js index 53e3f67930..eb8d7b96e9 100644 --- a/src/ping/index.js +++ b/src/ping/index.js @@ -33,7 +33,7 @@ async function ping (node, peer) { const { stream } = await node.dialProtocol(peer, PROTOCOL) - const start = new Date().getTime() + const start = Date.now() const data = crypto.randomBytes(PING_LENGTH) const [result] = await pipe(