In the promise library Q, you can do the following to sequentially chain promises:
var items = [\'one\', \'two\', \'three\']; var chain = Q(); items
Having this:
let items = ['one', 'two', 'three'];
One line (well, 3 for readability):
return items .map(item => foo.bind(null, item)) .reduce($q.when, $q.resolve());