
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
babel-plugin-top-level-await
Advanced tools
babel plugin for automatically wrapping top level awaits
This is a simple Babel plugin which automatically wraps top-level await
expressions.
That is, it'll turn code like:
await fetch('http://www.google.com/')
into:
export const __async = true;
export default (async function(){
await fetch('http://www.google.com/')
})()
This implementation automatically hoists import declarations so that they remain at the top level:
import _ from "lodash";
import fs from "fs-promise"
var text = await fs.readFile('README.md', 'utf-8')
console.log(text)
This is transpiled conveniently into:
import _ from "lodash";
import fs from "fs-promise"
export const __async = (async function(){
var text = await fs.readFile('README.md', 'utf-8')
console.log(text)
})()
In addition, transformed modules export __async
which is the promise of the wrapped async expression.
The current implementation doesn't support exports. Top level awaits might interfere with the behavior of certain modules (as many of their exports may not be defined until well after the module has been loaded). Anyway, this top-level await transform is primarily useful for REPL-style interactions, as essentially a convenience to avoid wrapping things with an async IIFE (immediately invoked function expression).
Additional Information: https://github.com/tc39/ecmascript-asyncawait/issues/9
There's a demo in the test/
folder
babel-node --presets es2015 transform.js
FAQs
babel plugin for automatically wrapping top level awaits
The npm package babel-plugin-top-level-await receives a total of 4 weekly downloads. As such, babel-plugin-top-level-await popularity was classified as not popular.
We found that babel-plugin-top-level-await demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.