{"id":13658970,"url":"https://github.com/brycebaril/node-stream-spigot","last_synced_at":"2025-04-19T16:24:25.996Z","repository":{"id":9320762,"uuid":"11164221","full_name":"brycebaril/node-stream-spigot","owner":"brycebaril","description":"A streams2 Readable stream generator, useful for testing.","archived":false,"fork":false,"pushed_at":"2017-03-28T15:37:03.000Z","size":18,"stargazers_count":15,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-10T12:43:04.728Z","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":"Quixotix/gedit-source-code-browser","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brycebaril.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2013-07-04T00:33:57.000Z","updated_at":"2022-07-19T07:42:51.000Z","dependencies_parsed_at":"2022-07-31T16:08:59.086Z","dependency_job_id":null,"html_url":"https://github.com/brycebaril/node-stream-spigot","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brycebaril%2Fnode-stream-spigot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brycebaril%2Fnode-stream-spigot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brycebaril%2Fnode-stream-spigot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brycebaril%2Fnode-stream-spigot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brycebaril","download_url":"https://codeload.github.com/brycebaril/node-stream-spigot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224960706,"owners_count":17398910,"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-08-02T05:01:04.199Z","updated_at":"2024-11-16T19:27:51.099Z","avatar_url":"https://github.com/brycebaril.png","language":"JavaScript","readme":"Stream Spigot\n=============\n\n[![NPM](https://nodei.co/npm/stream-spigot.png)](https://nodei.co/npm/stream-spigot/)\n\nA generator for (streams2) Readable streams, useful for testing or converting simple lazy functions into Readable streams, or just creating Readable streams without all the boilerplate.\n\n```javascript\nvar spigot = require(\"stream-spigot\")\n\nspigot.array([\"ABCDEFG\"]).pipe(process.stdout)\n// ABCDEFG\n\nspigot.array([\"ABC\", \"DEF\", \"G\"]).pipe(process.stdout)\n// same as: (short form)\nspigot([\"ABC\", \"DEF\", \"G\"]).pipe(process.stdout)\n// ABCDEFG\n\n\n// Create a stream out of a synchronous generator:\nvar count = 0\nfunction gen() {\n  if (count++ \u003c 5) {\n    return {val: count}\n  }\n}\n\nspigot.sync({objectMode: true}, gen).pipe(...)\n/*\n{val: 1}\n{val: 2}\n{val: 3}\n{val: 4}\n{val: 5}\n*/\n\n\n// Create a more traditional Readable stream:\nvar source = spigot({objectMode: true}, function () {\n  var self = this\n  iterator.next(function (err, value) {\n    if (err) return self.emit(\"error\", err)\n    self.push(value)\n  })\n})\n\nsource.pipe(...)\n\n```\n\nUsage\n=====\n\nspigot([options,] _read)\n---\n\nCreate a Readable stream instance with the specified _read method. Your _read method should follow the normal [stream.Readable _read](http://nodejs.org/api/stream.html#stream_readable_read_size_1) syntax. (I.e. it should call `this.push(chunk)`)\n\nspigot([options, ], array)\n---\n\nCreate a Readable stream instance that will emit each member of the specified array until it is consumed. Creates a copy of the given array and consumes that -- if this will cause memory issues, consider implementing your own _read function to consume your array.\n\nvar Spigot = spigot.ctor([options,], _read)\n---\n\nSame as the above except provides a constructor for your Readable class. You can then create instances by using either `var source = new Spigot()` or `var source = Spigot()`.\n\nvar Spigot = spigot.ctor([options,], array)\n---\n\nSame as the above except provides a constructor for your Readable class. You can then create instances by using either `var source = new Spigot()` or `var source = Spigot()`.\n\nspigot.array([options, ], array)\n---\n\nA manual version of the above to specify an array.\n\n\nspigot.sync([options,] fn)\n------------------------\n\nCreate a readable instance providing a synchronous generator function. It will internally wrap your synchronous function as an async function.\n\nOptions\n-------\n\nAccepts standard [readable-stream](http://npmjs.org/api/stream.html) options.\n\nLICENSE\n=======\n\nMIT\n","funding_links":[],"categories":["JavaScript","模块","Modules"],"sub_categories":["数据流-Stream","Stream"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrycebaril%2Fnode-stream-spigot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrycebaril%2Fnode-stream-spigot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrycebaril%2Fnode-stream-spigot/lists"}