{"action":"opened","issue":{"url":"https://api.github.com/repos/kriskowal/q/issues/704","labels_url":"https://api.github.com/repos/kriskowal/q/issues/704/labels{/name}","comments_url":"https://api.github.com/repos/kriskowal/q/issues/704/comments","events_url":"https://api.github.com/repos/kriskowal/q/issues/704/events","html_url":"https://github.com/kriskowal/q/issues/704","id":89429663,"number":704,"title":"Calculating progress when using spread","user":{"login":"timpoultney","id":530813,"avatar_url":"https://avatars.githubusercontent.com/u/530813?v=3","gravatar_id":"","url":"https://api.github.com/users/timpoultney","html_url":"https://github.com/timpoultney","followers_url":"https://api.github.com/users/timpoultney/followers","following_url":"https://api.github.com/users/timpoultney/following{/other_user}","gists_url":"https://api.github.com/users/timpoultney/gists{/gist_id}","starred_url":"https://api.github.com/users/timpoultney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timpoultney/subscriptions","organizations_url":"https://api.github.com/users/timpoultney/orgs","repos_url":"https://api.github.com/users/timpoultney/repos","events_url":"https://api.github.com/users/timpoultney/events{/privacy}","received_events_url":"https://api.github.com/users/timpoultney/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-19T00:14:29Z","updated_at":"2015-06-19T00:14:29Z","closed_at":null,"body":"Hi, given an array of promises that all use notify(0-100), when using Q.spread the progress function calculation required to get a result in the range 0-100 is a bit tricky.\r\n\r\nIs there a better answer than this:\r\n`\r\nprogress = [[],[],[]];\r\nQ.spread(promises, function( ...\r\n  ...\r\n}).progress(update) {\r\n    progress[update.index].push(parseFloat(update.value));\r\n    total = 0;\r\n    progress.forEach(function(row) {\r\n        for(i=row.length-1;i>-1;i--) {\r\n            if(i>0) total += row[i]-row[i-1];\r\n            else total += row[i];\r\n        }\r\n    })\r\n    console.log(\"Progress: \"+Math.round((total/(100*promises.length)*100))+\"%\";\r\n})\r\n`\r\n\r\nAnd could the calculation become part of Q? Thanks."}}