nanodelay

A tiny (25 bytes) Promise wrapper around setTimeout

Usage no npm install needed!

<script type="module">
  import nanodelay from 'https://cdn.skypack.dev/nanodelay';
</script>

README

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.