{"id":15154483,"url":"https://github.com/hiddentao/generator-compose","last_synced_at":"2026-02-23T03:40:25.044Z","repository":{"id":25574891,"uuid":"29008664","full_name":"hiddentao/generator-compose","owner":"hiddentao","description":"Compose generator middleware, with arguments pass-through","archived":false,"fork":false,"pushed_at":"2015-01-10T14:15:35.000Z","size":132,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T20:38:25.985Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hiddentao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-09T08:54:11.000Z","updated_at":"2015-01-10T14:15:35.000Z","dependencies_parsed_at":"2022-07-26T09:47:58.920Z","dependency_job_id":null,"html_url":"https://github.com/hiddentao/generator-compose","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/hiddentao%2Fgenerator-compose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiddentao%2Fgenerator-compose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiddentao%2Fgenerator-compose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiddentao%2Fgenerator-compose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hiddentao","download_url":"https://codeload.github.com/hiddentao/generator-compose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648904,"owners_count":20972944,"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-09-26T17:40:37.821Z","updated_at":"2025-10-25T01:10:07.173Z","avatar_url":"https://github.com/hiddentao.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# generator-compose\n\n[![Build Status](https://secure.travis-ci.org/hiddentao/generator-compose.png)](http://travis-ci.org/hiddentao/generator-compose)\n\nCompose generator middleware, with arguments pass-through.\n\nInspired by [koa-compose](https://github.com/koajs/compose), this library allows for arguments to be passed through \nto each middleware within the chain.\n\n## Installation\n\n```bash\n$ npm install generator-compose\n```\n\n## Usage\n\n```js\nvar compose = require('generator-compose');\n\nvar middleware = [\n  function*(param1, param2, next) {\n    // do some stuff...\n\n    yield next;\n  },\n  function*(param1, param2, next) {\n    // do some stuff...\n\n    yield next;\n\n    // do some more stuff if you like...\n  },\n  function*(param1, param2, next) {\n    // do some stuff...\n\n    yield next;\n  }\n];\n\n// example parameters\nvar obj1 = {},\n  obj2 = {};\n\ntry {\n  var fn = yield compose(middleware);\n\n  fn(obj1, obj2);\n} catch (err) {\n  // catch error thrown from within middleware methods\n}\n```\n\nAs shown above, each middleware method gets passed the original parameters as \nwell as a final `next` callback - which allows it to pass control to the next \nmiddleware in the chain.\n\nBy default the `this` context within each middleware method is the same as that \nfor the outer call:\n\n\n```js\nvar middleware = [\n  function*(next) {\n    console.log(this.value);  // 2\n\n    yield next;\n  },\n];\n\nthis.value = 2;\n\nvar fn = yield compose(middleware);\n\nfn();  // same as: fn.call(this)\n```\n\n## Building\n\nTo run the tests:\n\n    $ npm install -g gulp\n    $ npm install\n    $ npm test\n\n## Contributing\n\nContributions are welcome! Please see [CONTRIBUTING.md](https://github.com/hiddentao/generator-compose/blob/master/CONTRIBUTING.md).\n\n## License\n\nMIT - see [LICENSE.md](https://github.com/hiddentao/generator-compose/blob/master/LICENSE.md)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiddentao%2Fgenerator-compose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhiddentao%2Fgenerator-compose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiddentao%2Fgenerator-compose/lists"}