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.
I want to stop using the async library, replacing it with vanilla js.
const async = require('async')
function getTopicsData(tids, Uid, callback) {
async.map(tids, (tid, next) => {
redis.hgetall(`topic:${tid}`, (err, topics) => {
…
Background:
I have been using create-react-app to create React components and my latest project requires a server backend to return data.
I like to mock up the data returned by the API with imported functions from a 'API' file.
Recently, I have…
I have generator
function* pendingPage() {
let value = 1;
while (true)
yield getPage(value++);
}
I have getPage() function
async function getPage(value) {
const page = await service.getValidations(value);
…
I'm using babel to transpile ES7 js code, and everything works like a charm in dev/staging. Inside the application, I heavily rely on async/await features of ES7. My entry file looks like this:
'use…
I wonder if it's possible to wrap Geolocation.watchPosition() https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition in a Promise and use it with async/await idioms in a way it does it's work; constantly returns positions…
When reading about async and await, I noticed that it's almost an equivalent of generator functions. Consider this fragment from TypeScript Deep Dive:
Async Await
(...)
// Not actual code. A thought experiment
async function foo() {
try {
…
I want to use async/await in mocha in order to make my tests. I have read many post, but I didn't find the solution. I have already install all the babel modules in order to transpiling the code, but it doesn't work.
Here is my code inside the…
I'm trying to do this with async/await, but any solution is good. Anyone know how I could change this:
series[group].forEach(async (ele, j) => {
await $.ajax({
url: `templates/ele${ele}.template.html`,
success: function (data) {
…
Async/await are really handy, but I want the opposite of their behavior. Instead of other functions continuing on unless I manually ask them to await a promise, I want functions to yield unless I manually specify that they continue running in…
I'm having following code.
class DB {
constructor(client) {
this.client = client;
}
}
export default function store() {
return new Promise((resolve, reject) => {
pg.connect(process.env.DATABASE_URL, client => {
…
I want to make this example https://stackoverflow.com/a/33585993/1973680 synchronous.
Is this the correct implementation?
let times= async (n,f)=>{while(n-->0) await f();}
times(5,()=>
myfunc([1,2,3],err => err)
…
I am using async functions and default parameters with evaluation at call time.
With the default parameters I use a function to check if a value is provided or not.
function mandatory(paramName) {
throw new Error(`Missing parameter:…
When I place this code for a promise that the result is not needed to proceed:
await resultNotNeeded(bla, foo);
I'm getting this eslint error:
[eslint] Expected an assignment or function call and instead saw an
expression.…