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.
Are there any issues with using async/await in a forEach loop? I'm trying to loop through an array of files and await on the contents of each file.
import fs from 'fs-promise'
async function printFiles () {
const files = await getFilePaths() //…
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:
async function asyncGenerator() {
// other code
while (goOn) {
// other code
var fileList…
Given the following code:
var arr = [1,2,3,4,5];
var results: number[] = await arr.map(async (item): Promise => {
await callAsynchronousOperation(item);
return item + 1;
});
which produces the following error:
TS2322:…
I have been going over async/await and after going over several articles, I decided to test things myself. However, I can't seem to wrap my head around why this does not work:
async function main() {
var value = await Promise.resolve('Hey…
I'm digging into the node 7 async/await feature and keep stumbling across code like this
function getQuote() {
let quote = "Lorem ipsum dolor sit amet, consectetur adipiscing elit laborum.";
return quote;
}
async function main() {
try {
…
When using a simple callback such as in the example below:
test() {
api.on( 'someEvent', function( response ) {
return response;
});
}
How can the function be changed to use async / await? Specifically, assuming 'someEvent' is guaranteed…
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:
let…
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.
var fs = require('fs');
var crypto = require('crypto');
// the file you want to get the hash
var…
I'm working on an ng2 implementation. I'm using the following function call to convert an object to an array:
var authors = Object.entries(responseObject.Authors);
This is a standard js function. However, the ts compiler returns the following…
One can await a non-Promise and that's good so.
All these expressions are valid and cause no error:
await 5
await 'A'
await {}
await null
await undefined
Is there any detectable effect of awaiting a non-Promise? Is there any difference in behavior…
Is it or will it be possible to have an ES6 class getter
return a value from an ES2017 await / async function.
class Foo {
async get bar() {
var result = await someAsyncOperation();
return result;
}
}
function…