Update api reference pages

This commit is contained in:
Filip Tibell 2024-03-14 14:44:52 +01:00
parent d81c16ed20
commit d3b4017218
No known key found for this signature in database
3 changed files with 43 additions and 21 deletions

View file

@ -254,9 +254,12 @@ This is a dictionary that will contain the following values:
- `kind` - If the target path is a `file`, `dir` or `symlink` - `kind` - If the target path is a `file`, `dir` or `symlink`
- `exists` - If the target path exists - `exists` - If the target path exists
- `createdAt` - The timestamp at which the file or directory was created - `createdAt` - The timestamp represented as a `DateTime` object at which the file or directory
- `modifiedAt` - The timestamp at which the file or directory was last modified was created
- `accessedAt` - The timestamp at which the file or directory was last accessed - `modifiedAt` - The timestamp represented as a `DateTime` object at which the file or directory
was last modified
- `accessedAt` - The timestamp represented as a `DateTime` object at which the file or directory
was last accessed
- `permissions` - Current permissions for the file or directory - `permissions` - Current permissions for the file or directory
Note that timestamps are relative to the unix epoch, and may not be accurate if the system clock is Note that timestamps are relative to the unix epoch, and may not be accurate if the system clock is

View file

@ -16,6 +16,9 @@ local callableFn = luau.load(bytecode)
callableFn() callableFn()
``` ```
Since luau bytecode is highly compressible, it may also make sense to compress it using the `serde`
library while transmitting large amounts of it.
## Functions ## Functions
### compile ### compile
@ -29,18 +32,19 @@ An error will be thrown if the sourcecode given isn't valid Luau code.
```lua ```lua
local luau = require("@lune/luau") local luau = require("@lune/luau")
-- Compile the source to some highly optimized bytecode
local bytecode = luau.compile("print('Hello, World!')", { local bytecode = luau.compile("print('Hello, World!')", {
optimizationLevel: 1, optimizationLevel = 2,
coverageLevel: 0, coverageLevel = 0,
debugLevel: 1, debugLevel = 1,
}) })
``` ```
#### Parameters #### Parameters
- `source` The string that'll be compiled into bytecode - `source` The string that will be compiled into bytecode
- `compileOptions` The luau compiler options used when compiling the source string - `compileOptions` The options passed to the luau compiler that will output the bytecode
#### Returns #### Returns
@ -69,13 +73,13 @@ callableFn()
#### Parameters #### Parameters
- `source` Either bytecode or sourcecode - `source` Either luau bytecode or string source code
- `loadOptions` The load options used when creating a callbable function - `loadOptions` The options passed to luau for loading the chunk
#### Returns #### Returns
- luau function - luau chunk
--- ---
@ -83,27 +87,26 @@ callableFn()
### CompileOptions ### CompileOptions
The Luau compiler options used in generating luau bytecode The options passed to the luau compiler while compiling bytecode.
This is a dictionary that may contain one or more of the following values: This is a dictionary that may contain one or more of the following values:
- `optimizationLevel` - Sets the compiler option "optimizationLevel". Defaults to `1` - `optimizationLevel` - Sets the compiler option "optimizationLevel". Defaults to `1`.
- `coverageLevel` - Sets the compiler option "coverageLevel". Defaults to `0` - `coverageLevel` - Sets the compiler option "coverageLevel". Defaults to `0`.
- `debugLevel` - Sets the compiler option "debugLevel". Defaults to `1` - `debugLevel` - Sets the compiler option "debugLevel". Defaults to `1`.
Documentation regarding what these values represent can be found here; Documentation regarding what these values represent can be found
[here](https://github.com/Roblox/luau/blob/bd229816c0a82a8590395416c81c333087f541fd/Compiler/include/luacode.h#L13-L39).
- https://github.com/Roblox/luau/blob/bd229816c0a82a8590395416c81c333087f541fd/Compiler/include/luacode.h#L13
--- ---
### LoadOptions ### LoadOptions
The Luau load options are used for generating a lua function from either bytecode or sourcecode The options passed while loading a luau chunk from an arbitrary string, or bytecode.
This is a dictionary that may contain one or more of the following values: This is a dictionary that may contain one or more of the following values:
- `debugName` - The debug name of the closure. Defaults to `luau.load(...)` - `debugName` - The debug name of the closure. Defaults to `luau.load(...)`.
- `environment` - Environment values to set and/or override. Includes default globals unless - `environment` - Environment values to set and/or override. Includes default globals unless
overwritten. overwritten.

View file

@ -230,13 +230,29 @@ This is a dictionary that may contain one or more of the following values:
Configuration for `net.serve`. Configuration for `net.serve`.
This may contain one of, or both of the following callbacks: This may contain one of or more of the following values:
- `address` for setting the IP address to serve from. Defaults to the loopback interface
(`http://localhost`).
- `handleRequest` for handling normal http requests, equivalent to just passing a function to - `handleRequest` for handling normal http requests, equivalent to just passing a function to
`net.serve` `net.serve`
- `handleWebSocket` for handling web socket requests, which will receive a `WebSocket` object as - `handleWebSocket` for handling web socket requests, which will receive a `WebSocket` object as
its first and only parameter its first and only parameter
When setting `address`, the `handleRequest` callback must also be defined.
```lua
net.serve(8080, {
address = "http://0.0.0.0",
handleRequest = function(request)
return {
status = 200,
body = "Echo:\n" .. request.body,
}
end
})
```
--- ---
### ServeHandle ### ServeHandle