We can't use PeerIds as set entries because set entries are compared using same-value-zero equality, so this is just a map that stringifies the PeerIds before storing them.

PeerIds cache stringified versions of themselves so this should be a cheap operation.

Example

import { peerSet } from '@libp2p/peer-collections'

const set = peerSet()
set.add(peerId)

Constructors

Properties

set: Set<string>

Accessors

  • get size(): number
  • Returns number

Methods

  • Returns void

  • Parameters

    • predicate: ((peerId, index, set) => void)

    Returns void

  • Parameters

    Returns boolean