Questions tagged [ecmascript-2017]

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.

Proposals finalized in 2017 include:

387 questions
0
votes
3 answers

Why Promise returns also Resolve on Reject

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…
Martin Kravec
  • 187
  • 2
  • 10
0
votes
1 answer

An analog of async.queue for Async/Await functions

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'); …
Moshe Shmukler
  • 1,270
  • 2
  • 21
  • 43
0
votes
1 answer

How to navigate using path.resolve?

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 …
Taylor Austin
  • 5,407
  • 15
  • 58
  • 103
0
votes
2 answers

ECMAScript: Lexical Grammar vs Syntactic Grammar

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…
Magnus
  • 6,791
  • 8
  • 53
  • 84
0
votes
1 answer

ECMAScript 2017: EscapeSequence in StringLiteral

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,…
Magnus
  • 6,791
  • 8
  • 53
  • 84
0
votes
1 answer

ECMAScript 2017: Where Did "13.2 Creating Function Objects" Go (from ES5)?

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…
Magnus
  • 6,791
  • 8
  • 53
  • 84
0
votes
2 answers

Promise and await Javascript

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 =…
Terry Djony
  • 1,975
  • 4
  • 23
  • 41
0
votes
1 answer

Jest test Fat Arrow in class missing this

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) …
CherryNerd
  • 1,258
  • 1
  • 16
  • 38
0
votes
0 answers

Best Practice : Error Handling in Promise in async method

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…
0
votes
2 answers

handle promise error first level inside try catch

function testPromise(id) { return new Promise(function(resolve, reject) { setTimeout(function() { if (typeof id === 'number') { resolve(id); } else { reject('error'); } …
Daniel.V
  • 2,322
  • 7
  • 28
  • 58
0
votes
0 answers

Error trying to incorporate es2017 in webpack

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…
Jose Cabrera Zuniga
  • 2,348
  • 3
  • 31
  • 56
0
votes
2 answers

Is it possible to share a const to scope outside a block or closure

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 /…
david_adler
  • 9,690
  • 6
  • 57
  • 97
0
votes
3 answers

Async ES2017 Constructor

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,…
JD Angerhofer
  • 148
  • 1
  • 13
0
votes
2 answers

not getting correct data from promise

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…
Gardezi
  • 2,692
  • 2
  • 32
  • 62
0
votes
3 answers

How to await an array length to change to a specified value?

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,…