{"id":18665328,"url":"https://github.com/robertklep/top-level-await","last_synced_at":"2025-04-11T22:31:08.752Z","repository":{"id":57378038,"uuid":"92152989","full_name":"robertklep/top-level-await","owner":"robertklep","description":"Use `await` at your Node.js code's top level!","archived":false,"fork":false,"pushed_at":"2017-05-24T08:12:20.000Z","size":3,"stargazers_count":126,"open_issues_count":1,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-07T08:46:39.644Z","etag":null,"topics":["async-await","javascript","nodejs"],"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/robertklep.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":"2017-05-23T09:13:18.000Z","updated_at":"2024-01-04T16:14:17.000Z","dependencies_parsed_at":"2022-09-19T19:06:29.764Z","dependency_job_id":null,"html_url":"https://github.com/robertklep/top-level-await","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertklep%2Ftop-level-await","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertklep%2Ftop-level-await/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertklep%2Ftop-level-await/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertklep%2Ftop-level-await/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertklep","download_url":"https://codeload.github.com/robertklep/top-level-await/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223482404,"owners_count":17152516,"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":["async-await","javascript","nodejs"],"created_at":"2024-11-07T08:27:13.063Z","updated_at":"2024-11-07T08:27:13.758Z","avatar_url":"https://github.com/robertklep.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# top-level-await (PoC)\n\nAllow using `await` at your code's top level. Requires Node.js v7.6.0 or higher.\n\nNot this:\n```\n// 💩\n(async function() {\n  console.log(await Promise.resolve('hello world'));\n})();\n```\n\nBut this:\n```\n// 🎉\nconsole.log(await Promise.resolve('hello world'));\n```\n\n## Installation\n\n```\nnpm i top-level-await\n```\n\n## Usage\n\nIt's a two-step process: first `require()` this module, then `require()`\nthe rest of your code:\n\n```\n// bootstrap.js\nrequire('top-level-await');\nrequire('./app');\n```\n\nInside `app.js`, you can use `await` whenever you like.\n\nYou can also tell Node to require the module for you, instead of using\na separate bootstrap script:\n```\n$ node -r top-level-await app\n```\n\nWhich works for CLI tools too:\n```\n#!/usr/bin/env node -r top-level-await\n\nconsole.log( await Promise.resolve('hello world') );\n```\n\n## How?\n\nBy hacking `Module.wrap()`.\n\nThis is done without prejudice, so all modules that get loaded after loading this module will be \"fixed\".\n\n## Is it production-ready?\n\n```\n¯\\_(ツ)_/¯\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertklep%2Ftop-level-await","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertklep%2Ftop-level-await","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertklep%2Ftop-level-await/lists"}