National Patience Month

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

    0.0.7 • 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}));
    })();
    

    Install

    npm i @zodash/timeout

    DownloadsWeekly Downloads

    41

    Version

    0.0.7

    License

    MIT

    Unpacked Size

    6.21 kB

    Total Files

    6

    Last publish

    Collaborators

    • uniquecolesmith