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

const map = peerMap<string>()
map.set(peerId, 'value')

Type Parameters

  • T

Constructors

Properties

Accessors

Methods

Constructors

Properties

map: Map<string, {
    key: PeerId;
    value: T;
}>

Type declaration

Accessors

  • get size(): number
  • Returns number

Methods

  • Returns void

  • Parameters

    Returns boolean

  • Parameters

    • fn: ((value, key, map) => void)
        • (value, key, map): void
        • Parameters

          Returns void

    Returns void

  • Parameters

    Returns undefined | T

  • Parameters

    Returns boolean

  • Parameters

    Returns void

  • Returns IterableIterator<T>