Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
babel-plugin-async-to-plain-generator
Advanced tools
Transform async functions into non-wrapped ES2015 generators
While working with KoaJS v1 we found that the resulting output from transform-async-to-generator was incompatible with Koa's requirements - that app.use
must be passed a generator function.
This plugin was created by modifying the transform-async-to-generator plugin. While that plugin works well in most situations, it curiously (and extraneously?) wraps async functions and results in a generator function wrapped in a regular function of the same name. This plugin was created so that babel would produce plain old vanilla generator functions from async function declarations.
// in
[].forEach(async (a) => {
await a;
});
async function foo (bar) {
await bar;
};
// out
[].forEach(function* (a) {
yield a;
});
function* foo (bar) {
yield bar;
}
$ npm install babel-plugin-async-to-plain-generator
.babelrc
(Recommended).babelrc
{
"plugins": ["async-to-plain-generator"]
}
$ babel --plugins async-to-plain-generator script.js
require("babel-core").transform("code", {
plugins: ["async-to-plain-generator"]
});
FAQs
Transform async functions into non-wrapped ES2015 generators
We found that babel-plugin-async-to-plain-generator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.