Skip to content
This repository was archived by the owner on Feb 24, 2021. It is now read-only.

Commit 027e0ad

Browse files
authored
fix: remove use of assert module (#114)
The polyfill is big, we can simulate it by throwing an Error and it doesn't work under React Native.
1 parent 74e95e2 commit 027e0ad

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/index.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict'
22

3-
const assert = require('assert')
43
const debug = require('debug')
54
const log = debug('libp2p:secio')
65
log.error = debug('libp2p:secio:error')
@@ -11,8 +10,12 @@ const Wrap = require('it-pb-rpc')
1110
const { int32BEDecode, int32BEEncode } = require('it-length-prefixed')
1211

1312
async function secure (localPeer, duplex, remotePeer) { // returns duplex
14-
assert(localPeer, 'no local private key provided')
15-
assert(duplex, 'no connection for the handshake provided')
13+
if (!localPeer) {
14+
throw new Error('no local private key provided')
15+
}
16+
if (!duplex) {
17+
throw new Error('no connection for the handshake provided')
18+
}
1619

1720
const state = new State(localPeer, remotePeer)
1821
const wrapped = Wrap(duplex, { lengthDecoder: int32BEDecode, lengthEncoder: int32BEEncode })

0 commit comments

Comments
 (0)