Need correct call to Promise reduce (when.reduce )
问题 I have a processor function that takes a "cmd" object and returns a promise where the resolution is the same "cmd" object passed in (with a response key added). reduce here is when.reduce reduce = require('when').reduce; //return processor(cmds[0]) return reduce(cmds, function(processor, cmd) { Debug.L1('running processor for component ', cmd.component) return processor(cmd) }) .then(cmds => { Debug.L1('cmds with responses\n', cmds) let response = cmds.map(cmd => { return cmd.response })