Function waitForDelay

Returns a promise that resolves at least the given number of delay (in milliseconds) later. Uses setTimeout.