{"id":16731650,"url":"https://github.com/missinglink/bun","last_synced_at":"2025-03-15T18:26:13.543Z","repository":{"id":21079226,"uuid":"24378908","full_name":"missinglink/bun","owner":"missinglink","description":"A useful container for streams","archived":false,"fork":false,"pushed_at":"2014-09-23T16:13:51.000Z","size":111,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T08:13:33.478Z","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/missinglink.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":"2014-09-23T16:09:59.000Z","updated_at":"2021-01-15T19:20:00.000Z","dependencies_parsed_at":"2022-08-02T10:40:56.909Z","dependency_job_id":null,"html_url":"https://github.com/missinglink/bun","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/missinglink%2Fbun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/missinglink%2Fbun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/missinglink%2Fbun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/missinglink%2Fbun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/missinglink","download_url":"https://codeload.github.com/missinglink/bun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243772641,"owners_count":20345685,"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-12T23:38:22.103Z","updated_at":"2025-03-15T18:26:13.521Z","avatar_url":"https://github.com/missinglink.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"bun  ![build status][build_status]\n===\n\nWe've all pondered, \"But what do I do with it?\" The answer is universal: Wrap it\nin a bun! **bun** wraps a series of streams into a single\n`stream.Duplex`-compliant unit.\n\nA Possible And Likely Scenario\n------------------------------\n\nSay you have an existing module with an implentation like this\n\n```js\n// my-transport.js\nencryptor.pipe(compressor).pipe(socket).pipe(decompressor).pipe(decryptor);\n```\n\nTotally believable, right? Now each time someone wants to use your module, you\nhave to do something like this\n\n```js\n// too much work!\nclient.pipe(encryptor)\n      .pipe(compressor)\n      .pipe(socket)\n      .pipe(decompressor)\n      .pipe(decryptor)\n      .pipe(client);\n```\n\nGross! Puke! This is horribly inconvenient and ugly for the end user! Let's look\nat a **better solution**\n\n```js\n// defined in my-transport.js\nvar bun = require(\"bun\");\nmodule.service = function(socket) {\n  return bun([encryptor, compressor, socket, decompressor, decryptor]);\n});\n\n// used in client\nvar transport = require(\"./my-transport\");\nclient.pipe(transport.service(socket)).pipe(client);\n```\n\nHot cross buns! **bun** is amazing!\n\n\nExample\n-------\n\n```js\nvar  stream = require(\"stream\"),\n     bun    = require(\"bun\");\n\n// stream generator\nvar createStream = function createStream(id) {\n  var s = new stream.Transform({encoding: \"utf8\"});\n  s._transform = function _transform(str, encoding, done) {\n    this.push(\"(\" + id + \" \" + str + \")\");\n    done();\n  };\n  return s;\n};\n\n// create some streams\nvar streams = [\"G\", \"O\", \"D\"].map(function(id) {\n  return createStream(id);\n});\n\n// wrap the streams in a bun!\nvar hotdog = bun(streams);\n\n// connect hotdog to stdout\nhotdog.pipe(process.stdout);\n\n// use the hotdog\nhotdog.write(\"in a bun\"); // (D (O (G in a bun)))\n```\n\nBuns are convenient, edible, and keep your hands clean! Use **bun**!\n\n\nAPI\n---\n\n**bun**\n\n```js\nvar service = bun(streams, [options]);\n```\n\n* _streams_ - An array of `stream` objects.\n* _options_ - An object specifying options. (options are optional)\n\nOptions:\n\n* _bubbleErrors_ - Bubble \"error\" events from wrapped streams up to the outer\n  stream, giving you an easy way to aggregate and react to all the errors\n  emitted by them in one place. Default is `true`.\n\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n\n[build_status]: https://travis-ci.org/naomik/bun.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmissinglink%2Fbun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmissinglink%2Fbun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmissinglink%2Fbun/lists"}