bitburner-src/markdown/bitburner.ns.sleep.md

42 lines
772 B
Markdown
Raw Permalink Normal View History

<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md) &gt; [sleep](./bitburner.ns.sleep.md)
## NS.sleep() method
Suspends the script for n milliseconds.
**Signature:**
```typescript
sleep(millis: number): Promise<true>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| millis | number | Number of milliseconds to sleep. |
**Returns:**
Promise&lt;true&gt;
2023-04-28 20:19:30 +02:00
A promise that resolves to true when the sleep is completed.
## Remarks
RAM cost: 0 GB
2023-04-28 20:19:30 +02:00
## Example
2023-04-28 20:19:30 +02:00
```js
// This will count from 1 to 10 in your terminal, with one number every 5 seconds
for (let i = 1; i <= 10; ++i) {
2023-04-28 20:19:30 +02:00
ns.tprint(i);
await ns.sleep(5000);
}
```