mirror of
https://github.com/fluencelabs/js-peer-id
synced 2025-07-31 02:02:02 +00:00
feat: isEqual
This commit is contained in:
10
src/index.js
10
src/index.js
@@ -88,6 +88,16 @@ class PeerId {
|
||||
toB58String () {
|
||||
return this._idB58String
|
||||
}
|
||||
|
||||
isEqual (id) {
|
||||
if (Buffer.isBuffer(id)) {
|
||||
return this.id.equals(id)
|
||||
} else if (id.id) {
|
||||
return this.id.equals(id.id)
|
||||
} else {
|
||||
throw new Error('not valid Id')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports = module.exports = PeerId
|
||||
|
Reference in New Issue
Block a user