code: function sequence(promises) {
    var result = Promise.resolve();
    promises.forEach(function(promise,i) {
      result = result.then(promise);
    });
    return result;
  }
docs: utility function to sequentialize promises