Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

awaitable-timers

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

awaitable-timers

Polyfill of Node.js awaitable timers

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Node.js awaitable timers

Extracts the Node.js awaitable timers (from require('timers/promises')) implementation from Node.js.

See: https://nodejs.org/dist/latest-v15.x/docs/api/timers.html#timers_timers_promises_api for details.

Should also work in most modern browsers. The implementation does make use of newer JavaScript features such as optional chaining, trailing commas, argument defaults and spread operators.

Pull requests welcome if someone wants to contribute tests or fixes

Examples

const {
  setTimeout,
  setImmediate,
  setInterval
} = require('awaitable-timers');

async function foo() {
  await setTimeout(1000);
  console.log('hello world after 1 second');
}

async function bar() {
  await setImmediate();
  console.log('hello world after 1 event loop tick');
}

async function baz() {
  for await (const _ of setInterval(1000)) {
    console.log('outputs once per second');
  }
}

Also available as ESM:

import {
  setTimeout,
  setImmediate,
  setInterval
} from 'awaitable-timers';

License

MIT License (see https://github.com/nodejs/node/blob/master/LICENSE)

FAQs

Package last updated on 17 Mar 2021

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc