mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-22 22:22:26 +01:00
42 lines
772 B
Markdown
42 lines
772 B
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
|
|
[Home](./index.md) > [bitburner](./bitburner.md) > [NS](./bitburner.ns.md) > [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<true>
|
|
|
|
A promise that resolves to true when the sleep is completed.
|
|
|
|
## Remarks
|
|
|
|
RAM cost: 0 GB
|
|
|
|
## Example
|
|
|
|
|
|
```js
|
|
// This will count from 1 to 10 in your terminal, with one number every 5 seconds
|
|
for (let i = 1; i <= 10; ++i) {
|
|
ns.tprint(i);
|
|
await ns.sleep(5000);
|
|
}
|
|
```
|
|
|