showing results for - "es6 reduce return promise"
Linus
23 Aug 2016
1const sum = await [
2  Promise.resolve(1),
3  Promise.resolve(1),
4  Promise.resolve(1)
5].reduce(async (previousPromise, itemPromise) => {
6  const sum = await previousPromise;
7  const item = await itemPromise;
8  return sum + item;
9}, Promise.resolve(0))
10
11// sum === 3
12
Sofia
25 Nov 2019
1async function slowCounter () {
2    const ret = await ([100, 200, 300, 400, 500]).reduce(
3        async (promise, wait, idx) => {
4            return promise.then(async last => {
5                const ret = last + wait
6                console.log(`${idx}: waiting ${wait}ms to return ${ret}`)
7                await new Promise((res, rej) => setTimeout(res, wait))
8                return ret
9            })
10        }, Promise.resolve(0))
11    console.log(ret)
12}
13
14slowCounter ()
queries leading to this page
using reduce inside promise alljavascript reduce promises sequenciallyreduce function with promise in node jspromise inside of array reducejs reduce return value 22reduce 22 22for 22 promisesdoes reduce returns a promisepromise reduce parallersequential promises reduce javascriptes6 reduce objectpromise reduce javascriptes6 reduce object return promisebest example for promise and reducesequentially reduce promises 2c passing result into next functionreduce and promises 22 24http 22object reduce with promisenode js reduce then resolvejavascript es5 sequantial promise javascript promise all reducereduce promise examplereduce array of promiseses6 do we need return inside reduce functuionreduce and promises reduce returns a promiseuse promise in javascript reduce 28 29js promise all reducereduce promisejavascript primise array reducwejavascrip reduce 28 29 multi promiseslodash generate sequence array elementusing reduce to run sequential promisespromise all and reduce usingnodejs promise reducereduce prmoisejs reduce promise alljavascript promises reduce thenjavascript promis all reducejavascript reduce promisepromises reducejavascript reduce promisespromise reducepromise list reducepromises reducearray reduce ajax asyncpromise all reducejavascript chain promises arrayinvoke promise inside reduce jsarray reduce promisecall reducer in promise thenacc in reduce return promise javascriptjs reduce promisesreduce and promises 24httpreduce in javascript es6javascript array of promises reducejavascript reduce array of promisesobject reduce with promise es 11typescript promise recudenode js array of promise sequentialpromise all on reduceorder promise all with arr reducejavascript using promises inside reducereduce then 28 29 then 28 29 then 28 29promise in reducer functionreduct actions new promisejavascript reduce return typees6 reduce return promisereduce javascript promise endnode reduce with promisesjs promiseall reducejs array reducenode js reduce promisearray of promises with reducereduce thenreduce promise allreduce from promisejs array reduce promiseangular promise reducehow to excute promises using reduce functionreduce promise arrayreduce promise allpromise all reducepromise all reduce sizees6 reduce return promise