{"id":16326671,"url":"https://github.com/chrisyip/yieldr","last_synced_at":"2025-05-14T22:12:17.965Z","repository":{"id":25346734,"uuid":"28774226","full_name":"chrisyip/yieldr","owner":"chrisyip","description":"Run functions and generator functions, and wrap result into a promise.","archived":false,"fork":false,"pushed_at":"2015-01-09T08:52:02.000Z","size":156,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-14T22:12:17.233Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/chrisyip.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":"2015-01-04T12:57:31.000Z","updated_at":"2015-05-10T09:38:09.000Z","dependencies_parsed_at":"2022-08-24T00:21:07.501Z","dependency_job_id":null,"html_url":"https://github.com/chrisyip/yieldr","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Fyieldr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Fyieldr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Fyieldr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Fyieldr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisyip","download_url":"https://codeload.github.com/chrisyip/yieldr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235712,"owners_count":22036966,"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-10T23:09:15.438Z","updated_at":"2025-05-14T22:12:17.939Z","avatar_url":"https://github.com/chrisyip.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yieldr\n\n[![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Travis CI][travis-image]][travis-url] [![Coveralls][coveralls-image]][coveralls-url]\n\n# Installation\n\n```shell\nnpm install yieldr\n```\n\n# Usage\n\n```js\nvar yieldr = require('yieldr')\n\nfunction* bar () {\n  return Promise.resolve('bar')\n}\n\nyieldr(function* () {\n  var foo = yield 'foo'\n  var bar = yield bar()\n\n  return foo + bar\n}).then(function (res) {\n  console.log(res) // 'foobar'\n})\n```\n\n# Yieldables\n\nYou can yield anything just like [native `yield`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield).\n\n```js\nyieldr(function* () {\n  var foo = yield 'foo'\n  var isTrue = yield true\n  var zero = yield 0\n})\n```\n\nBut `yieldr` will try to resolve these types:\n\n- Promises\n- Generators and generator functions\n\n```js\nvar fs = require('mz/fs')\n\nyieldr(function* () {\n  var content = yield fs.readFile(FILE_PATH)\n})\n```\n\nNote: there is a [`yield*` expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield*) in ECMAScript 6, and it's designed for delegating to another generator or iterable object.\n\n# Compatibility\n\n`yieldr` requires `Promise`, you should use node `\u003e=0.11.9` or include a polyfill (try [bluebird](https://www.npmjs.com/package/bluebird)).\n\n# Contributors\n\nVia [GitHub](https://github.com/chrisyip/yieldr/graphs/contributors)\n\n[npm-url]: https://npmjs.org/package/yieldr\n[npm-image]: http://img.shields.io/npm/v/yieldr.svg?style=flat-square\n[daviddm-url]: https://david-dm.org/chrisyip/yieldr\n[daviddm-image]: http://img.shields.io/david/chrisyip/yieldr.svg?style=flat-square\n[travis-url]: https://travis-ci.org/chrisyip/yieldr\n[travis-image]: http://img.shields.io/travis/chrisyip/yieldr.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/chrisyip/yieldr\n[coveralls-image]: http://img.shields.io/coveralls/chrisyip/yieldr.svg?style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisyip%2Fyieldr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisyip%2Fyieldr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisyip%2Fyieldr/lists"}