Regarding compatibility between ECMAScript specification and actual implementation; It is fairly easy to check out the data about browser support for ECMAScript2015 (ES6), but I found it pretty difficult to have an equivalently clear table for all the following ES versions (ES7+). By the time this question is asked: Mozilla has some info on their website: it is possible to
Tag: ecmascript-2017
Correct Try…Catch Syntax Using Async/Await
I like the flatness of the new Async/Await feature available in Typescript, etc. However, I’m not sure I like the fact that I have to declare the variable I’m awaiting on the outside of a try…catch block in order to use it later. Like so: Please correct me if I’m wrong, but it seems to be best practice not to
When to mark function as async
Basically, function must be prefixed with async keyword if await used inside it. But if some function just returns Promise and doesn’t awaiting for anything, should I mark the function as async? Seems like both correct or not? Answer if some function just returns Promise and doesn’t awaiting for anything, should I mark the function as async? I would say
Chain async functions
In an async function, I can get an asynchronous value like so: const foo = await myAsyncFunction() If I want to call a method on the result, with a sync function I’d do something like myAsyncFunction().somethingElse() Is it possible to chain calls with async functions, or do you have to assign a new variable for each result? Answer I prefer
How to use ES8 async/await with streams?
In https://stackoverflow.com/a/18658613/779159 is an example of how to calculate the md5 of a file using the built-in crypto library and streams. But is it possible to convert this to using ES8 async/await instead of using the callback as seen above, but while still keeping the efficiency of using streams? Answer The await keyword only works on promises, not on streams.
Combination of async function + await + setTimeout
I am trying to use the new async features and I hope solving my problem will help others in the future. This is my code which is working: The problem is, that my while loop runs too fast and the script sends too many requests per second to the google API. Therefore I would like to build a sleep function