JSPM

timeout-idle-promise

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q32273F
  • License BSD-3-Clause

Detects when a promise is idle (does not create asynchronous events) for longer than permitted amount of time.

Package Exports

  • timeout-idle-promise

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (timeout-idle-promise) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

timeout-idle-promise

Travis build status Coveralls NPM version Canonical Code Style Twitter Follow

Detects when a promise is idle (does not create asynchronous events) for longer than permitted amount of time.

API

import {
  timeoutIdlePromise,
  TimeoutError,
} from 'timeout-idle-promise';

/**
 * @param {Function} promiseFactory
 * @param {number} maximumIdleTime Idle timeout in milliseconds.
 * @throws TimeoutError
 */
timeoutIdlePromise(promiseFactory);

Example Usage

// Rejected with Idle promise timeout.
timeoutIdlePromise(() => {
  return new Promise((resolve) => {

  });
}, 1000);

// Resolved.
timeoutIdlePromise(() => {
  return new Promise((resolve) => {
    setTimeout(() => {
      setTimeout(() => {
        setTimeout(() => {
          resolve();
        }, 500);
      }, 500);
    }, 500);
  });
}, 1000);