Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

a-mimir

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

a-mimir

async and sync sleep functions

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

a-mimir

Barebones sleep functions. As simple and boring as it gets

Usage

import { sleep } from "a-mimir";

// block the current thread (doesn't work in the browser main thread, but works in node and web workers)
sleep.sync(500); // block for 500ms

// schedule an action to run later, without blocking the main thread. works everywhere
const promise = sleep.async(500); // promise which resolves in 500ms

promise.then(() => {
  console.log("is printed second");
});

console.log("is printed first");

Notes

  • sleep.sync relies on the globals SharedArrayBuffer, Int32Array, and Atomics.wait.
  • sleep.async relies on the globals Promise and setTimeout.

License

MIT

Keywords

sleep

FAQs

Package last updated on 14 Apr 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