{"id":16681447,"url":"https://github.com/printercu/flow-coffee","last_synced_at":"2025-03-13T10:24:10.553Z","repository":{"id":6636358,"uuid":"7880355","full_name":"printercu/flow-coffee","owner":"printercu","description":"Easy way to control async flow","archived":false,"fork":false,"pushed_at":"2014-01-08T18:44:44.000Z","size":260,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-21T12:17:00.171Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/printercu.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-01-28T22:23:28.000Z","updated_at":"2016-07-02T00:32:10.000Z","dependencies_parsed_at":"2022-07-31T03:18:05.387Z","dependency_job_id":null,"html_url":"https://github.com/printercu/flow-coffee","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/printercu%2Fflow-coffee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/printercu%2Fflow-coffee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/printercu%2Fflow-coffee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/printercu%2Fflow-coffee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/printercu","download_url":"https://codeload.github.com/printercu/flow-coffee/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243384391,"owners_count":20282355,"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-12T14:04:15.218Z","updated_at":"2025-03-13T10:24:10.523Z","avatar_url":"https://github.com/printercu.png","language":"CoffeeScript","readme":"# Flow-coffee\n\nOriginal idea: [flow-js](https://github.com/willconant/flow-js).\nYou can read about the concept there.\n\nThis version is rewritten in coffee using prototypes.\nIt contains some extra features mostly needed for\n[costa](https://github.com/printercu/costa).\n\n## No js version\nThere is no js version. Just `require('coffee-script')` before\n`require('flow-coffee')`.\n\n## Extra features\n\n### Custom context\n```coffee\nobj =\n  someMethod: -\u003e # ...\n\ndo new flow(\n  context: obj\n  blocks: [\n    # If context is specified last argument is always a flow instance\n    (cb) -\u003e\n      @ == obj # true\n      cb() # It's callback\n    (cb) -\u003e\n      do (cb_multi = cb.multi()) -\u003e # multi is also available\n        setImmediate -\u003e cb_multi()\n    (err, results, cb) -\u003e # ...\n    'someMethod' # calls method from context\n    (err, cb) -\u003e # other callback\n  ]\n)\n```\n\n### downcase\n`REWIND`, `MULTI`, `TIMEOUT` are now `rewind`, `multi` \u0026 `setTitmeout`.\nOld names are left for compatibility.\n\n### `#define()` returns just function\n```coffee\nf = flow.define( -\u003e )\n\nf.exec()  # removed. no one used i think\nf()       # keep it simple\n```\n\n### prototype's aftermath\nThis version works only on engines that support `__proto__` (v8 \u0026 rhino do).\n\nNow it does mater what context you call `multi`, `setTimeout` and other methods.\n```coffee\nflow.exec(\n  -\u003e\n    multi = @multi\n    ... -\u003e\n      func multi() # wrong\n\n  -\u003e\n    state = @\n    ... -\u003e\n      func state.multi() # ok\n)\n```\n\n### Multiple results are stored in the order the `@multi()` is called, not callbacks\n```coffee\nnt = proccess.nextTick\nit 'should preserve results order', (cb) -\u003e\n  run = []\n  flow.exec(\n    -\u003e\n      do (cb = @multi()) -\u003e nt -\u003e nt -\u003e run.push 1; cb 1\n      # this will be ready first:\n      do (cb = @multi()) -\u003e nt -\u003e       run.push 2; cb 2\n    (err, results)-\u003e\n      assert.deepEqual run, [2, 1]\n      assert.deepEqual (x[0] for x in results), [1, 2]\n      @()\n    cb\n  )\n```\n\n### Function after `@multi` is called with 2 arguments\nIt's incompatible with original flow, but I've found it very convenient.\n\nFirst argument is set to the first error passed to any `@multi()`. Second is the original results array.\n\n### Callback on any error\n```coffee\nflow.exec(\n  -\u003e @ null, 'test'\n  (arg) -\u003e\n    # strips first (error) arguments for usual callbacks\n    assert.equal arg, 'test'\n    setImmediate =\u003e @ 'error'\n  -\u003e # this won't run\n).error (err) -\u003e\n  # this will run\n  # resume flow with @()\n```\n\n### Take a look at tests for examples \u0026 undocumented features\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprintercu%2Fflow-coffee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprintercu%2Fflow-coffee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprintercu%2Fflow-coffee/lists"}