{"id":28220920,"url":"https://github.com/morulus/thens","last_synced_at":"2025-06-10T09:30:37.350Z","repository":{"id":57376996,"uuid":"110413189","full_name":"morulus/thens","owner":"morulus","description":"Promise then in the plural, but something more","archived":false,"fork":false,"pushed_at":"2022-12-06T17:14:51.000Z","size":103,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-18T04:16:31.442Z","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/morulus.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-11-12T07:20:33.000Z","updated_at":"2020-07-02T14:10:21.000Z","dependencies_parsed_at":"2023-01-24T10:15:46.579Z","dependency_job_id":null,"html_url":"https://github.com/morulus/thens","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/morulus%2Fthens","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fthens/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fthens/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fthens/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morulus","download_url":"https://codeload.github.com/morulus/thens/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morulus%2Fthens/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259047870,"owners_count":22797614,"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":"2025-05-18T04:16:29.888Z","updated_at":"2025-06-10T09:30:37.282Z","avatar_url":"https://github.com/morulus.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Thens 🕺🏻 🕺🏻 🕺🏻\n==\n\nThe instrument to create async functions sequence, powered by Promise. It is Promise.`then` in the plural.\n\nForget about `Promise.resolve`, or `new Promise`, or `then.then.then` chain. Just compose functions and await result. Or use it as handler for native `then`, or a part of `thens`. And don't forget it **supports [generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function%2A)**.\n\nEnjoy.\n\n```shell\nyarn add thens\n```\n\nUsage.\n\n```js\nimport thens from 'thens';\n\nconst calc = thens(\n  // Static\n  a =\u003e a + 1, \n  // Async like\n  b =\u003e Promise.resolve(b + 1),\n  // Real async\n  c =\u003e new Promise((resolve) =\u003e setTimeout(() =\u003e resolve(c + 1))),\n  // Like Promise.all\n  [\n    d =\u003e d + 1,\n    d =\u003e Promise.resolve(d + 2),\n    d =\u003e new Promise((resolve) =\u003e setTimeout(() =\u003e resolve(d + 3))),\n  ],\n  // Generator, driven by rebound runner\n  function* ([e, f, g]) {\n    // Async inside generator\n    const h = yield Promise.resolve(e + f + g);\n    try {\n      throw new Error('Unexpected error');\n    } catch(e) {\n      // Error handler inside generator\n      return h;\n    }\n  }\n);\n\ncalc(0)\n.then(console.log) // 15\n.catch(console.warn); // And don't forget to add final catch\n```\n\n## License\n\nMIT, 2017, Vladimir Kalmykov \u003cvladimirmorulus@gmail.com\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorulus%2Fthens","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorulus%2Fthens","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorulus%2Fthens/lists"}