{"id":15455103,"url":"https://github.com/vsivsi/git-blob-stream","last_synced_at":"2025-03-28T10:14:20.618Z","repository":{"id":35649379,"uuid":"39924179","full_name":"vsivsi/git-blob-stream","owner":"vsivsi","description":"Read and write git blobs using node.js Stream2","archived":false,"fork":false,"pushed_at":"2015-08-06T20:11:00.000Z","size":228,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T09:30:45.365Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/git-blob-stream","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vsivsi.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-30T01:13:13.000Z","updated_at":"2017-08-02T02:09:24.000Z","dependencies_parsed_at":"2022-08-24T17:00:13.783Z","dependency_job_id":null,"html_url":"https://github.com/vsivsi/git-blob-stream","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsivsi%2Fgit-blob-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsivsi%2Fgit-blob-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsivsi%2Fgit-blob-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsivsi%2Fgit-blob-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vsivsi","download_url":"https://codeload.github.com/vsivsi/git-blob-stream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246009074,"owners_count":20708881,"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-10-01T22:09:24.090Z","updated_at":"2025-03-28T10:14:20.596Z","avatar_url":"https://github.com/vsivsi.png","language":"JavaScript","readme":"## git-blob-stream\n\n[![Build Status](https://travis-ci.org/vsivsi/git-blob-stream.svg)](https://travis-ci.org/vsivsi/git-blob-stream)\n\n**WARNING** This package is still under active development, I reserve the right to change anything until 0.1.0 is released. At that point I'll go all SemVer and everything.\n\nThis npm package makes it easy and efficient to read and write Git blob files using node.js Stream2 streams. It has no dependencies on command line git or native code git libraries; instead using crypto and compression libraries already built into node.js.\n\n### Installation\n\n```bash\nnpm install git-blob-stream\n\n# To run tests from within the package directory\nnpm install \u0026\u0026 npm test\n```\n\n### Usage\n\n##### To read a blob file:\n\n```javascript\nvar fs = require('fs');\nvar gbs = require('git-blob-stream');\n\nvar input = fs.createReadStream(\"filename.blob\");\nvar output = fs.createWriteStream(\"filename\");\n\nvar headerFunc = function (err, ret) {\n  // ret is an object:\n  // { size: \u003cblobDataLength\u003e, type: \u003cblobType\u003e }\n};\n\nvar xformStream = gbs.blobReader({\n    noOutput: false    // Default, if true, no data will be readable\n  },\n  headerFunc);      // callback is optional\n\n// Decode the file...\ninput.pipe(xformStream).pipe(output);\n\noutput.on('close', function () {\n  // All done\n});\n```\n\n##### To write a blob file:\n\n```javascript\nvar fs = require('fs');\nvar gbs = require('git-blob-stream');\n\nvar input = fs.createReadStream(\"filename\");\nvar output = fs.createWriteStream(\"filename.blob\");\n\nvar hashFunc = function (err, ret) {\n  // ret is an object:\n  // { size: \u003cblobDataLength\u003e, hash: \u003chashValue\u003e }\n  // hashValue is a hex string of the 20 byte SHA1 sum\n}\n\n// All options are manditory!\nvar xformStream = gbs.blobWriter({\n  size: fs.statSync(\"filename\").size,  // Optional, but more efficient if provided!\n  type: \"blob\",                        // Default, or \"tree\", \"tag\" or \"commit\"\n  noOutput: false                      // Default, if true, no data will be written\n  },\n  hashFunc); // callback is optional\n\n// Write the file. hashCallback will be called when finished\ninput.pipe(xformStream).pipe(output);\n\noutput.on('close', function () {\n  // All done\n});\n```\n\n#### Higher level git objects\n\nIn addition to blobs, this package can also stream to/from [js-git](https://github.com/creationix) style tree, commit and tag objects.\n\n##### To read a tree blob file:\n\n```javascript\nvar fs = require('fs');\nvar gbs = require('git-blob-stream');\nvar input = fs.createReadStream(\"tree.blob\");\n\nvar callback = function (err, ret) {\n  // ret is a tree object\n}\n\nvar xformStream = gbs.treeReader(callback); // callback is optional\n\n// Decode the file...\noutput = input.pipe(xformStream);\n\n// If a callback is not provided to treeReader, then it writes its output\n// as an object to the stream output\n// output.on('data', function (data) {\n//   // data is a tree object\n//   // This will only be called once\n// });\n//\n// output.on('end', function () {\n//   // All done\n// });\n```\n\n##### To write a tree blob file:\n\n```javascript\nvar fs = require('fs');\nvar gbs = require('git-blob-stream');\n\nvar output = fs.createWriteStream(\"tree.blob\");\n\nvar hashFunc = function (ret) {\n  // ret is an object:\n  // { size: \u003cblobDataLength\u003e, hash: \u003chashValue\u003e, tree: \u003cnormalizedTreeObj\u003e}\n  // hashValue is a hex string of the 20 byte SHA1 sum\n  // normalizedTreeObj is the actual tree object that would be read back, as\n  // normalized to git standard form (canonical sorting, missing fields added)\n}\n\n// All options are manditory!\nvar xformStream = gbs.treeWriter(\n  {\n    'greetings.txt' : { mode: gbs.gitModes.file, hash: fileHash }\n  },\n  hashFunc); // callback is optional\n\n// Write the file. hashCallback will be called when finished\nxformStream.pipe(output);\n\noutput.on('close', function () {\n  // All done\n});\n```\n\nAnalogous calls for reading/writing commits and (annotated) tags also exist:\n`commitReader`, `commitWriter`, `tagReader`, `tagWriter`.\nAll assume [js-git](https://github.com/creationix) style objects.\n\nEnjoy!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsivsi%2Fgit-blob-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvsivsi%2Fgit-blob-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsivsi%2Fgit-blob-stream/lists"}