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.
For years I ran into problems trying to remove an event listener in JavaScript. Often I would have to create an independent function as the handler. But that is just sloppy and, especially with the addition of arrow functions, just a pain.
I am not…
How to reuse some existing ES6 classes in Vue Js.
Have a class which has a variable being updated by observable.
class A {
public a: string;
someobservable.subscribe((a) =>{
this.a = a;
})
}
In vue.JS have created the object…
I'm having an issue with JavaScript's async/await functions. This is happening on an internal application that I can't share the source for, but I put together a quick generic reproduction of my issue:
function sleep(ms) {
return new…
I am wrapping a function returning a promises into an async function on a small helper function...
trash(filesArray, {
glob: false
})
.then(() => {
resolve(true);
}).catch((err) => {
return err;
})
…because I like to use it synchronous…
I can't figure out how to convert async await functionality in a while loop to a promise based implementation.
repl showing the async await version
https://repl.it/repls/IdealisticPepperyCoding
var dependency = false;
function checkDependency()…
I'm writing JavaScript (> ECMAScript 6) and I can't figure how to call a super class' async method in an extending class' method.
This is what I'm trying to do:
class SuperClass {
constructor(){}
async method() {
return;
…
I'm having some issues understanding how the Promise functionality works, I have previously used Bluebird but I wanted to try to learn the new await/async standard in order to improve as a programmer. I have used async/await and created promises…
As far as I know, async/await is just syntactic sugar over promise.then. Consider this code snippet:
function sleep(n){
return new Promise(res => setTimeout(res, n));
}
function* range(n){
var i = 0;
while(i < n) yield i++;
}
async…
For an object to implement iterable interface it must implement [Symbol.iterator] key that points to a function that returns the iterator. I'm wondering if the for..of loop internally calls this method on an object to get that iterator?
The reason…
I've implemented passport local strategy using async/await as below
const strategy = new LocalStrategy(
async(username, password, done) => {
try {
// Find the user given the username
const user = await User.findOne({ username });
…
I'm currently learning how to use ES8's fetch, async and await I currently have this code that works:
const url = "https://api.icndb.com/jokes/random";
async function tellJoke() {
let data = await (await fetch(url)).json();
return…
Currently, I have this code:
async function getConnection(){
// logic here...
}
To make it consistent with the rest of my codebase, I want to change it to an arrow function. I've tried async getConnection () => { ... } but that didn't seem to…
I've found that I can't call async functions with $.proxy. My case was that I proxied event listeners so that they'd still have the same context, but as soon as I tried proxying to an async function, it just didn't get called - also, no errors were…