diff --git a/.gitignore b/.gitignore index 1531bdf..7ad9e67 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ node_modules +build dist .docs .coverage +node_modules package-lock.json yarn.lock +.vscode diff --git a/package.json b/package.json index b33e551..0a9b55e 100644 --- a/package.json +++ b/package.json @@ -189,10 +189,9 @@ "uint8arraylist": "^2.3.2" }, "devDependencies": { - "aegir": "^37.2.0", + "aegir": "^38.1.7", "it-all": "^2.0.0", "it-map": "^2.0.0", - "it-pair": "^2.0.2", "it-pipe": "^2.0.2", "p-defer": "^4.0.0", "uint8arrays": "^4.0.2" diff --git a/src/array-equals.ts b/src/array-equals.ts index 21db488..e94499a 100644 --- a/src/array-equals.ts +++ b/src/array-equals.ts @@ -21,8 +21,8 @@ * Verify if two arrays of non primitive types with the "equals" function are equal. * Compatible with multiaddr, peer-id and others. */ -export function arrayEquals (a: any[], b: any[]) { - const sort = (a: any, b: any) => a.toString().localeCompare(b.toString()) +export function arrayEquals (a: any[], b: any[]): boolean { + const sort = (a: any, b: any): number => a.toString().localeCompare(b.toString()) if (a.length !== b.length) { return false diff --git a/src/ip-port-to-multiaddr.ts b/src/ip-port-to-multiaddr.ts index 35144d0..bb80dcb 100644 --- a/src/ip-port-to-multiaddr.ts +++ b/src/ip-port-to-multiaddr.ts @@ -1,5 +1,5 @@ import { logger } from '@libp2p/logger' -import { multiaddr } from '@multiformats/multiaddr' +import { Multiaddr, multiaddr } from '@multiformats/multiaddr' import { CodeError } from '@libp2p/interfaces/errors' import { Address4, Address6 } from '@achingbrain/ip-address' @@ -14,7 +14,7 @@ export const Errors = { /** * Transform an IP, Port pair into a multiaddr */ -export function ipPortToMultiaddr (ip: string, port: number | string) { +export function ipPortToMultiaddr (ip: string, port: number | string): Multiaddr { if (typeof ip !== 'string') { throw new CodeError(`invalid ip provided: ${ip}`, Errors.ERR_INVALID_IP_PARAMETER) // eslint-disable-line @typescript-eslint/restrict-template-expressions } diff --git a/src/multiaddr/is-loopback.ts b/src/multiaddr/is-loopback.ts index d676a66..d66f545 100644 --- a/src/multiaddr/is-loopback.ts +++ b/src/multiaddr/is-loopback.ts @@ -4,7 +4,7 @@ import type { Multiaddr } from '@multiformats/multiaddr' /** * Check if a given multiaddr is a loopback address. */ -export function isLoopback (ma: Multiaddr) { +export function isLoopback (ma: Multiaddr): boolean { const { address } = ma.nodeAddress() return isLoopbackAddr(address) diff --git a/src/multiaddr/is-private.ts b/src/multiaddr/is-private.ts index 54e8072..4d8f416 100644 --- a/src/multiaddr/is-private.ts +++ b/src/multiaddr/is-private.ts @@ -4,7 +4,7 @@ import isIpPrivate from 'private-ip' /** * Check if a given multiaddr has a private address. */ -export function isPrivate (ma: Multiaddr) { +export function isPrivate (ma: Multiaddr): boolean { const { address } = ma.nodeAddress() return Boolean(isIpPrivate(address)) diff --git a/src/stream-to-ma-conn.ts b/src/stream-to-ma-conn.ts index 2eeb28d..941f0a0 100644 --- a/src/stream-to-ma-conn.ts +++ b/src/stream-to-ma-conn.ts @@ -39,7 +39,7 @@ export interface StreamProperties { * Convert a duplex iterable into a MultiaddrConnection. * https://github.com/libp2p/interface-transport#multiaddrconnection */ -export function streamToMaConnection (props: StreamProperties, options: StreamOptions = {}) { +export function streamToMaConnection (props: StreamProperties, options: StreamOptions = {}): MultiaddrConnection { const { stream, remoteAddr } = props const { sink, source } = stream @@ -80,11 +80,11 @@ export function streamToMaConnection (props: StreamProperties, options: StreamOp } } - async function close () { + async function close (): Promise { if (maConn.timeline.close == null) { maConn.timeline.close = Date.now() } - return await Promise.resolve() + await Promise.resolve() } return maConn diff --git a/test/stream-to-ma-conn.spec.ts b/test/stream-to-ma-conn.spec.ts index 0e9d52c..1997862 100644 --- a/test/stream-to-ma-conn.spec.ts +++ b/test/stream-to-ma-conn.spec.ts @@ -11,7 +11,7 @@ import type { Stream } from '@libp2p/interface-connection' import type { Duplex } from 'it-stream-types' import type { Uint8ArrayList } from 'uint8arraylist' -function toMuxedStream (stream: Duplex) { +function toMuxedStream (stream: Duplex): Stream { const muxedStream: Stream = { ...stream, close: () => {},