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.
can someone explain, why Promise fires then() function (and also catch() function) when reject is called?
When resolve is called, only then() is trigger - OK
When reject is called, both then() and catch() function are called - Problem
static…
I am modernizing some code. It has a piece to load database implemented as:
var customerQueue = async.queue(insertCustomer, DATABASE_PARALLELISM);
customerQueue.drain = function() {
logger.info('all customers loaded');
…
I am inside of a folder src and want to create files insides another folder called dist. Below is what I want to do from inside the src folder. Create a json file inside of dist/JSON/{file goes here}
main
- src
index.js
- dist
- JSON
…
I am having some difficulties understanding the specific difference between Lexical Grammar and Syntactic Grammar in the ECMAScript 2017 specification.
Excerpts from ECMAScript 2017
5.1.2 The Lexical and RegExp Grammars
A lexical grammar for…
The below excerpts refer to ECMAScript 2017.
10.1 Source Text, Syntax
Escape sequences, like \u000A, will not be interpreted as line terminators (i.e. new lines):
In string literals, regular expression literals, template literals and
identifiers,…
In ECMA-262, version 5.x (aka. ECMAScript 5 | ES5), there used to be a section 13.2 called Creating Function Objects.
I have been searching through the latest version of the standard, ECMAScript 2017 (aka. ECMAScript 8 | ES8), but cannot find a…
I've got a strange problem..
FIrst, take a look at my code:
This one is where I use my await..
case "detail": {
const lineMessages = [];
let item = await this.getItem(postback.id);
let lineMessage =…
I'm writing unit tests for a Component in Jest and I'm currently just testing functionality.
The class function is as followed:
class Comp extends Component {
fetch = null;
update = async () => {
try {
if(this.fetch)
…
I am using typescript and used promises to maintain synchronous behavior in my code .As per my research though we have try catch bloc around promise we are getting un-handled exception when something goes wrong in our promise…
I am trying to add es2017 to my webpack. My program compiles but I get a syntax error message as in the previous picture. I believe I am missing something but I can not find what. I am trying to run the examples given…
Take this example function
async function foo () {
const res = await fetchData()
const out = await processData(res)
return out
}
Imagine that I notice fetchData is slow and I want to quickly profile with a generic timer function /…
What is the most up to date method to ensure that some asynchronous code completes in a class constructor before that class is subsequently used?
Specifically, how would an API client class retrieve an access token before allowing more method calls,…
Hello guys I'm using await keyword to wait for the async call to return. My url is a get url so if I call it from my browser a json is returned. The problem is when I try to get data from my code it returns me a promise but I can't figure out how to…
can I await an array length to change to a specified value in JS.
for example:
Suppose there is a magic function named foo here, and I can use foo like this:
async funtion bar () {
let arr = [];
// Wait for the arr.length to change to 10,…