timelimit

Reject promises on timeout

Usage no npm install needed!

<script type="module">
  import timelimit from 'https://cdn.skypack.dev/timelimit';
</script>

README

timelimit

NPM version Downloads Dependency status Dev Dependency status

Reject promises on timeout.

Installation

npm install --save timelimit

Usage

Basic usage:

import timelimit from 'timelimit'

const req = timelimit(
  fetch('https://example.com'),
  10000, // 10 seconds
  {
    rejectOnTimeout: true, // default is true
    errorMessage: 'timeout', // timeout error message (thrown if rejectOnTimeout is true)
  },
)