From b8e00c5388719577a95483372fcd05724fe003e8 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 13 Feb 2020 17:41:55 +0000 Subject: [PATCH] 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. --- src/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index e152c14..d22bdca 100644 --- a/src/index.js +++ b/src/index.js @@ -7,7 +7,6 @@ const toUri = require('multiaddr-to-uri') const { AbortError } = require('abortable-iterator') const log = require('debug')('libp2p:websockets') -const assert = require('assert') const createListener = require('./listener') const toConnection = require('./socket-to-conn') @@ -23,7 +22,9 @@ class WebSockets { * @param {Upgrader} options.upgrader */ constructor ({ upgrader }) { - assert(upgrader, 'An upgrader must be provided. See https://github.com/libp2p/interface-transport#upgrader.') + if (!upgrader) { + throw new Error('An upgrader must be provided. See https://github.com/libp2p/interface-transport#upgrader.') + } this._upgrader = upgrader }