libp2p / js-peer-id

peer-id implementation in JavaScript. Deprecated; use https://github.com/libp2p/js-libp2p-peer-id instead.
https://github.com/libp2p/js-libp2p-peer-id
MIT License
80 stars 44 forks source link

Add type predicate #115

Closed robertkiel closed 4 years ago

robertkiel commented 4 years ago

Tell Typescript that isPeerId(id) returns true if, and only if, id is of type PeerId.

See https://www.typescriptlang.org/docs/handbook/advanced-types.html#using-type-predicates

vasco-santos commented 4 years ago

Thanks for the PR @robertkiel @carsonfarmer mind having a look?

carsonfarmer commented 4 years ago

Oooh, this is nice. Good call.