{"id":21990093,"url":"https://github.com/skyhacker2/yieldflow","last_synced_at":"2025-03-23T03:16:38.401Z","repository":{"id":57403775,"uuid":"53098324","full_name":"skyhacker2/yieldflow","owner":"skyhacker2","description":null,"archived":false,"fork":false,"pushed_at":"2016-03-04T02:12:43.000Z","size":2,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T18:57:57.755Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skyhacker2.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":"2016-03-04T01:42:49.000Z","updated_at":"2016-07-18T14:55:57.000Z","dependencies_parsed_at":"2022-08-26T01:23:11.251Z","dependency_job_id":null,"html_url":"https://github.com/skyhacker2/yieldflow","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/skyhacker2%2Fyieldflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyhacker2%2Fyieldflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyhacker2%2Fyieldflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skyhacker2%2Fyieldflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skyhacker2","download_url":"https://codeload.github.com/skyhacker2/yieldflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245048278,"owners_count":20552483,"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-11-29T19:37:11.877Z","updated_at":"2025-03-23T03:16:38.382Z","avatar_url":"https://github.com/skyhacker2.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yieldflow\n\u003e Asynchronous becomes synchronous with the yield\n\n## Install\n\n```\nnpm install yieldflow\n```\n\n## Usage\n\n```\nvar yieldflow = require('yieldflow');\n\nvar assert = require('assert');\n\nfunction login(username, password, callback) {\n    assert(username);\n    assert(password);\n    assert(callback);\n    setTimeout(()=\u003ecallback(0), 1000);\n}\n\nfunction sendmsg(msg, callback) {\n    assert(msg);\n    setTimeout(()=\u003ecallback(msg), 500);\n}\n\nyieldflow(function* (next){\n    var code = yield login('user', '123', (code)=\u003e{\n        next(code);\n    });\n    console.log('login: ' + code);\n\n    var sendText = yield sendmsg('xxx', (text)=\u003e{\n        next(text);\n    });\n    console.log('send: ' + sendText);\n\n    sendText = yield sendmsg('fuck', (text)=\u003e {\n        next(text);\n    });\n    console.log('send: ' + sendText);\n});\n\n```\n\nresult print:\n\n```\nlogin: 0\nsend: xxx\nsend: fuck\n```\n\n`login` and `sendmsg` is two asyns function.\n\n`yeildflow` pass a next function to you, you will call `next(result)` in the async function callback to return the result to yield operation (`var code = yield login(...);`) and move one step.\n\nHave fun.\n\n## License\n\nMIT: http://rem.mit-license.org","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskyhacker2%2Fyieldflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskyhacker2%2Fyieldflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskyhacker2%2Fyieldflow/lists"}