{"id":21561754,"url":"https://github.com/synonymdev/slashtags-feeds","last_synced_at":"2025-07-16T16:31:05.206Z","repository":{"id":104962215,"uuid":"497870807","full_name":"synonymdev/slashtags-feeds","owner":"synonymdev","description":null,"archived":true,"fork":false,"pushed_at":"2024-02-15T04:56:04.000Z","size":144,"stargazers_count":0,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-18T13:02:03.033Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/synonymdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-30T09:17:49.000Z","updated_at":"2024-06-07T12:25:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"66566783-941c-454c-8d47-88bee8114628","html_url":"https://github.com/synonymdev/slashtags-feeds","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/synonymdev/slashtags-feeds","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synonymdev%2Fslashtags-feeds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synonymdev%2Fslashtags-feeds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synonymdev%2Fslashtags-feeds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synonymdev%2Fslashtags-feeds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/synonymdev","download_url":"https://codeload.github.com/synonymdev/slashtags-feeds/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synonymdev%2Fslashtags-feeds/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265524626,"owners_count":23782014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T09:27:53.292Z","updated_at":"2025-07-16T16:31:04.927Z","avatar_url":"https://github.com/synonymdev.png","language":"JavaScript","readme":"# Slashtags Feeds\n\nA library for creating and managing feeds using the web-relay\n\n## Usage\n\n```js\nconst { Client, Relay } = require('@synonymdev/web-relay')\nconst path = require('path')\n\nconst { Feed, Reader } = require('@synonymdev/feeds')\n\nconst relay = new Relay(path.join(__dirname, '/storage/relay'));\n\n(async () =\u003e {\n  const relayAddress = await relay.listen()\n\n  const client = new Client({ storage: path.join(__dirname, '/storage/writer'), relay: relayAddress })\n\n  const icon = Buffer.from('icon-data')\n\n  const config = {\n    name: 'price-feed',\n    description: 'a price feed',\n    icons: {\n      32: 'icon.png'\n    },\n    type: 'price-feed',\n    version: '1.0.0',\n    fields: [\n      {\n        name: 'latest',\n        description: 'Bitcoin / US Dollar price history',\n        main: '/feed/BTCUSD-last'\n      }\n    ]\n  }\n\n  const feed = new Feed(client, config, { icon })\n  // Wait for config file to be saved\n  await feed.ready()\n\n  confsole.log(feed.config.fields.map(f =\u003e f.main)) //  [\"/feed/BTCUSD-last\"]\n\n  // may need to wait more for a the relay to get the files from the client in production.\n  // await new Promise(resolve =\u003e settimeout(resolve, 200))\n\n  // Update a field, by its name in the config above.\n  feed.put('latest', 1000000)\n\n  {\n    const client = new Client({ storage: path.join(__dirname, '/storage/reader') })\n    const reader = new Reader(client, feed.url)\n\n    console.log('Config:', await reader.getConfig())\n    console.log('BTCUSD-last', await reader.getField('latest'))\n  }\n\n  relay.close()\n})()\n```\n\n## API\n\n#### `const feed = new Feed(client, config, [opts])`\n\nCreate a Feed instance.\n\n`client` is a [web-relay](https://github.com/slashtags/web-relay) client\n\n`config` is a feed config file to be saved at `./slashfeed.json`\n\n`opts` includes:\n\n- `icon`: an optional icon data as Uint8Array\n\n### `const url = feed.url`\n\nThe feed's url in the format `slashfeed:\u003cclient.id\u003e/\u003cfeed-name\u003e/[?query]`\n\n### `await feed.ready()`\n\nAwait to fetch and populate `feed.config` and `feed.icon`.\n\n#### `await feeds.put(key, value)`\n\nUpdates a feed. `key` is a string, and `value` is Uint8Array, a utf-8 string or a JSON.\n\n#### `await feeds.get(key)`\n\nReturns a Uint8Array value from a the local feed.\n\n#### `await feeds.close()`\n\nGracefully closing feeds and the underlying client.\n\n#### `const buffer = Feed.encode(value)`\n\nEncodes a value (string, number, null, boolean, array, or object) as JSON and return a Uint8Array\n\n#### `const value = Feed.dcode(buffer)`\n\nDecodes a Uint8Array as JSON if possible, or return the Uint8Array itself.\n\n#### `const reader = new Reader(client, url)`\n\nCreate an instance of the helper `Reader` class.\n\n`client` is a [web-relay](https://github.com/slashtags/web-relay) client\n\n`url` is a feed url `feed.url`\n\n#### `const config = await reader.getConfig()`\n\nReturns the `slashfeed.json` configuration file, and sets the `reader.config` value. Internally this method gets called as soon as you initialize the Reader instance.\n\n#### `const iconData = await reader.getIcon([size])`\n\nReturns the data buffer of the feed icon if it exists. `size` is an optional input to choose icon size to fetch, by default it will return the first size in the `config.icons`.\n\n#### `const value = await reader.getField(fieldName, [decode])`\n\nReturns the value of a specific field.\n\n`decode` is an opitonal funciton that expects a `Uint8Array` and returns the decoded value.\n\n#### `await reader.subscribe(fieldName, onupdate, [decode])`\n\nReturns the value of a specific field.\n\n`onupdate(value: T) =\u003e any` is a callback function that gets the decoded value as an argument.\n`decode(buf:Uint8Array) =\u003e T` is an opitonal funciton that expects a `Uint8Array` and returns the decoded value.\n\n## How it works\n\nAs of this first version, Slashtags feeds is a directory with the current structure:\n\n```\n├── feed\n│   ├── foo\n│   ├── bar\n└── slashfeed.json\n```\n\nWhere `slashfeed.json` defines the `name`, `image` and other future metadata about the feed.\nAnd `feed` directory contains the feed files, where each file represents a key value pair.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynonymdev%2Fslashtags-feeds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsynonymdev%2Fslashtags-feeds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynonymdev%2Fslashtags-feeds/lists"}