44 if(icons.length === 0) return;
45
46 Promise.all(icons.map(icon => {
47 return new Promise((resolve) => { 48 resolve({ 49 "key": icon.nameHash, 50 "value": streamerIconStats[icon.nameHash] + 1 || 1 51 }); 52 }) 53 }))
54 .then(async data => {
55 const merged = {};
If the executor argument to a promise constructor only calls the reject
or resolve
and exits, then the code can refactored to use Promise#reject
or Promise#resolve
instead.
new Promise((resolve, reject) => {
resolve(getItem())
})
new Promise(function (resolve, reject) {
reject("oops")
})
Promise.resolve(getItem())
Promise.reject("oops")