We can't use PeerIds as list entries because list 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 { peerList } from '@libp2p/peer-collections'

const list = peerList()
list.push(peerId)

Constructors

Properties

list: PeerId[]

Accessors

  • get length(): number
  • Returns number

Methods

  • Parameters

    • predicate: ((peerId, index, arr) => boolean)
        • (peerId, index, arr): boolean
        • Parameters

          Returns boolean

    Returns boolean

  • Parameters

    • predicate: ((peerId, index, arr) => boolean)
        • (peerId, index, arr): boolean
        • Parameters

          Returns boolean

    Returns PeerList

  • Parameters

    • predicate: ((peerId, index, arr) => boolean)
        • (peerId, index, arr): boolean
        • Parameters

          Returns boolean

    Returns undefined | PeerId

  • Parameters

    • predicate: ((peerId, index, arr) => boolean)
        • (peerId, index, arr): boolean
        • Parameters

          Returns boolean

    Returns number

  • Parameters

    • predicate: ((peerId, index, arr) => void)
        • (peerId, index, arr): void
        • Parameters

          Returns void

    Returns void

  • Parameters

    Returns boolean

  • Parameters

    Returns void

  • Parameters

    Returns number