Skip to content

Commit

Permalink
fix: remove use of assert module (#117)
Browse files Browse the repository at this point in the history
The polyfill is big, we can simulate it by throwing an Error and it doesn't work under React Native.
  • Loading branch information
achingbrain authored Feb 18, 2020
1 parent a68855a commit f44645e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
const mh = require('multihashes')
const CID = require('cids')
const cryptoKeys = require('libp2p-crypto/src/keys')
const assert = require('assert')
const withIs = require('class-is')
const { PeerIdProto } = require('./proto')

class PeerId {
constructor (id, privKey, pubKey) {
assert(Buffer.isBuffer(id), 'invalid id provided')
if (!Buffer.isBuffer(id)) {
throw new Error('invalid id provided')
}

if (privKey && pubKey) {
assert(privKey.public.bytes.equals(pubKey.bytes), 'inconsistent arguments')
if (privKey && pubKey && !privKey.public.bytes.equals(pubKey.bytes)) {
throw new Error('inconsistent arguments')
}

this._id = id
Expand Down

0 comments on commit f44645e

Please sign in to comment.