Skip to content

Commit

Permalink
docs: add quote and sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Feb 19, 2024
1 parent 0db1b41 commit f82b343
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/plugins/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ This function is only available in the async context.

Returns the target family of the current platform, `"windows"`, `"unix"`, or `"wasm"`.

### `quote(str)`

Quote characters that may have special meaning in a shell:

- `str`: Required, the string to be quoted, which is a string

```lua
local handle = io.popen("ls " .. ya.quote(filename))
```

### `truncate(text, max)`

Truncate the text to the specified length and return it:
Expand All @@ -147,6 +157,18 @@ Check whether the mime-type is valid:

Returns the current timestamp, which is a float, the integer part represents the seconds, and the decimal part represents the milliseconds.

### `sleep(secs)`

Waits until `secs` has elapsed:

- `secs`: Required, the number of seconds to sleep, which is a positive float

```lua
ya.sleep(0.5) -- Sleep for 500 milliseconds
```

This function is only available in the async context.

### `uid()`

Only available on Unix-like systems. Returns the user id of the current user, which is an integer.
Expand Down

0 comments on commit f82b343

Please sign in to comment.