Run a sequence once the previous sequence for that project id ends.

@param  {{projectId: string}}             client   Rest client
@param  {function(): Promise<void,Error>} sequence Sequence to run
@return {Promise<void,Error>}
function lock(client, sequence) {
  const lastSequence = sequences.get(client.projectId);

  return Promise.resolve(lastSequence).then(() => {
    const result = sequence();

    sequences.set(client.projectId, result.then(noop, noop));

    return result;
  });
}