Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
docs: publish api docs (#14)
Browse files Browse the repository at this point in the history
Updates project config to publish api docs
  • Loading branch information
achingbrain authored Dec 16, 2022
1 parent 64d13f4 commit f11b89a
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ updates:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
commit-message:
prefix: "deps"
prefix-development: "deps(dev)"
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
node_modules
coverage
.nyc_output
build
dist
.docs
.coverage
node_modules
package-lock.json
yarn.lock
docs
dist
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# @libp2p/peer-collections <!-- omit in toc -->

[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-peer-collections.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-peer-collections)
[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-peer-collections/actions/workflows/js-test-and-release.yml)
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-peer-collections/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p-peer-collections/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)

> Stores values against a peer id
## Table of contents <!-- omit in toc -->

- [Install](#install)
- [Browser `<script>` tag](#browser-script-tag)
- [Description](#description)
- [Example](#example)
- [API Docs](#api-docs)
- [License](#license)
- [Contribution](#contribution)

Expand All @@ -22,26 +22,23 @@
$ npm i @libp2p/peer-collections
```

## Description
### Browser `<script>` tag

We 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.
Loading this module through a script tag will make it's exports available as `Libp2pPeerCollections` in the global namespace.

PeerIds cache stringified versions of themselves so this should be a cheap operation.
```html
<script src="https://unpkg.com/@libp2p/peer-collections/dist/index.min.js"></script>
```

## Example
## Description

```JavaScript
import { peerMap, peerSet, peerList } from '@libp2p/peer-collections'
We 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.

const map = peerMap<string>()
map.set(peerId, 'value')
PeerIds cache stringified versions of themselves so this should be a cheap operation.

const set = peerSet()
set.add(peerId)
## API Docs

const list = peerList()
list.push(peerId)
```
- <https://libp2p.github.io/js-libp2p-peer-collections>

## License

Expand Down
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"types": "./dist/src/index.d.ts",
"files": [
"src",
"dist/src",
"dist",
"!dist/test",
"!**/*.tsbuildinfo"
],
Expand Down Expand Up @@ -65,15 +65,15 @@
"release": "patch"
},
{
"type": "chore",
"type": "docs",
"release": "patch"
},
{
"type": "docs",
"type": "test",
"release": "patch"
},
{
"type": "test",
"type": "deps",
"release": "patch"
},
{
Expand Down Expand Up @@ -103,7 +103,11 @@
},
{
"type": "docs",
"section": "Trivial Changes"
"section": "Documentation"
},
{
"type": "deps",
"section": "Dependencies"
},
{
"type": "test",
Expand Down Expand Up @@ -131,7 +135,8 @@
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
"test:node": "aegir test -t node --cov",
"test:electron-main": "aegir test -t electron-main",
"release": "aegir release"
"release": "aegir release",
"docs": "aegir docs"
},
"dependencies": {
"@libp2p/interface-peer-id": "^1.0.4",
Expand Down
9 changes: 9 additions & 0 deletions src/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import { mapIterable } from './util.js'
*
* PeerIds cache stringified versions of themselves so this
* should be a cheap operation.
*
* @example
*
* ```JavaScript
* import { peerList } from '@libp2p/peer-collections'
*
* const list = peerList()
* list.push(peerId)
* ```
*/
export class PeerList {
private readonly list: string[]
Expand Down
9 changes: 9 additions & 0 deletions src/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import { mapIterable } from './util.js'
*
* PeerIds cache stringified versions of themselves so this
* should be a cheap operation.
*
* @example
*
* ```JavaScript
* import { peerMap } from '@libp2p/peer-collections'
*
* const map = peerMap<string>()
* map.set(peerId, 'value')
* ```
*/
export class PeerMap <T> {
private readonly map: Map<string, T>
Expand Down
9 changes: 9 additions & 0 deletions src/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import { mapIterable } from './util.js'
*
* PeerIds cache stringified versions of themselves so this
* should be a cheap operation.
*
* @example
*
* ```JavaScript
* import { peerSet } from '@libp2p/peer-collections'
*
* const set = peerSet()
* set.add(peerId)
* ```
*/
export class PeerSet {
private readonly set: Set<string>
Expand Down

0 comments on commit f11b89a

Please sign in to comment.