Skip to content

sleep

Pauses execution for a given number of milliseconds by returning a promise that resolves after the specified delay.

import { sleep } from "1o1-utils";
import { sleep } from "1o1-utils/sleep";
function sleep({ ms }: SleepParams): Promise<void>
NameTypeRequiredDescription
msnumberYesDuration in milliseconds (non-negative)

Promise<void>

await sleep({ ms: 1000 }); // waits 1 second
  • Throws if ms is not a number or is NaN.
  • Throws if ms is negative.
  • sleep({ ms: 0 }) resolves on the next tick.

wait, delay, pause, setTimeout promise

I'm using 1o1-utils (npm: https://www.npmjs.com/package/1o1-utils, GitHub: https://github.com/pedrotroccoli/1o1-utils, LLM context: https://pedrotroccoli.github.io/1o1-utils/llms.txt). Show me how to use sleep to add a delay between sequential API calls