{"name":"@libp2p/peer-collections","version":"5.2.2","keywords":["IPFS"],"license":"Apache-2.0 OR MIT","_id":"@libp2p/peer-collections@5.2.2","homepage":"https://github.com/libp2p/js-libp2p/tree/main/packages/peer-collections#readme","bugs":{"url":"https://github.com/libp2p/js-libp2p/issues"},"dist":{"shasum":"54ce9de477b1d4660ef6736e230e3e5a260c0bab","tarball":"http://registry-npm.ywwl.com/@libp2p/peer-collections/download/@libp2p/peer-collections-5.2.2.tgz","fileCount":50,"integrity":"sha512-Etx4C5vo/46WY2FG5jpeAUl0DDJf6OlhSRGo2yZbGGIy3m861awm59ExCr9i2tvKxvLTRfhzlK82HXP+CFPWMQ==","signatures":[{"sig":"MEUCIQDG12VrB3ECAStmo0g1hzGA++FoYBsQAY5GKtOdtMg86wIgI49pDUFoiws/hPm9nD41EU0eny/MV8YFUs9WUUxbeHU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@libp2p%2fpeer-collections@5.2.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":108189,"size":25062,"noattachment":false,"key":"/@libp2p/peer-collections/-/@libp2p/peer-collections-5.2.2.tgz"},"type":"module","types":"./dist/src/index.d.ts","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"}},"gitHead":"f9df63299d5e73168f2aef452d42f9723f56e810","scripts":{"lint":"aegir lint","test":"aegir test","build":"aegir build","clean":"aegir clean","dep-check":"aegir dep-check","doc-check":"aegir doc-check","test:node":"aegir test -t node --cov","test:chrome":"aegir test -t browser --cov","test:firefox":"aegir test -t browser -- --browser firefox","test:electron-main":"aegir test -t electron-main","test:chrome-webworker":"aegir test -t webworker","test:firefox-webworker":"aegir test -t webworker -- --browser firefox"},"_npmUser":{"name":"npm-service-account-libp2p","email":"npm-service-account+libp2p@ipfs.tech"},"repository":{"url":"git+https://github.com/libp2p/js-libp2p.git","type":"git"},"_npmVersion":"10.8.0","description":"Stores values against a peer id","directories":{},"sideEffects":false,"_nodeVersion":"20.13.1","dependencies":{"@libp2p/utils":"^5.4.2","@libp2p/peer-id":"^4.1.2","@libp2p/interface":"^1.4.0"},"eslintConfig":{"extends":"ipfs","parserOptions":{"project":true,"sourceType":"module"}},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"aegir":"^42.2.11","sinon":"^18.0.0","sinon-ts":"^2.0.0","@types/sinon":"^17.0.3","@libp2p/peer-id-factory":"^4.1.2"},"_npmOperationalInternal":{"tmp":"tmp/peer-collections_5.2.2_1716203844373_0.3068938482099186","host":"s3://npm-registry-packages"},"readme":"# @libp2p/peer-collections\n\n[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)\n[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)\n[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)\n[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=main\\&style=flat-square)](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amain)\n\n> Stores values against a peer id\n\n# About\n\n<!--\n\n!IMPORTANT!\n\nEverything in this README between \"# About\" and \"# Install\" is automatically\ngenerated and will be overwritten the next time the doc generator is run.\n\nTo make changes to this section, please update the @packageDocumentation section\nof src/index.js or src/index.ts\n\nTo experiment with formatting, please run \"npm run docs\" from the root of this\nrepo and examine the changes made.\n\n-->\n\nWe can't use PeerIds as collection keys because collection keys are compared using same-value-zero equality, so this is just a group of collections that stringifies PeerIds before storing them.\n\nPeerIds cache stringified versions of themselves so this should be a cheap operation.\n\nTracked versions are also available which report their current size to the libp2p Metrics collector.\n\n## Example - Peer lists\n\n```TypeScript\nimport { peerList } from '@libp2p/peer-collections'\nimport { createEd25519PeerId } from '@libp2p/peer-id-factory'\n\nconst peerId = await createEd25519PeerId()\n\nconst list = peerList()\nlist.push(peerId)\n```\n\n## Example - Tracked peer lists\n\n```TypeScript\nimport { trackedPeerList } from '@libp2p/peer-collections'\nimport { createEd25519PeerId } from '@libp2p/peer-id-factory'\nimport { createLibp2p } from 'libp2p'\n\nconst libp2p = await createLibp2p()\nconst peerId = await createEd25519PeerId()\n\nconst list = trackedPeerList({ name: 'my_metric_name', metrics: libp2p.metrics })\nlist.push(peerId)\n```\n\n## Example - Peer maps\n\n```TypeScript\nimport { peerMap } from '@libp2p/peer-collections'\nimport { createEd25519PeerId } from '@libp2p/peer-id-factory'\n\nconst peerId = await createEd25519PeerId()\n\nconst map = peerMap<string>()\nmap.set(peerId, 'value')\n```\n\n## Example - Tracked peer maps\n\n```TypeScript\nimport { trackedPeerMap } from '@libp2p/peer-collections'\nimport { createLibp2p } from 'libp2p'\nimport { createEd25519PeerId } from '@libp2p/peer-id-factory'\n\nconst libp2p = await createLibp2p()\nconst peerId = await createEd25519PeerId()\n\nconst map = trackedPeerMap({ name: 'my_metric_name', metrics: libp2p.metrics })\nmap.set(peerId, 'value')\n```\n\n## Example - Peer sets\n\n```TypeScript\nimport { peerSet } from '@libp2p/peer-collections'\nimport { createEd25519PeerId } from '@libp2p/peer-id-factory'\n\nconst peerId = await createEd25519PeerId()\n\nconst set = peerSet()\nset.add(peerId)\n```\n\n## Example - Tracked peer sets\n\n```TypeScript\nimport { trackedPeerSet } from '@libp2p/peer-collections'\nimport { createLibp2p } from 'libp2p'\nimport { createEd25519PeerId } from '@libp2p/peer-id-factory'\n\nconst libp2p = await createLibp2p()\nconst peerId = await createEd25519PeerId()\n\nconst set = trackedPeerSet({ name: 'my_metric_name', metrics: libp2p.metrics })\nset.add(peerId)\n```\n\n## Example - Peer filters\n\n```TypeScript\nimport { peerFilter } from '@libp2p/peer-collections'\nimport { createEd25519PeerId } from '@libp2p/peer-id-factory'\n\nconst peerId = await createEd25519PeerId()\n\nconst filter = peerFilter(1024)\nfilter.has(peerId) // false\nfilter.add(peerId)\nfilter.has(peerId) // true\n```\n\n# Install\n\n```console\n$ npm i @libp2p/peer-collections\n```\n\n## Browser `<script>` tag\n\nLoading this module through a script tag will make it's exports available as `Libp2pPeerCollections` in the global namespace.\n\n```html\n<script src=\"https://unpkg.com/@libp2p/peer-collections/dist/index.min.js\"></script>\n```\n\n# API Docs\n\n- <https://libp2p.github.io/js-libp2p/modules/_libp2p_peer_collections.html>\n\n# License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](https://github.com/libp2p/js-libp2p/blob/main/packages/peer-collections/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](https://github.com/libp2p/js-libp2p/blob/main/packages/peer-collections/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)\n\n# Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","publish_time":1716203844555,"maintainers":[{"name":"jacobheun","email":"jacobheun@gmail.com"},{"name":"npm-service-account-libp2p","email":"npm-service-account+libp2p@ipfs.tech"},{"name":"alanshaw","email":"alan138@gmail.com"},{"name":"vascosantos","email":"santos.vasco10@gmail.com"},{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"daviddias","email":"mail@daviddias.me"}],"_cnpm_publish_time":1716203844555,"dist-tags":{"latest":"7.0.32","next":"7.0.32-fab409544"}}