{"id":19837341,"url":"https://github.com/e-e-e/dat-protocol-buffers","last_synced_at":"2025-02-28T18:47:03.818Z","repository":{"id":57211449,"uuid":"93983978","full_name":"e-e-e/dat-protocol-buffers","owner":"e-e-e","description":"A convenience wrapper for encoding and decoding common dat protocol buffers defined in the dat white paper.","archived":false,"fork":false,"pushed_at":"2017-06-12T01:12:34.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T23:08:24.296Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"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/e-e-e.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}},"created_at":"2017-06-11T05:33:46.000Z","updated_at":"2017-06-11T06:01:36.000Z","dependencies_parsed_at":"2022-08-30T12:30:20.052Z","dependency_job_id":null,"html_url":"https://github.com/e-e-e/dat-protocol-buffers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-e-e%2Fdat-protocol-buffers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-e-e%2Fdat-protocol-buffers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-e-e%2Fdat-protocol-buffers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-e-e%2Fdat-protocol-buffers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/e-e-e","download_url":"https://codeload.github.com/e-e-e/dat-protocol-buffers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240710057,"owners_count":19845039,"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-12T12:14:08.350Z","updated_at":"2025-02-28T18:47:03.796Z","avatar_url":"https://github.com/e-e-e.png","language":"JavaScript","readme":"# dat protocol buffers\n\n[![Build Status](https://travis-ci.org/e-e-e/dat-protocol-buffers.svg?branch=master)](https://travis-ci.org/e-e-e/dat-protocol-buffers) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\nThis is a convenience implementation of the protocol buffers for the [dat protocol](www.datproject.org) as defined in the [dat white paper](https://github.com/datproject/docs/blob/master/papers/dat-paper.pdf).\n\nAlthough this package can be used to decode or encode any dat protocol buffers. It is particularly useful for decoding download events from [dat-node](https://github.com/datproject/dat-node) or [hyperdrive](https://github.com/mafintosh/hyperdrive).\n\n## install\n\n`npm install dat-protocol-buffers`\n\n## How to use\n\nYou can import all the message specification simple my importing the base module\n\n```js\nvar messages = require('dat-protocol-buffers')\n```\n\nor individually\n\n```js\nvar messages = require('dat-protocol-buffers/messages/{name-of-protocol}')\n// e.g. var messages = require('dat-protocol-buffers/messages/node')\n// e.g. var messages = require('dat-protocol-buffers/messages/handshake')\n```\n\nListening to dat download events:\n```js\nDat(dir, { key: somekey, sparse: true }, function (err, dat) {\n  const stats = dat.trackStats();\n  dat.joinNetwork();\n  dat.network.once('connection', function () {\n    console.log('I connected to someone!')\n    dat.archive.metadata.on('download', (i, d) =\u003e {\n      if(i === 0) {\n        const header = messages.Header.decode(d);\n        console.log('HEADER', header);\n      } else {\n          const block = messages.Node.decode(d);\n          console.log('BLOCK', block);\n      }\n    })\n  })\n})\n```\n\n### Protocols currently supported:\n\n- Cancel\n- Data\n- Handshake\n- Have\n- Header\n- Register\n- Request\n- Node\n- Stat\n- Status\n- Want\n- Unhave\n- Unwant\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe-e-e%2Fdat-protocol-buffers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fe-e-e%2Fdat-protocol-buffers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe-e-e%2Fdat-protocol-buffers/lists"}