{"id":24956955,"url":"https://github.com/prodo-dev/js-async","last_synced_at":"2025-03-28T20:38:25.817Z","repository":{"id":57138173,"uuid":"131324325","full_name":"prodo-dev/js-async","owner":"prodo-dev","description":"JavaScript utility library for using async/await","archived":false,"fork":false,"pushed_at":"2018-08-06T20:15:28.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-26T06:21:01.776Z","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/prodo-dev.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":"2018-04-27T17:07:42.000Z","updated_at":"2018-08-06T20:15:30.000Z","dependencies_parsed_at":"2022-08-25T10:10:22.579Z","dependency_job_id":null,"html_url":"https://github.com/prodo-dev/js-async","commit_stats":null,"previous_names":["prodo-ai/js-async"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prodo-dev%2Fjs-async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prodo-dev%2Fjs-async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prodo-dev%2Fjs-async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prodo-dev%2Fjs-async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prodo-dev","download_url":"https://codeload.github.com/prodo-dev/js-async/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246100419,"owners_count":20723466,"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-02-03T06:41:46.716Z","updated_at":"2025-03-28T20:38:25.794Z","avatar_url":"https://github.com/prodo-dev.png","language":"JavaScript","readme":"# JS ASync\n\nUtility library for handling async/await.\n\n## Usage\n\n### denodeify\n\nTurns a function that accepts a node-style callback into one that returns a `Promise`:\n\n```javascript\nimport {denodeify} from \"@prodo-ai/js-async\";\n\nconst nodeStyleFunction = (arg1, arg2, callback) =\u003e {\n  if (arg1 == null) {\n    callback(new Error(\"Must specify `arg1`.\"));\n  }\n  callback(null, arg1 + arg2);\n}\n\nconst asyncFunction = denodeify(nodeStyleFunction);\n\nasyncFunction(1, 2)\n  .then(console.log)\n  .catch(console.error);\n```\n\n### fromCallback\n\nThe same as `denodeify`, but without error handling. Probably don't use this.\n\n### keepTrying\n\nKeeps attempting a behaviour until it succeeds:\n\n```javascript\nimport {keepTrying} from \"@prodo-ai/js-async\";\n\nconst result = await keepTrying({\n  behaviour: () =\u003e service.getResult()\n});\n```\n\nYou can also pass additional parameters for greater control:\n\n* `until` - a predicate that can be used to determine success. By default, this predicate just checks if the result is non-null.\n* `ignoreErrors` - if `false`, gives up trying after an error is thrown.\n* `timeout` - a timeout, after which an `Error` is thrown.\n* `inbetweenAttempts` - a callback that is executed between each attempt.\n\n### waitUntil\n\nWaits until a predicate passes:\n\n```javascript\nimport {waitUntil} from \"@prodo-ai/js-async\";\nimport {duration, SECOND} from \"@prodo-ai/js-timing\";\n\nwaitUntil({\n  condition: async () =\u003e (await service.getStatus()) === \"OK\",\n  pauseTime: duration(1, SECOND),\n}).then(service.getResult);\n```\n\nYou can also pass additional parameters for greater control:\n\n* `timeout` - a timeout, after which an `Error` is thrown.\n\n\n## Information\n\nOwner: Prodo Tech Ltd\n\nMaintainer: [tdawes](https://github.com/tdawes)\n\nLicense: UNLICENSED (for now)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprodo-dev%2Fjs-async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprodo-dev%2Fjs-async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprodo-dev%2Fjs-async/lists"}