src/delay.js
function create(delay) {
    let timeoutId;
    let _reject;
    const promise = new Promise((resolve, reject) => {
      _reject = reject;
      timeoutId = setTimeout(() => {
        resolve();
        pendingPromises.delete(promise);
      }, delay);
    });

    pendingPromises.set(promise, {
      timeoutId,
      reject: _reject,
    });
    log('debug', 'Created a delay:', delay);
    return promise;
  }
function create(delay) {
    let timeoutId;
    let _reject;
    const promise = new Promise((resolve, reject) => {
      _reject = reject;
      timeoutId = setTimeout(() => {
        resolve();
        pendingPromises.delete(promise);
      }, delay);
    });

    pendingPromises.set(promise, {
      timeoutId,
      reject: _reject,
    });
    log('debug', 'Created a delay:', delay);
    return promise;
  }
function create ( delay ) { let timeoutId ; let _reject ; const promise = new Promise ( ( resolve , reject ) => { _reject = reject ; timeoutId = setTimeout ( ( ) => { resolve ( ) ; pendingPromises . delete ( promise ) ; } , delay ) ; } ) ; pendingPromises . set ( promise , { timeoutId , reject : _reject , } ) ; log ( 'debug' , 'Created a delay:' , delay ) ; return promise ; }
Create a new delay
@param  {Number}   delay  The delay in ms
@return {Promise}
A promise to be resolved after that delay
or rejected if it is cancelled.
@example
await delay.create(1000);
console.log('1000 ms elapsed!');
Create a new delay