{"id":20181783,"url":"https://github.com/nichoth/blobs","last_synced_at":"2025-05-07T03:30:32.510Z","repository":{"id":156717821,"uuid":"633034330","full_name":"nichoth/blobs","owner":"nichoth","description":"Content addressed blob storage","archived":true,"fork":false,"pushed_at":"2024-01-23T18:00:21.000Z","size":166,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-19T20:26:06.562Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/nichoth.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":"2023-04-26T16:30:35.000Z","updated_at":"2025-01-06T08:02:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"217c313c-766e-4f66-ae1e-26912d9da4f1","html_url":"https://github.com/nichoth/blobs","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":"nichoth/template-ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Fblobs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Fblobs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Fblobs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nichoth%2Fblobs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nichoth","download_url":"https://codeload.github.com/nichoth/blobs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252806321,"owners_count":21807188,"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-14T02:36:44.127Z","updated_at":"2025-05-07T03:30:32.176Z","avatar_url":"https://github.com/nichoth.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# blobs ![tests](https://github.com/nichoth/blobs/actions/workflows/nodejs.yml/badge.svg)\n\nStore blobs by their content address using the blake2 hash algorithm.\n\n## featuring\n* ESM only. Sorry, no common JS, because we are using top level `await`\n* compatibility with either Node JS or [SSC](https://github.com/socketsupply/socket)\n* types\n* Contemporary API -- use promises \u0026 `async` functions\n\n## install\n```\nnpm i @nichoth/blobs\n```\n\n## API\n\n### `Blobs({ dir:string })`\nCreate a new `blobs` object.\n\n```js\nconst blobs = Blobs({ dir: '/hello' })\n```\n\n### add: (data:Uint8Array|string) =\u003e Promise\u003cstring\u003e,\nWrite the data to a file, and return the hash of the data passed in. The hash string returned here is what you would pass in to `blobs.get`.\n\n```js\nconst hash = await blobs.add('hello')\n```\n\n### get: (hash:string, enc?:BufferEncoding) =\u003e Promise\u003cstring|Buffer\u003e\nReturn the data at the given hash.\n\n```js\nconst content = await blobs.get(hash, 'utf8')\n```\n\n## example\n\n```ts\nimport { test } from 'tapzero'\nimport { Blobs } from '@nichoth/blobs'\nimport path from 'node:path'\nimport fs from 'node:fs/promises'\nimport { fileURLToPath } from 'url'\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\nlet blobs\ntest('create an instance', t =\u003e {\n    blobs = Blobs({ dir: __dirname })\n    t.ok(blobs, 'should create a new blobs instance')\n    t.ok(blobs.add, 'has .add')\n    t.ok(blobs.get, 'has .get')\n})\n\nlet hash\ntest('blobs.add', async t =\u003e {\n    hash = await blobs.add('hello')\n    t.equal(typeof hash, 'string', 'should return hash as a string')\n    t.equal(hash, 'GSE7rMWN7m294865pHy7Mws9hvjMqJl-sAvkVvFAyiU',\n        'should return the expected hash')\n\n    const stats = await fs.stat(path.join(__dirname, hash))\n    t.ok(stats, 'should create the file at the right path')\n})\n\ntest('blobs.get', async t =\u003e {\n    const content = await blobs.get(hash, 'utf8')\n    t.ok(content, 'got content')\n    t.equal(content, 'hello', 'should return a string because we passed \"utf8\"')\n})\n```\n\n## test\nTest in Node:\n```bash\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnichoth%2Fblobs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnichoth%2Fblobs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnichoth%2Fblobs/lists"}