From 9753460d534befe064bc52bfa51c7a46fe099762 Mon Sep 17 00:00:00 2001 From: dzdidi Date: Fri, 27 Jan 2023 08:41:46 +0100 Subject: [PATCH] doc: add usage example; clarify randomID behaviour Signed-off-by: dzdidi --- README.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7fb2467..34bc4ba 100644 --- a/README.md +++ b/README.md @@ -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])` @@ -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)` @@ -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: