Socket
Book a DemoInstallSign in
Socket

@jam3/wait

Package Overview
Dependencies
Maintainers
14
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jam3/wait

Wait a specific amount of time and return a promise, "setTimeout promisified"

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
14
Created
Source

wait

Minimalistic library that promisified setTimeout.

Installation

npm install @jam3/wait

Usage

Basic usage

const wait = require('@jam3/wait');

wait(1500).then(callback);

Async/Await example

const wait = require('@jam3/wait');

async function animate() {
  await wait(0); // Wait for JS to dequeue this call and do some rending in the meanwhile
  console.log('Waited at least 0 milliseconds');
}

Promises example

const wait = require('@jam3/wait');

async function runProcess() {
  ...
  await Promise.all([setTimer, other]);
  ...
}

async setTimer() {
  return await wait(1000);
}

Alternatives

If you want a more complete library, with a couple extra bytes, checkout delay

Keywords

timeout

FAQs

Package last updated on 04 Feb 2019

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.