Convert Promise to async function
See original GitHub issueInput:
var promise = function() {
return new Promise((resolve) => function() {
setTimeout(resolve, 200, 4);
});
};
var aF = function() {
return new Promise(resolve => {
promise.then((data) => {
resolve(data);
});
});
}
Expected output:
let promise = () => new Promise((resolve) => function() {
setTimeout(resolve, 200, 4);
});
};
let aF = async () => {
return await promise;
};
Issue Analytics
- State:
- Created 7 years ago
- Reactions:8
- Comments:14
Top Results From Across the Web
Convert Promise-Based Chain to Async/Await with VS Code
Converting Promises to Async/Await with Visual Studio Code · First, select the code that conatins the Promise.then() calls, · Next, click the ...
Read more >Converting promises to async/await - Javascript - Stack Overflow
I have a dataService function in React that does my API fetching. I tried converting to async/await block but seem to hit a...
Read more >Migrating from Promise chains to Async/Await - AfterAcademy
Introduces Async/Await and compare it with Promises. We shall discuss migrating your from Promise Chains to Async/Await .
Read more >Convert A Promise To ASYNC/AWAIT - DEV Community
This is a simple function that returns a promise. The promise resolves to a value of type string, and of value "resolved" after...
Read more >Automatically convert Promise.then() into async/await - VS Code
Focus on some code which uses .then() with Promise related code · Click the lightbulb icon which appears in the line gutter ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tunnckoCore Ah, I guess my comment was pretty ambiguous. My concern wasn’t about babylon, but about Recast supporting the things babylon supports.
I’m pleased to announce a new codemod I developed for this. It’s still a bit of a work in progress, but it’s getting pretty baller. You may be interested in integrating it into lebab. (Although the README shows how to use it with jscodeshift, the transform is actually implemented with pure babel 7).
https://github.com/codemodsquad/asyncify
Right now if you want to see examples look in the tests. I’ll plan on making a try-it site in the next few days.