ES7 Getting result from an array of promises using await generator

As mentioned in the issue you filed, the core issue is that await* is no longer a thing and has been removed. Unfortunately, it was not properly throwing a syntax error in Babel 6 and was essentially being treated like a normal await. You’ll need to explicitly let [p1, p2] = await Promise.all([ System.import(‘./package1.js’), System.import(‘./package2.js’)]);

Can I fire and forget a promise in nodejs (ES7)?

Yes, you can do that, and it will run the two asynchronous functions in parallel. You’ve just created a promise and thrown it away. However, this means that when the promise is rejected you won’t notice. You’ll just get an unhandledRejection eventually which will crash your process if not handled. Is this OK? How can … Read more

javascript : Async/await in .replace

An easy function to use and understand for some async replace : async function replaceAsync(str, regex, asyncFn) { const promises = []; str.replace(regex, (match, …args) => { const promise = asyncFn(match, …args); promises.push(promise); }); const data = await Promise.all(promises); return str.replace(regex, () => data.shift()); } It does the replace function twice so watch out if … Read more

Can I catch an error from async without using await?

Dealing with unhandled rejected native promises (and async/await uses native promises) is a feature supported now in V8. It’s used in the latest Chrome to output debugging information when a rejected promise is unhandled; try the following at the Babel REPL: async function executor() { console.log(“execute”); } async function doStuff() { console.log(“do stuff”); throw new … Read more

VSCode Linter ES6 ES7 Babel linter

How I proceed: install globally eslint : npm install -g eslint install babel-eslint : npm install –save-dev babel-eslint install eslint-plugin-react : npm install –save-dev eslint-plugin-react create .eslintrc file in you root directory. here is my config: { “env”: { “browser”: true, “node”: true, “es6”: true, “jest”: true, “jquery”: true }, “parser”: “babel-eslint”, “parserOptions”: { “ecmaVersion”: … Read more

Difference between ECMAScript 2016 exponentiation operator and Math.pow()

None. As you can read in the ES7 spec, both Math.pow and the ** exponentation operator cast their arguments/operands to numbers and use the very same algorithm to determine the result. Addendum: this changed with the introduction of the BigInt type in ES2020, whose values are only supported by operators (including **) but not the … Read more