sleep
Pauses execution for a given number of milliseconds by returning a promise that resolves after the specified delay.
Import
Section titled “Import”import { sleep } from "1o1-utils";import { sleep } from "1o1-utils/sleep";Signature
Section titled “Signature”function sleep({ ms }: SleepParams): Promise<void>Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
| ms | number | Yes | Duration in milliseconds (non-negative) |
Returns
Section titled “Returns”Promise<void>
Examples
Section titled “Examples”await sleep({ ms: 1000 }); // waits 1 secondEdge Cases
Section titled “Edge Cases”- Throws if
msis not a number or isNaN. - Throws if
msis negative. sleep({ ms: 0 })resolves on the next tick.
Also known as
Section titled “Also known as”wait, delay, pause, setTimeout promise
Prompt suggestion
Section titled “Prompt suggestion”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