Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

doc: add usage example; clarify randomID behaviour #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,29 @@

A library for creating and managing feeds using Hyperdrive and Hyperswarm.

## Usage
## Installation

```sh
npm install @synonymdev/feeds
```

Initiate the library.
## Usage

### Example
```js
import Feeds from '@synonymdev/feeds'

const feeds = new Feeds();
const feedID = feeds.randomID();
await feeds.update(feedID, 'balance', 1000);

let get = await feeds.get(feedID, 'foo')
console.log(get)

feeds.close()
```

## API
### API

#### `const feeds = new Feeds(storage, [opts])`

Expand All @@ -26,7 +38,7 @@ Create a Feeds instance.

#### `feeds.randomID()`

Generate a random string id to be used as the feedID.
Generate a random string id good for using as the feedID.

#### `await feeds.feed(feedID)`

Expand All @@ -49,7 +61,7 @@ Gracefully closing feeds and freeing IO resources.

Destroys all stored data for the feed.

## How it works
### How it works

As of this first version, Slashtags feeds is a directory on top of Hyperdrive with the current structure:

Expand Down