npm.io
2.0.2 • Published 4 years ago

nanodelay

Licence
MIT
Version
2.0.2
Deps
0
Size
3 kB
Vulns
0
Weekly
0
Stars
199

Nano Delay

A tiny Promise wrapper around setTimeout for JavaScript. Returns a Promise and resolve it after a specific amount of time.

  • Only 40 bytes (minified and gzipped), 10 times smaller than delay library.
  • Has good ES modules and TypeScript support.
import { delay } from 'nanodelay'

async function foo () {
  await delay(300)
  // Executed after 300 milliseconds
}

delay(300).then(() => {
  // Executed after 300 milliseconds
})
Sponsored by Evil Martians

Docs

Read full docs on GitHub.

Keywords