Skip to content

Commit 294a907

Browse files
docs: Fix example in README.md (libp2p#54)
Currently, the example fails with > Module '"@libp2p/peer-id"' declares 'PeerId' locally, but it is not exported.ts(2459) Replaced with a working example. Co-authored-by: Alex Potsides <[email protected]>
1 parent ce4be90 commit 294a907

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/libp2p-peer-id/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ A basic implementation of a peer id
3838
## Example
3939

4040
```JavaScript
41-
import { PeerId } from '@libp2p/peer-id'
41+
import { peerIdFromString } from '@libp2p/peer-id'
4242

43-
const id = new PeerId(...)
43+
const peer = peerIdFromString('k51qzi5uqu5dkwkqm42v9j9kqcam2jiuvloi16g72i4i4amoo2m8u3ol3mqu6s')
4444

45-
console.log(id.toCid())
45+
console.log(peer.toCid()) // CID(bafzaa...)
46+
console.log(peer.toString()) // "12D3K..."
4647
```
4748

4849
## API Docs

0 commit comments

Comments
 (0)