mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-21 13:01:33 +00:00
fix: remove use of assert module (#561)
* fix: remove use of assert module The polyfill is big, we can simulate it by throwing an Error and it doesn't work under React Native. * chore: fix linting * chore: export invalid param code Co-authored-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
@ -1,11 +1,15 @@
|
||||
'use strict'
|
||||
|
||||
const assert = require('assert')
|
||||
const errcode = require('err-code')
|
||||
const mergeOptions = require('merge-options')
|
||||
const LatencyMonitor = require('latency-monitor').default
|
||||
const debug = require('debug')('libp2p:connection-manager')
|
||||
const retimer = require('retimer')
|
||||
|
||||
const {
|
||||
ERR_INVALID_PARAMETERS
|
||||
} = require('../errors')
|
||||
|
||||
const defaultOptions = {
|
||||
maxConnections: Infinity,
|
||||
minConnections: 0,
|
||||
@ -38,10 +42,9 @@ class ConnectionManager {
|
||||
this._registrar = libp2p.registrar
|
||||
this._peerId = libp2p.peerInfo.id.toB58String()
|
||||
this._options = mergeOptions.call({ ignoreUndefined: true }, defaultOptions, options)
|
||||
assert(
|
||||
this._options.maxConnections > this._options.minConnections,
|
||||
'Connection Manager maxConnections must be greater than minConnections'
|
||||
)
|
||||
if (this._options.maxConnections < this._options.minConnections) {
|
||||
throw errcode(new Error('Connection Manager maxConnections must be greater than minConnections'), ERR_INVALID_PARAMETERS)
|
||||
}
|
||||
|
||||
debug('options: %j', this._options)
|
||||
|
||||
|
Reference in New Issue
Block a user