{"id":21557693,"url":"https://github.com/danielrohers/node-async-await","last_synced_at":"2025-09-10T08:36:55.351Z","repository":{"id":151566935,"uuid":"88028101","full_name":"danielrohers/node-async-await","owner":"danielrohers","description":"Example node async-await","archived":false,"fork":false,"pushed_at":"2017-04-12T21:26:13.000Z","size":1,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-03T02:10:42.823Z","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/danielrohers.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-12T08:26:20.000Z","updated_at":"2017-04-12T13:30:02.000Z","dependencies_parsed_at":"2023-07-12T02:15:16.441Z","dependency_job_id":null,"html_url":"https://github.com/danielrohers/node-async-await","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danielrohers/node-async-await","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielrohers%2Fnode-async-await","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielrohers%2Fnode-async-await/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielrohers%2Fnode-async-await/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielrohers%2Fnode-async-await/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielrohers","download_url":"https://codeload.github.com/danielrohers/node-async-await/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielrohers%2Fnode-async-await/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269948901,"owners_count":24501835,"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","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"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":[],"created_at":"2024-11-24T08:12:56.827Z","updated_at":"2025-08-11T20:15:04.082Z","avatar_url":"https://github.com/danielrohers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-async-await\n\nExample node async-await\n\n## Old (only with promises)\n\n[index-old.js](index-old.js)\n```js\nconst getText = () =\u003e {\n  return new Promise((resolve, reject) =\u003e {\n    let timeout = setTimeout(() =\u003e {\n      resolve('Hi :)');\n      clearTimeout(timeout);\n    }, 3000);\n  })\n}\n\nconst makeText = () =\u003e {\n  console.log('init');\n  getText()\n    .then(console.log)\n    .then(() =\u003e console.log('end'));\n}\n\nmakeText();\n```\n\n[series-old.js](series-old.js)\n```js\nconst getText = () =\u003e {\n  return new Promise((resolve, reject) =\u003e {\n    let timeout = setTimeout(() =\u003e {\n      console.log('Hi :)');\n      resolve();\n      clearTimeout(timeout);\n    }, 1000);\n  })\n}\n\nconst makeText = () =\u003e {\n  console.log('init');\n  getText()\n    .then(getText)\n    .then(getText)\n    .then(getText)\n    .then(getText)\n    .then(() =\u003e console.log('end'))\n}\n\nmakeText();\n```\n\n## New (with async-await)\n\n[index.js](index.js)\n```js\nconst getText = () =\u003e {\n  return new Promise((resolve, reject) =\u003e {\n    let timeout = setTimeout(() =\u003e {\n      resolve('Hi :)');\n      clearTimeout(timeout);\n    }, 3000);\n  })\n}\n\nconst makeText = async () =\u003e {\n  console.log('init');\n  console.log(await getText());\n  console.log('end');\n}\n\nmakeText();\n```\n[series.js](series.js)\n```js\nconst getText = () =\u003e {\n  return new Promise((resolve, reject) =\u003e {\n    let timeout = setTimeout(() =\u003e {\n      console.log('Hi :)');\n      resolve();\n      clearTimeout(timeout);\n    }, 1000);\n  })\n}\n\nconst makeText = async () =\u003e {\n  console.log('init');\n  await getText();\n  await getText();\n  await getText();\n  await getText();\n  await getText();\n  console.log('end');\n}\n\nmakeText();\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielrohers%2Fnode-async-await","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielrohers%2Fnode-async-await","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielrohers%2Fnode-async-await/lists"}