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

@actualwave/promised-timeout

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@actualwave/promised-timeout

Function that returns a Promise which will be resolved on timeout

latest
npmnpm
Version
0.0.7
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

@actualwave/promised-timeout

Set of functions that return promise which will be resolved after a specific timeout. It best suited to use with async/await.

import timeout from '@actualwave/promised-timeout';

async function test() {
	console.log('Before');
	
	await timeout(1000);
	
	console.log('After a second');
}

Installation

Via NPM

npm install @actualwave/promised-timeout --save

Or yarn

yarn add @actualwave/promised-timeout

API

Functions available

  • timeout() -- Present as default or named export, resolves after specified number of milliseconds
  • aTick -- Returns a promise which resolves on next tick
  • aQuarterSecond -- Returns a promise which resolves after a quarter of second
  • aHalfSecond -- Returns a promise which resolves after a half of second
  • aSecond -- Returns a promise which resolves after a second
  • aQuarterMinute -- Returns a promise which resolves after a quarter of minute
  • aHalfMinute -- Returns a promise which resolves after a half of minute
  • aMinute -- Returns a promise which resolves after a minute
  • aQuarterHour -- Returns a promise which resolves aftera quarter of hour
  • aHalfHour -- Returns a promise which resolves after a half of hour
  • anHour -- Returns a promise which resolves after an hour

These functions with predefined timeouts should cover majority of timeout() usages:

import { aSecond, aTick } from '@actualwave/promised-timeout';

async function test() {
	console.log('Before');
	
	await aSecond();
	
	console.log('After a second');
	
	await aTick();
	
	console.log('Next tick');
}

Constants available

  • QUARTER_SECOND -- 250, quarter of second in milliseconds
  • HALF_SECOND -- 500, half of second in milliseconds
  • SECOND -- 1000, second in milliseconds
  • QUARTER_MINUTE -- 15000, quarter of minute in milliseconds
  • HALF_MINUTE -- 30000, half of minute in milliseconds
  • MINUTE -- 60000, minute in milliseconds
  • QUARTER_HOUR -- 900000, quarter of hour in milliseconds
  • HALF_HOUR -- 1800000, half of hour in milliseconds
  • HOUR -- 3600000, an hour in milliseconds

Constants can be used with timeout() function.

import timeout, { SECOND } from '@actualwave/promised-timeout';

async function test() {
	console.log('Before');
	
	await timeout(SECOND);
	
	console.log('After a second');
}

Keywords

promise

FAQs

Package last updated on 12 Jan 2022

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