How do I make an "async/await" operator for Jint?

See original GitHub issue

I made a function in C# for Promise, Async and Await, but I don’t want it to be “async / await” functions in javascript, but an operator.

It works in my custom Jint.Engine like that

var async_example = async(function()
{
  return 2;
})
var t = async_example();
console.log(await(t))
// 2

But I would like it that way:

var async_example = async function()
{
  return 2;
}
var t = async_example();
console.log(await t)
// 2

I wanted to add the “async / await” operator to Jint. Please help me.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
lahmacommented, Oct 20, 2022

async/await has been implemented as first class citizen in main branch.

0reactions
lahmacommented, Dec 11, 2021

Closing this as duplicate of #514 , we have the promises, but async/await needs to be done. I think generators need to be done as it has some building blocks once again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Await operator can only be used within an Async method
1 Answer 1 ... You can only use await in an async method, and Main cannot be async . You'll have to use...
Read more >
Async programming
The error message is The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier...
Read more >
Async/Await Function in JavaScript
Await : Await function is used to wait for the promise. It could be used within the async block only. It makes the...
Read more >
Async/Await, Combine, Closures: A Guide to Modern ...
A comparison between async/await, Combine, and closures in Swift. Includes an overview of the strengths and weaknesses of the different ...
Read more >
Asynchronous Programming Using Async/Await in C# ...
The return type of an async method is always Task or Task<T> . It's checked by the compiler, so there's not much room...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found