New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@arndesk/awaitdelay

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arndesk/awaitdelay

A Node Js utility to add timeouts to promises

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

@arndesk/awaitdelay

A Node Js utility to add timeouts to promises

Get StartedInstallationUsageFeaturesContributingLicense

Get Started

Installation

Use npm to install this package:

npm install @arndesk/awaitdelay

Usage

Here's a basic example of how to use awaitdelay in your code:


// ES Modules import
import awaitdelay from '@arndesk/awaitdelay';
// CommonJS require
const awaitdelay = require('@arndesk/awaitdelay');

// Async function to use the awaitdelay function
async function main() {
  const slowPromise = new Promise(resolve => setTimeout(() => resolve('Resolved'), 5000));

  try {
    const result = await awaitdelay(slowPromise, { timeout: 5000 }); // 5 seconds timeout
    console.log(result);
  } catch (error) {
    console.error(error.message);
  }
}

main();

Features

  • Provides a straightforward way to add timeouts to promises
  • Easily adjustable timeout duration
  • Compatible with both ES Modules and CommonJS
  • Useful in a wide range of JavaScript and TypeScript projects

Keywords

promise

FAQs

Package last updated on 28 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts