Skip to content
Client
Server

Reference / @open-music-sdk/core / sleep

Function: sleep() ​

ts
function sleep(ms, signal?): Promise<void>;

Defined in: packages/core/src/retry.ts:126

Resolves after ms, or rejects with the abort reason. What it is handed is checked, since other packages call it too: a wait that is no number of milliseconds from 0, or has no end, is a TypeError, and so is a signal that is none. A wait longer than a timer keeps is kept as several, so that it is never over at once.

Parameters ​

ms ​

number

How long to wait, in milliseconds: a number from 0, and not infinity.

signal? ​

AbortSignal

Ends the wait early.

Returns ​

Promise<void>

Throws ​

TypeError if ms is not a number of milliseconds from 0, or is without end, or signal is given and is no AbortSignal.

Throws ​

The reason signal aborted with, when it does.

MIT licensed. Not affiliated with, endorsed by, or sponsored by Apple Inc. Apple Music and MusicKit are trademarks of Apple Inc.