From b20d969cfd809083fb760a1017eba079fd3da5a4 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 30 Oct 2018 20:17:30 +0000 Subject: [PATCH] fix: better verifications on create() License: MIT Signed-off-by: Henrique Dias --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index c17d5b0..46165e3 100644 --- a/src/index.js +++ b/src/index.js @@ -35,9 +35,9 @@ class PeerInfo { } PeerInfo.create = async (peerId) => { - if (typeof peerId === 'undefined') { + if (peerId == null) { peerId = await PeerId.create() - } else if (peerId && typeof peerId.toJSON !== 'function') { + } else if (!PeerId.isPeerId(peerId)) { peerId = await PeerId.createFromJSON(peerId) }