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

Introduce `ToPeerId` type for things that can be turned into PeerId #133

Open Gozala opened 3 years ago

Gozala commented 3 years ago

Based on discussion here https://github.com/ipfs/js-ipfs/pull/3365/files/fa7c2c13c43bab922052104fe8aff863d9725e9b?file-filters%5B%5D=.js&file-filters%5B%5D=.json&file-filters%5B%5D=.ts#r520418521

vasco-santos commented 3 years ago

Cross posting from https://github.com/ipfs/js-ipfs/pull/3365/files/fa7c2c13c43bab922052104fe8aff863d9725e9b?file-filters%5B%5D=.js&file-filters%5B%5D=.json&file-filters%5B%5D=.ts#r522871631

We already have several createFrom* functions in peer-id, but they are targeted to a specific type https://github.com/libp2p/js-peer-id#import I think this would be nice to have, I would just go with PeerId.createFrom(param: ToPeerId) to be consistent with what we already have.