{"id":19217494,"url":"https://github.com/lwdgit/myflow","last_synced_at":"2026-06-15T04:33:01.425Z","repository":{"id":57306596,"uuid":"83223410","full_name":"lwdgit/myflow","owner":"lwdgit","description":"A js async flow without side effects.","archived":false,"fork":false,"pushed_at":"2017-05-20T04:24:44.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-23T18:32:23.544Z","etag":null,"topics":["flow"],"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/lwdgit.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":"2017-02-26T16:29:34.000Z","updated_at":"2017-05-20T04:23:38.000Z","dependencies_parsed_at":"2022-08-29T02:41:15.433Z","dependency_job_id":null,"html_url":"https://github.com/lwdgit/myflow","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lwdgit/myflow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwdgit%2Fmyflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwdgit%2Fmyflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwdgit%2Fmyflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwdgit%2Fmyflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lwdgit","download_url":"https://codeload.github.com/lwdgit/myflow/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwdgit%2Fmyflow/sbom","scorecard":{"id":606538,"data":{"date":"2025-08-11","repo":{"name":"github.com/lwdgit/myflow","commit":"7282aea7ae23b0157cfb656bd2f0460ed1dd9845"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/6 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-21T01:44:15.592Z","repository_id":57306596,"created_at":"2025-08-21T01:44:15.593Z","updated_at":"2025-08-21T01:44:15.593Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34348291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["flow"],"created_at":"2024-11-09T14:22:30.742Z","updated_at":"2026-06-15T04:33:01.404Z","avatar_url":"https://github.com/lwdgit.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# myflow\n\n\u003e 异步流程控制库，完全消除异步流程中的副作用。\n\n\n## 安装\n\n\u003e npm install myflow \n\n## 功能特色\n\n  * 语法简洁，支持多级流程嵌套\n  * 支持分支流程\n  * 支持同步异步\n  * 支持继承拓展\n  * 支持数据传递combo传递\n  * 支持两种书写形式(pipe与参数串连写法) [可以根据需求自行组织]\n  \n\n## Example\n\n### simple\n\n```\nconst flow = require('myflow');\nflow(\n    task1, \n    [task2, task3],\n    flow(task4_1, task4_2),\n    task5,\n    {\n        'task6_1': task6_1,\n        'task6_2': task6_2\n    }\n)\n.run();\n\n```\n\n### basic \n```\nconst flow = require('myflow');\nconst sleep = function (ms) {\n    return new Promise(resolve =\u003e setTimeout(resolve, ms));\n};\nflow()\n.pipe(function () {\n    return 'main';\n})\n.pipe(function* (ret) {\n    yield sleep(200);\n    console.log(3, ret);\n    return 3;\n})\n.pipe(function (ret) {\n    return new Promise(function (resolve, reject) {\n        //some async function\n        setTimeout(function () {\n            resolve('done');\n        }, 20);\n    });\n})\n.pipe(function (ret) {\n    console.log(ret);\n})\n.run();//不可少\n```\n\n### extends\n\n```\nconst {\n    Flow\n} = require('myflow');\nconst sleep = function (ms) {\n    return new Promise(resolve =\u003e setTimeout(resolve, ms));\n};\n\nclass MyFlow extends Flow {\n    constructor(args) {\n        super(function () {\n            console.log('run with Args', args);\n            return args;\n        });\n        let ins;\n        process.nextTick(() =\u003e {\n            ins = this.run();\n        });\n    }\n    task1() {\n        return this.pipe(function (ret) {\n            console.log('task1', ret++);\n            return ret;\n        });\n    }\n    task2() {\n        return this.pipe(function (ret) {\n            return new Promise((resolve, reject) =\u003e {\n                setTimeout(() =\u003e {\n                    console.log('task2, 我有点慢。', ret++);\n                    resolve(ret);\n                }, 2000);\n            })\n        });\n    }\n    task3() {\n        return this.pipe(function* (ret) {\n            yield sleep(2000);\n            console.log('task3, 我睡觉刚起来，等等', ret++);\n            return ret;\n        })\n    }\n    someTasks() {\n        return this.append(function* (ret) {\n            console.log('task4', ret++);\n            return ret;\n        }, function (ret) {\n            console.log('task5', ret);\n            return ret * ret;\n        });\n    }\n    then(fn) {\n        return this.pipe(fn);\n    }\n    first() {\n        return this.prepend(function (ret) {\n            console.log('first', '强行插队');\n            return ret ? ret : -10;\n        })\n    }\n};\n\nnew MyFlow(1).task1().task2().task3().someTasks().first().then(function (ret) {\n    console.log('我接收到啦', ret);\n    return ret;\n});\n\n```\n\n## API\n\n### constructor(...tasks)\n初始化时添加tasks，支持 Generator Function\n``` \nflow(task1, task2).run();\n```\n### pipe(task: Function)\n添加一个task\n```\nflow().pipe(task3).run();\n```\n### append(...tasks)\n添加一批task\n```\nflow().append(task4, tasks5).run();\n```\n\n### prepend(...tasks)\n往前添加task\n```\nflow().prepend(task0).run();\n```\n\n### run(initValue)\n启动task。注：flow本身做为一个子task时不需要调用`run`方法。\n```\nflow(...tasks).run();\n```\n\n### all\n启动task, 并收集所有流程的返回值。\n```\nflow(...tasks).all();\n```\n\n### static spread(args: Array) 静态方法\n将 Array 数据平铺传递给下一级\n```\nflow([task1, task2], (ret1, ret2) =\u003e flow.spread([ret1, ret2]), (ret1, ret2) =\u003e task3)\n```\n\n### static resolve(...args) 静态方法\n将参数平铺传递给下一级\n```\nflow([task1, task2], (ret1, ret2) =\u003e flow.resolve(ret1, ret2), (ret1, ret2) =\u003e task3)\n```\n\n## Features\n\n### sync task\nTask依次执行\n```\nflow(function(initValue) {\n    return 1;\n}, function(ret) {\n    console.log(ret);// value is 1\n}, function* () {\n    yield sleep(1000);\n    return 2;\n}, function(ret) {\n    console.log(ret);//value is 2\n})\n.run()\n```\n\n### async task\nTask同时执行，执行时间以执行最长的task为准。\n```\nflow()\n.pipe(initValue) {\n    return 1;\n})\n.pipe([//并行执行开始\n    function(ret) {\n        console.log(ret);// value is 1\n        return ret++;\n    }, function* (ret) {\n        yield sleep(1000);\n        console.log(ret);// value is 1\n        return ret++;\n    }\n])\n.pipe(function(...ret) {\n    console.log(ret);//value is [2, 2]\n})\n.run()\n```\n\n### group task\nTask依次执行，执行结果以数据形式返回。\n```\nflow()\n.pipe(initValue) {\n    return 1;\n})\n.pipe(\n    flow(\n        function(ret) {\n            console.log(ret);// value is 1\n            return ret++;\n        }, function* (ret) {\n            yield sleep(1000);\n            console.log(ret);// value is 2\n            return ret++;\n        }\n    )\n)\n.pipe(function(...ret) {\n    console.log(ret);//value is [2, 3]\n})\n.run()\n```\n\n### condition task \n条件执行，根据上一级task的返回值进行特定的下一级task。\n\n```\nflow(function() {\n    return 'b';//return {task: 'b', otherParam: xxx}也行\n})\n.pipe({\n    'a': function() {\n        return 'a';\n    },\n    'b': function() {\n        return 'b';\n    }\n    'defalut': function() {//当上一级的返回没有进入到任何一个时，执行default\n        return 'defalut';\n    }\n})\n.pipe(function(ret) {\n    console.log(ret);// value is 'b';\n});\n\n```\n\n### pipe与...args写法\nflow也支持不用pipe的方式来连接任务。\n\n如:\n```\nflow().pipe(task1).pipe(task2).run();\n```\n可以写成:\n```\nflow(task1, task2).run();\n```\n\n例二：\n```\nflow()\n.pipe(task1)\n.pipe([task2, task3])\n.pipe(\n    flow().pipe(task4_1).pipe(task4_2)\n)\n.pipe(task5)\n.pipe({\n    'task6_1': task6_1,\n    'task6_2': task6_2\n})\n.run()\n```\n\n可以写成\n```\nflow(\n    task1, \n    [task2, task3],\n    flow(task4_1, task4_2),\n    task5,\n    {\n        'task6_1': task6_1,\n        'task6_2': task6_2\n    }\n).run()\n```\n\n\n更多详见 [test](./test)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwdgit%2Fmyflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flwdgit%2Fmyflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwdgit%2Fmyflow/lists"}