@zodash/timeout
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

@zodash/timeout

Timeout a promise-returning or async function

Usage

import { timeout } from '@zodash/timeout';
import * as fetch from 'node-fetch';

const run = async () => {
	const response = await fetch('https://sindresorhus.com/unicorn');

	// Abort retrying if the resource doesn't exist
	if (response.status === 404) {
		throw new Error(response.statusText);
	}

	return response.blob();
};

(async () => {
	console.log(await retry(run, {retries: 5}));
})();

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i @zodash/timeout

    Weekly Downloads

    4

    Version

    0.0.9

    License

    MIT

    Unpacked Size

    6.56 kB

    Total Files

    6

    Last publish

    Collaborators

    • uniquecolesmith