Delays between promises in promise chain
<p>Let's say I am using the following code to run a couple of promises in series:</p>

<pre><code>let paramerterArr = ['a','b','c','d','e','f']
parameterArr.reduce(function(promise, item) {
  return promise.then(function(result) {
    return mySpecialFunction(item);
  })
}, Promise.resolve())
</code></pre>

<p>The code simply calls mySpecialFunction (which returns a promise), waits for the promise to be resolved and then calls mySpecialFunction again etc. So the function is called once for every element in the array, in the correct order.</p>

<p>How could I make sure that there is a delay of at least 50 milliseconds between every call of <code>mySpecialFunction(item)</code>?  </p>

<p>It is important that the promises are executed in the right order and the execution time of <code>mySpecialFunction</code> varies every time.  </p>

<p>I guess a synchronous sleep would work, but I'm not planning to run this code in a separate thread, so it would cause annoying ui freezes in the browser. </p>

<p>I'm not sure if setTimer could somehow be used for this. I mean I can't delay the returning of a promise. </p>