Add documentation for bit32.count* and coroutine.close (#268)

This commit is contained in:
Arseny Kapoulkine 2021-12-02 11:36:40 -08:00 committed by GitHub
parent d2bf2870e8
commit 2aff9bb859
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -624,6 +624,12 @@ function coroutine.resume(co: thread, args: ...any): (boolean, ...any)
Resumes the coroutine and passes the arguments along to the suspension point. When the coroutine yields or finishes, returns `true` and all values returned at the suspension point. If an error is raised during coroutine resumption, this function returns `false` and the error object, similarly to `pcall`.
```
function coroutine.close(co: thread): (boolean, any?)
```
Closes the coroutine which puts coroutine in the dead state. The coroutine must be dead or suspended - in particular it can't be currently running. If the coroutine that's being closed was in an error state, returns `false` along with an error object; otherwise returns `true`. After closing, the coroutine can't be resumed and the coroutine stack becomes empty.
## bit32 library
All functions in the `bit32` library treat input numbers as 32-bit unsigned integers in `[0..4294967295]` range. The bit positions start at 0 where 0 corresponds to the least significant bit.
@ -700,6 +706,18 @@ function bit32.rshift(n: number, i: number): number
Shifts `n` to the right by `i` bits (if `i` is negative, a left shift is performed instead).
```
function bit32.countlz(n: number): number
```
Returns the number of consecutive zero bits in the 32-bit representation of `n` starting from the left-most (most significant) bit. Returns 32 if `n` is zero.
```
function bit32.countrz(n: number): number
```
Returns the number of consecutive zero bits in the 32-bit representation of `n` starting from the right-most (least significant) bit. Returns 32 if `n` is zero.
## utf8 library
Strings in Luau can contain arbitrary bytes; however, in many applications strings representing text contain UTF8 encoded data by convention, that can be inspected and manipulated using `utf8` library.