Use this tag for questions about features finalized in ECMAScript 2017. Do *not* use this tag if the code in question merely *uses* one of the features, *unless* the feature is cause of the problem.
ECMA-2017(ES8), just finalized about a month ago, introduces SharedArrayBuffer and Atomics. The link here shows that they have been supported in some browsers.
As we know, they are meant to allow the sharing of data across threads. I wonder how this…
I'm using the native fetch library as specified here. It seems that whenever a response other than a 200 OK is returned it throws an exception with the string response Uncaught (in promise) TypeError: Failed to fetch.
Was there a way to catch and…
The issue
I'm curious if it would be possible to consume a generator-function in async/await context within modern ES2017. (The application is a React-native-application)
This is my code where I want to call the generator function:
class…
Reading the ECMAScript specification, it seems both an Environment Record (a component of a Lexical Environment), and a Reference is used to determine what variable / function an Identifier is bound to. In other words, finding the actual value…
If I use async/await function in a nested function call, I think the callers of that async/await functions should have async/await prefix.
For example, in this situation:
function a() {
b();
}
function b() {
c();
}
function c() {
…
I've seen a lot of articles about how use async/await in your unit tests, but my need is the opposite.
How do you write a test for a method that uses async/await?
My spec is not able to reach any code after the 'await' line. Specifically, the spec…
The MDN documentation for async function currently gives the following combined example of two ways to use await. I've reordered it just a bit for emphasis:
function resolveAfter2Seconds(x) {
return new Promise(resolve => {
setTimeout(() => {
…
How to refer to class instance when called from an async method.
class Senders {
callSendAPI() {
//Some code here
}
sendText() {
this.callSendAPI();
}
async sendCards() {
var dbpromise = await db.call();
console.log('this=…
I have TypeScript project with ES6 target, it uses core-js to polyfill ES2017 features and tsconfig.json is configured accordingly.
When Object.entries(...) and Object.values(...) are used, the results don't have array methods and properties (map,…
Can you stop code outside of the async function using await? However, I don't want all code to stop. I want to control what code will run.
I think there might be a solution, something like this:
var isAsyncRunning = false;
var currentPromise;
async…
I have promise objects which need to work synchronize. For example second promise shouldn't work before first one is done. If first one rejects first one has to be executed again.
I have implemented some examples.This one works well.
call getVal,…
I am curious why methods cannot call other methods or themselves in javascript. For example, this produces a Reference error saying add is not defined.
class sum {
add(x, amt) {
if(amt == 0) return x
return add(x+1, amt-1)
}
}
summer =…