Nvim :help pages, generated
from source
using the tree-sitter-vimdoc parser.
vim.uv.version()).uv module, but can
be used in other Lua environments.local uv = vim.uv
local server = uv.new_tcp()
server:bind("127.0.0.1", 1337)
server:listen(128, function (err)
assert(not err, err)
local client = uv.new_tcp()
server:accept(client)
client:read_start(function (err, chunk)
assert(not err, err)
if chunk then
client:write(chunk)
else
client:shutdown()
client:close()
end
end)
end)
print("TCP server listening at 127.0.0.1 port 1337")
uv.run() -- an explicit run call is necessary outside of luvituv for
simplicity. This module consists mostly of functions with names corresponding
to their original libuv versions. For example, the libuv function
uv_tcp_bind has a luv version at uv.tcp_bind(). Currently, only two
non-function fields exists: uv.constants and uv.errno, which are tables.uv.tcp_bind(server, host, port) can alternatively be
called as server:bind(host, port) . Note that the first argument server
becomes the object and tcp_ is removed from the function name. Method forms
are documented below where they exist.callable: a function; or a table or userdata with a __call
metamethod
buffer: a string or a sequential table of strings
threadargs: variable arguments (...) of type nil, boolean, number,
string, or userdata; number of arguments limited to 9.
-- signal start with string input
uv.signal_start("sigterm", function(signame)
print(signame) -- string output: "sigterm"
end)uv.constants where its keys are uppercase constant names and their associated
values are integers defined internally by libuv. The values from this table may
be supported as function arguments, but their use may not change the output
type. For example:
-- signal start with integer input
uv.signal_start(uv.constants.SIGTERM, function(signame)
print(signame) -- string output: "sigterm"
end)uv.constants that have associated
lowercase option strings are listed below.AF_UNIX: "unix"
AF_INET: "inet"
AF_INET6: "inet6"
AF_IPX: "ipx"
AF_NETLINK: "netlink"
AF_X25: "x25"
AF_AX25: "as25"
AF_ATMPVC: "atmpvc"
AF_APPLETALK: "appletalk"
AF_PACKET: "packet"
SIGHUP: "sighup"
SIGINT: "sigint"
SIGQUIT: "sigquit"
SIGILL: "sigill"
SIGTRAP: "sigtrap"
SIGABRT: "sigabrt"
SIGIOT: "sigiot"
SIGBUS: "sigbus"
SIGFPE: "sigfpe"
SIGKILL: "sigkill"
SIGUSR1: "sigusr1"
SIGSEGV: "sigsegv"
SIGUSR2: "sigusr2"
SIGPIPE: "sigpipe"
SIGALRM: "sigalrm"
SIGTERM: "sigterm"
SIGCHLD: "sigchld"
SIGSTKFLT: "sigstkflt"
SIGCONT: "sigcont"
SIGSTOP: "sigstop"
SIGTSTP: "sigtstp"
SIGBREAK: "sigbreak"
SIGTTIN: "sigttin"
SIGTTOU: "sigttou"
SIGURG: "sigurg"
SIGXCPU: "sigxcpu"
SIGXFSZ: "sigxfsz"
SIGVTALRM: "sigvtalrm"
SIGPROF: "sigprof"
SIGWINCH: "sigwinch"
SIGIO: "sigio"
SIGPOLL: "sigpoll"
SIGLOST: "siglost"
SIGPWR: "sigpwr"
SIGSYS: "sigsys"
SOCK_STREAM: "stream"
SOCK_DGRAM: "dgram"
SOCK_SEQPACKET: "seqpacket"
SOCK_RAW: "raw"
SOCK_RDM: "rdm"
TTY_MODE_NORMAL: "normal"
TTY_MODE_RAW: "raw"
TTY_MODE_IO: "io"
TTY_MODE_RAW_VT: "raw_vt"
FS_UTIME_NOW: "now"
FS_UTIME_OMIT: "omit"
uv.errno table, they are not returned by
luv functions and the libuv functions used to handle them are not exposed.
Instead, if an internal error is encountered, the failing luv function will
return to the caller an assertable nil, err, name tuple:nil idiomatically indicates failure
err is a string with the format {name}: {message}
{name} is the error name provided internally by uv_err_name
{message} is a human-readable message provided internally by
uv_strerror
name is the same string used to construct err
fail pseudo-type.0 to indicate
success, or sometimes nothing at all. These cases are documented below.E2BIG: argument list too long.
EACCES: permission denied.
EADDRINUSE: address already in use.
EADDRNOTAVAIL: address not available.
EAFNOSUPPORT: address family not supported.
EAGAIN: resource temporarily unavailable.
EAI_ADDRFAMILY: address family not supported.
EAI_AGAIN: temporary failure.
EAI_BADFLAGS: bad ai_flags value.
EAI_BADHINTS: invalid value for hints.
EAI_CANCELED: request canceled.
EAI_FAIL: permanent failure.
EAI_FAMILY: ai_family not supported.
EAI_MEMORY: out of memory.
EAI_NODATA: no address.
EAI_NONAME: unknown node or service.
EAI_OVERFLOW: argument buffer overflow.
EAI_PROTOCOL: resolved protocol is unknown.
EAI_SERVICE: service not available for socket type.
EAI_SOCKTYPE: socket type not supported.
EALREADY: connection already in progress.
EBADF: bad file descriptor.
EBUSY: resource busy or locked.
ECANCELED: operation canceled.
ECHARSET: invalid Unicode character.
ECONNABORTED: software caused connection abort.
ECONNREFUSED: connection refused.
ECONNRESET: connection reset by peer.
EDESTADDRREQ: destination address required.
EEXIST: file already exists.
EFAULT: bad address in system call argument.
EFBIG: file too large.
EHOSTUNREACH: host is unreachable.
EINTR: interrupted system call.
EINVAL: invalid argument.
EIO: i/o error.
EISCONN: socket is already connected.
EISDIR: illegal operation on a directory.
ELOOP: too many symbolic links encountered.
EMFILE: too many open files.
EMSGSIZE: message too long.
ENAMETOOLONG: name too long.
ENETDOWN: network is down.
ENETUNREACH: network is unreachable.
ENFILE: file table overflow.
ENOBUFS: no buffer space available.
ENODEV: no such device.
ENOENT: no such file or directory.
ENOMEM: not enough memory.
ENONET: machine is not on the network.
ENOPROTOOPT: protocol not available.
ENOSPC: no space left on device.
ENOSYS: function not implemented.
ENOTCONN: socket is not connected.
ENOTDIR: not a directory.
ENOTEMPTY: directory not empty.
ENOTSOCK: socket operation on non-socket.
ENOTSUP: operation not supported on socket.
EOVERFLOW: value too large for defined data type.
EPERM: operation not permitted.
EPIPE: broken pipe.
EPROTO: protocol error.
EPROTONOSUPPORT: protocol not supported.
EPROTOTYPE: protocol wrong type for socket.
ERANGE: result too large.
EROFS: read-only file system.
ESHUTDOWN: cannot send after transport endpoint shutdown.
ESPIPE: invalid seek.
ESRCH: no such process.
ETIMEDOUT: connection timed out.
ETXTBSY: text file is busy.
EXDEV: cross-device link not permitted.
UNKNOWN: unknown error.
EOF: end of file.
ENXIO: no such device or address.
EMLINK: too many links.
ENOTTY: inappropriate ioctl for device.
EFTYPE: inappropriate file type or format.
EILSEQ: illegal byte sequence.
ESOCKTNOSUPPORT: socket type not supported.
integerstringuv_loop_t — Event looploop_close(). Call this function only after the loop has
finished executing and all open handles and requests have been
closed, or it will return EBUSY.0 or failmode: string or nil (default: "default")
"default": Runs the event loop until there are no more
active and referenced handles or requests. Returns true
if uv.stop() was called and there are still active
handles or requests. Returns false in all other cases.
"once": Poll for I/O once. Note that this function
blocks if there are no pending callbacks. Returns false
when done (no active handles or requests left), or true
if more callbacks are expected (meaning you should run the
event loop again sometime in the future).
"nowait": Poll for I/O once but don't block if there are
no pending callbacks. Returns false if done (no active
handles or requests left), or true if more callbacks are
expected (meaning you should run the event loop again
sometime in the future).
boolean or failuv.run() after loading user
code, but if you use the luv bindings directly, you need to
call this after registering your initial set of event
callbacks to start the event loop.option: string
...: depends on option, see below
"block_signal": Block a signal when polling for new
events. The second argument to loop_configure() is the
signal name (as a lowercase string) or the signal number.
This operation is currently only implemented for
"sigprof" signals, to suppress unnecessary wakeups when
using a sampling profiler. Requesting other signals will
fail with EINVAL.
"metrics_idle_time": Accumulate the amount of idle time
the event loop spends in the event provider. This option
is necessary to use metrics_idle_time().
uv.loop_configure("block_signal", "sigprof")0 or failENOSYS error; it means the
loop option is not supported by the platform.nil is returned instead.string or niltrue if there are referenced active handles, active
requests, or closing handles in the loop; otherwise, false.boolean or failuv.run("nowait") to
poll in one thread and run the event loop's callbacks in
anotherinteger or nilintegerintegercallback: callable
callback will be executed with
each handle.-- Example usage of uv.walk to close all handles that
-- aren't already closing.
uv.walk(function (handle)
if not handle:is_closing() then
handle:close()
end
end)uv_req_t — Base requestuv_req_t is the base type for all libuv request types.req:cancel()uv_getaddrinfo_t, uv_getnameinfo_t and uv_work_t
requests is currently supported.0 or failreq:get_type()"fs" for uv_fs_t) and the libuv enum integer for the
request's type (uv_req_type).string, integeruv_handle_t — Base handleuv_handle_t is the base type for all libuv handle types. All API functions
defined here work with any handle type.handle:is_active()true if the handle is active, false if it's
inactive. What "active” means depends on the type of handle:boolean or failhandle:is_closing()true if the handle is closing or closed, false
otherwise.boolean or failhandle:close([callback])callback: callable or nil
callback will be called
asynchronously after this call. This MUST be called on each
handle before memory is released.callback will still be deferred to the next iteration of the
event loop. It gives you a chance to free up any resources
associated with the handle.uv_connect_t or uv_write_t, are
cancelled and have their callbacks called asynchronously with
ECANCELED.handle:ref()handle:unref()handle:has_ref()true if the handle referenced, false if not.boolean or failhandle:send_buffer_size([size])size: integer or nil (default: 0)
size is omitted (or 0), this will return the current
send buffer size; otherwise, this will use size to set the
new send buffer size.integer or fail (if size is nil or 0)
0 or fail (if size is not nil and not 0)
handle:recv_buffer_size([size])size: integer or nil (default: 0)
size is omitted (or 0), this will return the current
send buffer size; otherwise, this will use size to set the
new send buffer size.integer or fail (if size is nil or 0)
0 or fail (if size is not nil and not 0)
handle:fileno()EINVAL.EBADF.integer or failhandle:get_type()"pipe" for uv_pipe_t) and the libuv enum integer for the
handle's type (uv_handle_type).string, integeruv_timer_t — Timer handleuv_timer_t userdata or fail-- Creating a simple setTimeout wrapper
local function setTimeout(timeout, callback)
local timer = uv.new_timer()
timer:start(timeout, 0, function ()
timer:stop()
timer:close()
callback()
end)
return timer
end
-- Creating a simple setInterval wrapper
local function setInterval(interval, callback)
local timer = uv.new_timer()
timer:start(interval, interval, function ()
callback()
end)
return timer
end
-- And clearInterval
local function clearInterval(timer)
timer:stop()
timer:close()
endtimer:start(timeout, repeat, callback)timer: uv_timer_t userdata
timeout: integer
repeat: integer
callback: callable
timeout and repeat are in milliseconds.timeout is zero, the callback fires on the next event
loop iteration. If repeat is non-zero, the callback fires
first after timeout milliseconds and then repeatedly after
repeat milliseconds.0 or failtimer:stop()timer: uv_timer_t userdata
0 or failtimer:again()timer: uv_timer_t userdata
EINVAL.0 or failtimer:set_repeat(repeat)timer: uv_timer_t userdata
repeat: integer
timer:get_repeat()timer: uv_timer_t userdata
integertimer:get_due_in()timer: uv_timer_t userdata
integeruv_prepare_t — Prepare handlelocal prepare = uv.new_prepare()
prepare:start(function()
print("Before I/O polling")
end)uv_prepare_t userdataprepare:start(callback)prepare: uv_prepare_t userdata
callback: callable
0 or failprepare:stop()prepare: uv_prepare_t userdata
0 or failuv_check_t — Check handlelocal check = uv.new_check()
check:start(function()
print("After I/O polling")
end)uv_check_t userdatacheck:start(callback)check: uv_check_t userdata
callback: callable
0 or failcheck:stop()check: uv_check_t userdata
0 or failuv_idle_t — Idle handlelocal idle = uv.new_idle()
idle:start(function()
print("Before I/O polling, no blocking")
end)uv_idle_t userdataidle:start(callback)idle: uv_idle_t userdata
callback: callable
0 or failidle:stop()idle: uv_idle_t userdata
0 or failuv_async_t — Async handlelocal async
async = uv.new_async(function()
print("async operation ran")
async:close()
end)
async:send()callback: callable
...: threadargs passed to/from
uv.async_send(async, ...)
uv_async_t userdata or failasync:send(...)async: uv_async_t userdata
...: threadargs
0 or failuv.async_send(async),
that is, not every call to it will yield an execution of the
callback. For example: if uv.async_send() is called 5 times
in a row before the callback is called, the callback will only
be called once. If uv.async_send() is called again after the
callback was called, it will be called again.uv_poll_t — Poll handleuv_poll_t for any other purpose is not recommended;
uv_tcp_t, uv_udp_t, etc. provide an implementation that is faster and more
scalable than what can be achieved with uv_poll_t, especially on Windows.fd: integer
uv_poll_t userdata or failfd: integer
uv_poll_t userdata or failpoll:start(events, callback)poll: uv_poll_t userdata
events: string or nil (default: "rw")
callback: callable
err: nil or string
events: string or nil
events are: "r",
"w", "rw", "d", "rd", "wd", "rwd", "p", "rp",
"wp", "rwp", "dp", "rdp", "wdp", or "rwdp" where
r is READABLE, w is WRITABLE, d is DISCONNECT, and
p is PRIORITIZED. As soon as an event is detected the
callback will be called with status set to 0, and the detected
events set on the events field.0 or failuv.poll_start() on a handle that is already
active is fine. Doing so will update the events mask that is
being watched for.poll:stop()poll: uv_poll_t userdata
0 or failuv_signal_t — Signal handle-- Create a new signal handler
local signal = uv.new_signal()
-- Define a handler function
uv.signal_start(signal, "sigint", function(signame)
print("got " .. signame .. ", shutting down")
os.exit(1)
end)uv_signal_t userdata or failsignal:start(signame, callback)signal: uv_signal_t userdata
signame: string or integer
callback: callable
signame: string
signame input and output
values.0 or fail
uv.signal_start_oneshot(){signal}, {signame}, {callback})signal:start_oneshot(signame, callback)signal: uv_signal_t userdata
signame: string or integer
callback: callable
signame: string
signame input and output
values.0 or failsignal:stop()signal: uv_signal_t userdata
0 or failuv_process_t — Process handlepath: string
options: table (see below)
on_exit: callable
code: integer
signal: integer
local stdin = uv.new_pipe()
local stdout = uv.new_pipe()
local stderr = uv.new_pipe()
print("stdin", stdin)
print("stdout", stdout)
print("stderr", stderr)
local handle, pid = uv.spawn("cat", {
stdio = {stdin, stdout, stderr}
}, function(code, signal) -- on exit
print("exit code", code)
print("exit signal", signal)
end)
print("process opened", handle, pid)
uv.read_start(stdout, function(err, data)
assert(not err, err)
if data then
print("stdout chunk", stdout, data)
else
print("stdout end", stdout)
end
end)
uv.read_start(stderr, function(err, data)
assert(not err, err)
if data then
print("stderr chunk", stderr, data)
else
print("stderr end", stderr)
end
end)
uv.write(stdin, "Hello World")
uv.shutdown(stdin, function()
print("stdin shutdown", stdin)
uv.close(handle, function()
print("process closed", handle, pid)
end)
end)options.args - Command line arguments as a list of
strings. The first string should not be the path to the
program, since that is already provided via path. On
Windows, this uses CreateProcess which concatenates the
arguments into a string. This can cause some strange
errors (see options.verbatim below for Windows).
options.stdio - Set the file descriptors that will be
made available to the child process. The convention is
that the first entries are stdin, stdout, and stderr.
(Note: On Windows, file descriptors after the third are
available to the child process only if the child processes
uses the MSVCRT runtime.)
options.env - Set environment variables for the new
process.
options.cwd - Set the current working directory for the
sub-process.
options.uid - Set the child process' user id.
options.gid - Set the child process' group id.
options.verbatim - If true, do not wrap any arguments in
quotes, or perform any other escaping, when converting the
argument list into a command line string. This option is
only meaningful on Windows systems. On Unix it is silently
ignored.
options.detached - If true, spawn the child process in a
detached state - this will make it a process group leader,
and will effectively enable the child to keep running
after the parent exits. Note that the child process will
still keep the parent's event loop alive unless the parent
process calls uv.unref() on the child's process handle.
options.hide - If true, hide the subprocess console
window that would normally be created. This option is only
meaningful on Windows systems. On Unix it is silently
ignored.
options.stdio entries can take many shapes.nil placeholders means to ignore that fd in
the child process.
on_exit is called with an exit
code and signal.uv_process_t userdata, integerprocess:kill(signame)process: uv_process_t userdata
signame: string or integer or nil (default: sigterm)
signame input and output
values.0 or failpid: integer
signame: string or integer or nil (default: sigterm)
signame input and output
values.0 or failprocess:get_pid()process: uv_process_t userdata
integeruv_stream_t — Stream handleuv_stream_t is an abstract type, libuv provides 3 stream implementations
in the form of uv_tcp_t, uv_pipe_t and uv_tty_t.stream:shutdown([callback])callback: callable or nil
err: nil or string
uv_shutdown_t userdata or failstream:listen(backlog, callback)backlog: integer
callback: callable
err: nil or string
backlog indicates
the number of connections the kernel might queue, same as
listen(2). When a new incoming connection is received the
callback is called.0 or failstream:accept(client_stream)0 or failserver:listen(128, function (err)
local client = uv.new_tcp()
server:accept(client)
end)stream:read_start(callback)callback: callable
err: nil or string
data: string or nil
data
will be nil.0 or failstream:read_start(function (err, chunk)
if err then
-- handle read error
elseif chunk then
-- handle data
else
-- handle disconnect
end
end)stream:read_stop()0 or failstream:write(data, [callback])data: buffer
callback: callable or nil
err: nil or string
data can either be a Lua string or a table of strings. If a
table is passed in, the C backend will use writev to send all
strings in a single system call.callback is for knowing when the write is
complete.uv_write_t userdata or failstream:write2(data, send_handle, [callback])data: buffer
callback: callable or nil
err: nil or string
ipc option true.uv_write_t userdata or failsend_handle must be a TCP socket or pipe, which is a
server or a connection (listening or connected state). Bound
sockets or pipes will be assumed to be servers.stream:try_write(data)data: buffer
integer or failstream:try_write2(data, send_handle)data: buffer
UV_EAGAIN.integer or failstream:is_readable()true if the stream is readable, false otherwise.booleanstream:is_writable()true if the stream is writable, false otherwise.booleanstream:set_blocking(blocking)blocking: boolean
0 or failstream:get_write_queue_size()integeruv_tcp_t — TCP handleflags: string or integer or nil
flags must be a valid address family. See
luv-constants for supported address family input values.uv_tcp_t userdata or failtcp:open(sock)tcp: uv_tcp_t userdata
sock: integer
0 or failtcp:nodelay(enable)tcp: uv_tcp_t userdata
enable: boolean
0 or failtcp:keepalive(enable, [delay])tcp: uv_tcp_t userdata
enable: boolean
delay: integer or nil
delay is the initial delay
in seconds, ignored when enable is false.0 or failtcp:simultaneous_accepts(enable)tcp: uv_tcp_t userdata
enable: boolean
0 or failtcp:bind(host, port, [flags])tcp: uv_tcp_t userdata
host: string
port: integer
flags: table or nil
ipv6only: boolean
host should be an IP
address and not a domain name. Any flags are set with a
table with field ipv6only equal to true or false.EADDRINUSE error from either uv.tcp_bind(), uv.listen()
or uv.tcp_connect(). That is, a successful call to this
function does not guarantee that the call to uv.listen() or
uv.tcp_connect() will succeed as well.0 to let the OS assign an ephemeral port. You
can look it up later using uv.tcp_getsockname().0 or failtcp:getpeername()tcp: uv_tcp_t userdata
family output values.table or fail
ip : string
family : string
port : integer
tcp:getsockname()tcp: uv_tcp_t userdata
family output values.table or fail
ip : string
family : string
port : integer
tcp:connect(host, port, callback)tcp: uv_tcp_t userdata
host: string
port: integer
callback: callable
err: nil or string
uv_connect_t userdata or faillocal client = uv.new_tcp()
client:connect("127.0.0.1", 8080, function (err)
-- check error and carry on.
end)tcp:write_queue_size()tcp:close_reset([callback])tcp: uv_tcp_t userdata
callback: callable or nil
uv.tcp_close_reset() calls is not allowed.0 or fail
uv.socketpair(){socktype}, [{protocol}, [{flags1}, [{flags2}]]]])socktype: string, integer or nil (default: stream)
protocol: string, integer or nil (default: 0)
flags1: table or nil
nonblock: boolean (default: false)
flags2: table or nil
nonblock: boolean (default: false)
socktype input values.protocol is set to 0 or nil, it will be automatically
chosen based on the socket's domain and type. When protocol
is specified as a string, it will be looked up using the
getprotobyname(3) function (examples: "ip", "icmp",
"tcp", "udp", etc).nonblock: Opens the specified socket handle for
OVERLAPPED or FIONBIO/`O_NONBLOCK` I/O usage. This is
recommended for handles that will be used by libuv, and not
usually recommended otherwise.
socketpair(2) with a domain of AF_UNIX.table or fail
[1, 2] : integer (file descriptor)
-- Simple read/write with tcp
local fds = uv.socketpair(nil, nil, {nonblock=true}, {nonblock=true})
local sock1 = uv.new_tcp()
sock1:open(fds[1])
local sock2 = uv.new_tcp()
sock2:open(fds[2])
sock1:write("hello")
sock2:read_start(function(err, chunk)
assert(not err, err)
print(chunk)
end)uv_pipe_t — Pipe handlelocal pipe = uv.new_pipe(false)
pipe:bind('/tmp/sock.test')
pipe:listen(128, function()
local client = uv.new_pipe(false)
pipe:accept(client)
client:write("hello!\n")
client:close()
end)ipc: boolean or nil (default: false)
ipc argument is a boolean to
indicate if this pipe will be used for handle passing between
processes.uv_pipe_t userdata or failpipe:open(fd)pipe: uv_pipe_t userdata
fd: integer
0 or failpipe:bind(name)pipe: uv_pipe_t userdata
name: string
0 or failpipe:connect(name, [callback])pipe: uv_pipe_t userdata
name: string
callback: callable or nil
err: nil or string
uv_connect_t userdata or failpipe:getsockname()pipe: uv_pipe_t userdata
string or failpipe:getpeername()pipe: uv_pipe_t userdata
string or failpipe:pending_instances(count)pipe: uv_pipe_t userdata
count: integer
pipe:pending_count()pipe: uv_pipe_t userdata
integerpipe:pending_type()pipe: uv_pipe_t userdata
uv.pipe_pending_type() and call uv.accept(pipe, handle) .stringpipe:chmod(flags)pipe: uv_pipe_t userdata
flags: string
flags are: "r", "w", "rw", or
"wr" where r is READABLE and w is WRITABLE. This
function is blocking.0 or failread_flags: table or nil
nonblock: boolean (default: false)
write_flags: table or nil
nonblock: boolean (default: false)
write fd and read from the read fd. The resulting
handles can be passed to pipe_open, used with spawn, or
for any other purpose.nonblock: Opens the specified socket handle for
OVERLAPPED or FIONBIO/`O_NONBLOCK` I/O usage. This is
recommended for handles that will be used by libuv, and not
usually recommended otherwise.
pipe(2) with the O_CLOEXEC flag set.table or fail
read : integer (file descriptor)
write : integer (file descriptor)
-- Simple read/write with pipe_open
local fds = uv.pipe({nonblock=true}, {nonblock=true})
local read_pipe = uv.new_pipe()
read_pipe:open(fds.read)
local write_pipe = uv.new_pipe()
write_pipe:open(fds.write)
write_pipe:write("hello")
read_pipe:read_start(function(err, chunk)
assert(not err, err)
print(chunk)
end)pipe:pipe_bind(name, flags)pipe: uv_pipe_t userdata
name: string
flags: integer or table or nil (default: 0)
type(flags) is number, it must be 0 or
uv.constants.PIPE_NO_TRUNCATE.
type(flags) is table, it must be {} or
{ no_truncate = true|false }.
type(flags) is nil, it use default value 0.
EINVAL for unsupported flags without performing the
bind.
0 or failpipe:connect2(name, [flags], [callback])pipe: uv_pipe_t userdata
name: string
flags: integer or table or nil (default: 0)
callback: callable or nil
err: nil or string
Flags:type(flags) is number, it must be 0 or
uv.constants.PIPE_NO_TRUNCATE.
type(flags) is table, it must be {} or
{ no_truncate = true|false }.
type(flags) is nil, it use default value 0.
EINVAL for unsupported flags without performing the
bind operation.
uv_connect_t userdata or failuv_tty_t — TTY handle-- Simple echo program
local stdin = uv.new_tty(0, true)
local stdout = uv.new_tty(1, false)
stdin:read_start(function (err, data)
assert(not err, err)
if data then
stdout:write(data)
else
stdin:close()
stdout:close()
end
end)fd: integer
readable: boolean
uv_tty_t userdata or failtty:set_mode(mode)tty: uv_tty_t userdata
mode: string or integer
0 or failEBUSY if you call it when execution is
inside uv.tty_set_mode().0 or failtty:get_winsize()tty: uv_tty_t userdata
integer, integer or failstate: string
"supported" or
"unsupported"."supported" or "unsupported".ENOTSUP.string or failuv_udp_t — UDP handleflags: table or nil
family: string or nil
mmsgs: integer or nil (default: 1)
family input values.mmsgs determines the number of messages able
to be received at one time via recvmmsg(2) (the allocated
buffer will be sized to be able to fit the specified number of
max size dgrams). Only has an effect on platforms that support
recvmmsg(2).flags can also be
a string or integer. When it is a string, it will be treated
like the family key above. When it is an integer, it will be
used directly as the flags parameter when calling
uv_udp_init_ex.uv_udp_t userdata or failudp:get_send_queue_size()integerudp:get_send_queue_count()integerudp:open(fd)udp: uv_udp_t userdata
fd: integer
0 or failudp:bind(host, port, [flags])udp: uv_udp_t userdata
host: string
port: number
flags: table or nil
ipv6only: boolean
reuseaddr: boolean
flags are
set with a table with fields reuseaddr or ipv6only equal
to true or false.0 or failudp:getsockname()udp: uv_udp_t userdata
table or fail
ip : string
family : string
port : integer
udp:getpeername()udp: uv_udp_t userdata
table or fail
ip : string
family : string
port : integer
{udp}, {multicast_addr}, {interface_addr}, {membership})udp:set_membership(multicast_addr, interface_addr, membership)udp: uv_udp_t userdata
multicast_addr: string
interface_addr: string or nil
membership: string
multicast_addr is
multicast address to set membership for. interface_addr is
interface address. membership can be the string "leave" or
"join".0 or fail{udp}, {multicast_addr}, {interface_addr}, {source_addr}, {membership})udp:set_source_membership(multicast_addr, interface_addr, source_addr, membership)udp: uv_udp_t userdata
multicast_addr: string
interface_addr: string or nil
source_addr: string
membership: string
multicast_addr is multicast address to set membership for.
interface_addr is interface address. source_addr is source
address. membership can be the string "leave" or "join".0 or failudp:set_multicast_loop(on)udp: uv_udp_t userdata
on: boolean
0 or failudp:set_multicast_ttl(ttl)udp: uv_udp_t userdata
ttl: integer
ttl is an integer 1 through 255.0 or failudp:set_multicast_interface(interface_addr)udp: uv_udp_t userdata
interface_addr: string
0 or failudp:set_broadcast(on)udp: uv_udp_t userdata
on: boolean
0 or failudp:set_ttl(ttl)udp: uv_udp_t userdata
ttl: integer
ttl is an integer 1 through 255.0 or failudp:send(data, host, port, callback)udp: uv_udp_t userdata
data: buffer
host: string
port: integer
callback: callable
err: nil or string
0.0.0.0 (the "all interfaces" IPv4 address) and a random
port number.uv_udp_send_t userdata or failudp:try_send(data, host, port)udp: uv_udp_t userdata
data: buffer
host: string
port: integer
integer or failudp:try_send2(messages, flags)udp: uv_udp_t userdata
messages: table
[1, 2, 3, ..., n] : table
data : buffer
addr : table
ip : string
port : integer
flags: nil (see below)
port: integer
uv.udp_try_send(), but can send multiple datagrams.
Lightweight abstraction around sendmmsg(2), with a
sendmsg(2) fallback loop for platforms that do not support
the former. The udp handle must be fully initialized, either
from a uv.udp_bind call, another call that will bind
automatically (udp_send, udp_try_send, etc), or from
uv.udp_connect. messages should be an array-like table,
where addr must be specified if the udp has not been
connected via udp_connect. Otherwise, addr must be nil.flags is reserved for future extension and must currently be
nil or 0 or {}.integer or fail
-- If client:connect(...) was not called
local addr = { ip = "127.0.0.1", port = 1234 }
client:try_send2({
{ data = "Message 1", addr = addr },
{ data = "Message 2", addr = addr },
})
-- If client:connect(...) was called
client:try_send2({
{ data = "Message 1" },
{ data = "Message 2" },
})udp:recv_start(callback)udp: uv_udp_t userdata
callback: callable
err: nil or string
data: string or nil
addr: table or nil
ip: string
port: integer
family: string
flags: table
partial: boolean or nil
mmsg_chunk: boolean or nil
0.0.0.0 (the
"all interfaces" IPv4 address) and a random port number.family output values.0 or failudp:recv_stop()udp: uv_udp_t userdata
0 or failudp:connect(host, port)udp: uv_udp_t userdata
host: string
port: integer
uv.udp_connect() on
an already connected handle will result in an EISCONN error.
Trying to disconnect a handle that is not connected will
return an ENOTCONN error.0 or failuv_fs_event_t — FS Event handleuv_fs_event_t userdata or failfs_event:start(path, flags, callback)fs_event: uv_fs_event_t userdata
path: string
flags: table
watch_entry: boolean or nil (default: false)
stat: boolean or nil (default: false)
recursive: boolean or nil (default: false)
callback: callable
err: nil or string
filename: string
events: table
change: boolean or nil
rename: boolean or nil
0 or failfs_event:stop()0 or failfs_event:getpath()string or failuv_fs_poll_t — FS Poll handlestat to detect when a file has changed
so they can work on file systems where fs event handles can't.uv_fs_poll_t userdata or failfs_poll:start(path, interval, callback)fs_poll: uv_fs_poll_t userdata
path: string
interval: integer
callback: callable
err: nil or string
prev: table or nil (see uv.fs_stat)
curr: table or nil (see uv.fs_stat)
path for changes every interval
milliseconds.0 or failfs_poll:stop()0 or failfs_poll:getpath()string or failuv_fs_t userdata and asynchronously execute its callback; if an error is
encountered, the first and only argument passed to the callback will be the
err error string; if the operation completes successfully, the first
argument will be nil and the remaining arguments will be the results of the
FS call.readFile (with naive error
handling) are implemented below as an example:local function readFileSync(path)
local fd = assert(uv.fs_open(path, "r", 438))
local stat = assert(uv.fs_fstat(fd))
local data = assert(uv.fs_read(fd, stat.size, 0))
assert(uv.fs_close(fd))
return data
end
local data = readFileSync("main.lua")
print("synchronous read", data)local function readFile(path, callback)
uv.fs_open(path, "r", 438, function(err, fd)
assert(not err, err)
uv.fs_fstat(fd, function(err, stat)
assert(not err, err)
uv.fs_read(fd, stat.size, 0, function(err, data)
assert(not err, err)
uv.fs_close(fd, function(err)
assert(not err, err)
return callback(data)
end)
end)
end)
end)
end
readFile("main.lua", function(data)
print("asynchronous read", data)
end)fd: integer
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
close(2).boolean or failuv_fs_t userdatapath: string
flags: string or integer
mode: integer (octal chmod(1) mode, e.g.
tonumber('644', 8))
callback: callable (async version) or nil (sync
version)
err: nil or string
fd: integer or nil
open(2). Access flags may be an integer or
one of: "r", "rs", "sr", "r+", "rs+", "sr+",
"w", "wx", "xw", "w+", "wx+", "xw+", "a",
"ax", "xa", "a+", "ax+", or "`xa+`".integer or failuv_fs_t userdataCreateFileW and thus the file
is always opened in binary mode. Because of this, the
O_BINARY and O_TEXT flags are not supported.fd: integer
size: integer
offset: integer or nil
callback: callable (async version) or nil (sync
version)
err: nil or string
data: string or nil
preadv(2). Returns any data. An empty string
indicates EOF.offset is nil or omitted, it will default to -1, which
indicates "use and update the current file offset."offset is >= 0, the current file offset will not
be updated by the read.string or failuv_fs_t userdatapath: string
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
unlink(2).boolean or failuv_fs_t userdatafd: integer
data: buffer
offset: integer or nil
callback: callable (async version) or nil (sync
version)
err: nil or string
bytes: integer or nil
pwritev(2). Returns the number of bytes
written.offset is nil or omitted, it will default to -1, which
indicates "use and update the current file offset."offset is >= 0, the current file offset will not
be updated by the write.integer or failuv_fs_t userdatapath: string
mode: integer (octal representation of chmod(1) mode,
e.g. tonumber('755', 8))
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
mkdir(2).boolean or failuv_fs_t userdatatemplate: string
callback: callable (async version) or nil (sync
version)
err: nil or string
path: string or nil
mkdtemp(3).string or failuv_fs_t userdatatemplate: string
callback: callable (async version) or nil (sync
version)
err: nil or string
fd: integer or nil
path: string or nil
mkstemp(3). Returns a temporary file handle
and filename.integer, string or failuv_fs_t userdatapath: string
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
rmdir(2).boolean or failuv_fs_t userdatapath: string
callback: callable
err: nil or string
success: uv_fs_t userdata or nil
scandir(3), with a slightly different API.
Returns a handle that the user can pass to
uv.fs_scandir_next().uv_fs_t userdata or failfs: uv_fs_t userdata
name, type pair. When there
are no more entries, nil is returned.string, string or nil or failpath: string
callback: callable (async version) or nil (sync
version)
err: nil or string
stat: table or nil (see below)
stat(2).table or fail
dev : integer
mode : integer
nlink : integer
uid : integer
gid : integer
rdev : integer
ino : integer
size : integer
blksize : integer
blocks : integer
flags : integer
gen : integer
atime : table
sec : integer
nsec : integer
mtime : table
sec : integer
nsec : integer
ctime : table
sec : integer
nsec : integer
birthtime : table
sec : integer
nsec : integer
type : string
uv_fs_t userdatafd: integer
callback: callable (async version) or nil (sync
version)
err: nil or string
stat: table or nil (see uv.fs_stat)
fstat(2).table or fail (see uv.fs_stat)uv_fs_t userdatapath: string
callback: callable (async version) or nil (sync
version)
err: nil or string
stat: table or nil (see uv.fs_stat)
lstat(2).uv_fs_t userdatapath: string
new_path: string
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
rename(2).boolean or failuv_fs_t userdatafd: integer
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
fsync(2).boolean or failuv_fs_t userdatafd: integer
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
fdatasync(2).boolean or failuv_fs_t userdatafd: integer
offset: integer
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
ftruncate(2).boolean or failuv_fs_t userdataout_fd: integer
in_fd: integer
in_offset: integer
size: integer
callback: callable (async version) or nil (sync
version)
err: nil or string
bytes: integer or nil
sendfile(2). Returns the number of
bytes written.integer or failuv_fs_t userdatapath: string
mode: integer string (a combination of the 'r',
'w' and 'x' characters denoting the symbolic mode as per
chmod(1))
callback: callable (async version) or nil (sync
version)
err: nil or string
permission: boolean or nil
access(2) on Unix. Windows uses
GetFileAttributesW(). Access mode can be an integer or a
string containing "R" or "W" or "X". Returns true or
false indicating access permission.boolean or failuv_fs_t userdatapath: string
mode: integer (octal representation of chmod(1) mode,
e.g. tonumber('644', 8))
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
chmod(2).boolean or failuv_fs_t userdatafd: integer
mode: integer
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
fchmod(2).boolean or failuv_fs_t userdatapath: string
atime: number or string or nil
mtime: number or string or nil
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
utime(2)."now" or uv.constants.FS_UTIME_NOW as the atime or
mtime sets the timestamp to the current time.nil, "omit", or uv.constants.FS_UTIME_OMIT as
the atime or mtime leaves the timestamp untouched.boolean or failuv_fs_t userdatafd: integer
atime: number or string or nil
mtime: number or string or nil
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
futimes(3)."now" or uv.constants.FS_UTIME_NOW as the atime or
mtime sets the timestamp to the current time.nil, "omit", or uv.constants.FS_UTIME_OMIT as
the atime or mtime leaves the timestamp untouched.boolean or failuv_fs_t userdatapath: string
atime: number or string or nil
mtime: number or string or nil
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
lutimes(3)."now" or uv.constants.FS_UTIME_NOW as the atime or
mtime sets the timestamp to the current time.nil, "omit", or uv.constants.FS_UTIME_OMIT as
the atime or mtime leaves the timestamp untouched.boolean or failuv_fs_t userdatapath: string
new_path: string
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
link(2).boolean or failuv_fs_t userdatapath: string
new_path: string
flags: table, integer, or nil
dir: boolean
junction: boolean
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
symlink(2). If the flags parameter is
omitted, then the 3rd parameter will be treated as the
callback.boolean or failuv_fs_t userdatapath: string
callback: callable (async version) or nil (sync
version)
err: nil or string
path: string or nil
readlink(2).string or failuv_fs_t userdatapath: string
callback: callable (async version) or nil (sync
version)
err: nil or string
path: string or nil
realpath(3).string or failuv_fs_t userdatapath: string
uid: integer
gid: integer
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
chown(2).boolean or failuv_fs_t userdatafd: integer
uid: integer
gid: integer
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
fchown(2).boolean or failuv_fs_t userdatafd: integer
uid: integer
gid: integer
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
lchown(2).boolean or failuv_fs_t userdatapath: string
new_path: string
flags: table, integer, or nil
excl: boolean
ficlone: boolean
ficlone_force: boolean
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
flags parameter
is omitted, then the 3rd parameter will be treated as the
callback.boolean or failuv_fs_t userdatapath: string
callback: callable (async version) or nil (sync
version)
err: nil or string
dir: luv_dir_t userdata or nil
entries: integer or nil
entries parameter
defines the maximum number of entries that should be returned
by each call to uv.fs_readdir().luv_dir_t userdata or failuv_fs_t userdatadir:readdir([callback])dir: luv_dir_t userdata
callback: callable (async version) or nil (sync
version)
err: nil or string
entries: table or nil (see below)
luv_dir_t returned by a
successful uv.fs_opendir() call. A table of data tables is
returned where the number of entries n is equal to or less
than the entries parameter used in the associated
uv.fs_opendir() call.table or fail
[1, 2, 3, ..., n] : table
name : string
type : string
uv_fs_t userdatadir:closedir([callback])dir: luv_dir_t userdata
callback: callable (async version) or nil (sync
version)
err: nil or string
success: boolean or nil
boolean or failuv_fs_t userdatapath: string
callback: callable (async version) or nil (sync
version)
err: nil or string
table or nil (see below)
statfs(2).table or nil
type : integer
bsize : integer
blocks : integer
bfree : integer
bavail : integer
files : integer
ffree : integer
getaddrinfo and getnameinfo requests.local function work_callback(a, b)
return a + b
end
local function after_work_callback(c)
print("The result is: " .. c)
end
local work = uv.new_work(work_callback, after_work_callback)
work:queue(1, 2)
-- output: "The result is: 3"work_callback: function or string
...: threadargs passed to/from
uv.queue_work(work_ctx, ...)
after_work_callback: function
...: threadargs returned from work_callback
luv_work_ctx_t (not
uv_work_t).
work_callback is a Lua function or a string containing Lua
code or bytecode dumped from a function. Returns the Lua
userdata wrapping it.luv_work_ctx_t userdatawork_ctx:queue(...)work_ctx: luv_work_ctx_t userdata
...: threadargs
work_callback in a new
Lua state in a thread from the threadpool with any additional
arguments from .... Values returned from work_callback are
passed to after_work_callback, which is called in the main
loop thread.boolean or failhost: string or nil
service: string or nil
hints: table or nil
family: string or integer or nil
socktype: string or integer or nil
protocol: string or integer or nil
addrconfig: boolean or nil
v4mapped: boolean or nil
all: boolean or nil
numerichost: boolean or nil
passive: boolean or nil
numericserv: boolean or nil
canonname: boolean or nil
callback: callable (async version) or nil (sync
version)
err: nil or string
addresses: table or nil (see below)
getaddrinfo(3). Either node or service may
be nil but not both.family input and
output values.socktype input and
output values.protocol is set to 0 or nil, it will be
automatically chosen based on the socket's domain and type.
When protocol is specified as a string, it will be looked up
using the getprotobyname(3) function. Examples: "ip",
"icmp", "tcp", "udp", etc.table or fail
[1, 2, 3, ..., n] : table
addr : string
family : string
port : integer or nil
socktype : string
protocol : string
canonname : string or nil
uv_getaddrinfo_t userdata or failaddress: table
ip: string or nil
port: integer or nil
family: string or integer or nil
callback: callable (async version) or nil (sync
version)
err: nil or string
host: string or nil
service: string or nil
getnameinfo(3).family input values.string, string or failuv_getnameinfo_t userdata or failoptions: table or nil
stack_size: integer or nil
entry: function or string
...: threadargs passed to entry
luv_thread_t (not uv_thread_t).
Returns the Lua userdata wrapping it and asynchronously
executes entry, which can be either a Lua function or a
string containing Lua code or bytecode dumped from a function.
Additional arguments ... are passed to the entry function
and an optional options table may be provided. Currently
accepted option fields are stack_size.luv_thread_t userdata or failthread:equal(other_thread)thread: luv_thread_t userdata
other_thread: luv_thread_t userdata
__eq metamethod.boolean
uv.thread_setaffinity(){thread}, {affinity} [, {get_old_affinity}])thread:setaffinity(affinity, [get_old_affinity])thread: luv_thread_t userdata
affinity: table
[1, 2, 3, ..., n] : boolean
get_old_affinity: boolean
affinity must be a table where each of the keys are a CPU
number and the values are booleans that represent whether the
thread should be eligible to run on that CPU. If the length
of the affinity table is not greater than or equal to
uv.cpumask_size(), any CPU numbers missing from the table
will have their affinity set to false. If setting the
affinity of more than uv.cpumask_size() CPUs is desired,
affinity must be an array-like table with no gaps, since
#affinity will be used as the cpumask_size if it is
greater than uv.cpumask_size().get_old_affinity is true, the previous affinity
settings for the thread will be returned. Otherwise, true
is returned after a successful call.table or boolean or fail
[1, 2, 3, ..., n] : boolean
thread:getaffinity([mask_size])thread: luv_thread_t userdata
mask_size: integer
mask_size is provided, it must be greater than or equal
to uv.cpumask_size(). If the mask_size parameter is
omitted, then the return of uv.cpumask_size() will be used.
Returns an array-like table where each of the keys correspond
to a CPU number and the values are booleans that represent
whether the thread is eligible to run on that CPU.table or fail
[1, 2, 3, ..., n] : boolean
uv.thread_getaffinity and uv.thread_setaffinity.integer or failthread:setpriority(priority)thread: luv_thread_t userdata
priority: number
uv.constants.THREAD_PRIORITY_HIGHEST
uv.constants.THREAD_PRIORITY_ABOVE_NORMAL
uv.constants.THREAD_PRIORITY_NORMAL
uv.constants.THREAD_PRIORITY_BELOW_NORMAL
uv.constants.THREAD_PRIORITY_LOWEST
boolean or failthread:getpriority()thread: luv_thread_t userdata
number or failluv_thread_tthread:join()thread: luv_thread_t userdata
thread to finish executing its entry function.boolean or failthread:detach()thread: luv_thread_t userdata
uv.thread_join.boolean or failname: string
name is larger than the limit of the platform.0 or failthread:getname()thread: luv_thread_t userdata
thread.string or failmsec: integer
value: integer or nil
luv_sem_t userdata or failuv.sem_wait() on a single thread that blocks will deadlock.sem:post()sem: luv_sem_t userdata
sem:wait()sem: luv_sem_t userdata
sem:trywait()sem: luv_sem_t userdata
uv.sem_wait() but returns immediately if the
semaphore is not available.true is
returned, otherwise the semaphore has a value of zero and
false is returned.booleanstring or failstring or failcwd: string
cwd.0 or failstring or failtitle: string
title.0 or failnumbernumbernumberuv.get_free_memory()
in that it takes into account any limits imposed by the OS. If
there is no such constraint, or the constraint is unknown, the
amount returned will be identical to uv.get_free_memory().numberinteger or failtable or fail
utime : table (user CPU time used)
sec : integer
usec : integer
stime : table (system CPU time used)
sec : integer
usec : integer
maxrss : integer (maximum resident set size)
ixrss : integer (integral shared memory size)
idrss : integer (integral unshared data size)
isrss : integer (integral unshared stack size)
minflt : integer (page reclaims (soft page faults))
majflt : integer (page faults (hard page faults))
nswap : integer (swaps)
inblock : integer (block input operations)
oublock : integer (block output operations)
msgsnd : integer (IPC messages sent)
msgrcv : integer (IPC messages received)
nsignals : integer (signals received)
nvcsw : integer (voluntary context switches)
nivcsw : integer (involuntary context switches)
ENOTSUP.table or fail
utime : table (user CPU time used)
sec : integer
usec : integer
stime : table (system CPU time used)
sec : integer
usec : integer
maxrss : integer (maximum resident set size)
ixrss : integer (integral shared memory size)
idrss : integer (integral unshared data size)
isrss : integer (integral unshared stack size)
minflt : integer (page reclaims (soft page faults))
majflt : integer (page faults (hard page faults))
nswap : integer (swaps)
inblock : integer (block input operations)
oublock : integer (block output operations)
msgsnd : integer (IPC messages sent)
msgrcv : integer (IPC messages received)
nsignals : integer (signals received)
nvcsw : integer (voluntary context switches)
nivcsw : integer (involuntary context switches)
integertable or fail
[1, 2, 3, ..., n] : table
model : string
speed : number
times : table
user : number
nice : number
sys : number
idle : number
irq : number
ENOTSUP if affinities are not supported on
the current platform.integer or failintegerintegerid: integer
id.id: integer
id.numberclock_id: string
clock_id can be the
string "monotonic" or "realtime".table or fail
sec: integer
nsec: integer
number or fail[flags] handle-type handle-address . Flags are
R for referenced, A for active and I for internal.fd: integer
fd. Usually this will be used during
initialization to guess the type of the stdio streams.stringgettimeofday(2). Returns
the seconds and microseconds of a unix time as a pair.integer, integer or failip, family, netmask,
internal, and mac.family output values.table
[name(s)] : table
ip : string
family : string
netmask : string
internal : boolean
mac : string
ifindex: integer
if_indextoname(3).string or failifindex: integer
ifindex as a string. On all other platforms,
uv.if_indextoname() is used.string or failnumber, number, numbertable
sysname : string
release : string
version : string
machine : string
stringname: string
size: integer (default = LUAL_BUFFERSIZE)
name as
string. The internal buffer size can be set by defining
size. If omitted, LUAL_BUFFERSIZE is used. If the
environment variable exceeds the storage available in the
internal buffer, ENOBUFS is returned. If no matching
environment variable exists, ENOENT is returned.string or failname: string
value: string
name with the
string value.boolean or failname: string
name.boolean or failtablestring or failstring or failtable
username : string
uid : integer
gid : integer
shell : string
homedir : string
numbernumberpid: integer
pid.number or failpid: integer
priority: integer
pid. The priority range is between -20 (high priority) and
19 (low priority).boolean or faillen: integer
flags: nil (see below)
callback: callable (async version) or nil (sync
version)
err: nil or string
bytes: string or nil
len with cryptographically strong
random bytes acquired from the system CSPRNG. flags is
reserved for future extension and must currently be nil or
0 or {}.len random
bytes are available, a non-zero error value is returned or
passed to the callback. If the callback is omitted, this
function is completed synchronously.string or fail0 or failerrcode: integer
err and name in luv-error-handling) equivalent
to the given platform dependent error code: POSIX error codes
on Unix (the ones stored in errno), and Win32 error codes on
Windows (those returned by GetLastError() or
WSAGetLastError()).string, string or nilepoll_wait). The call is
thread safe.loop_configure with
"metrics_idle_time".numberprepare
callback (see uv.new_prepare(), uv.prepare_start()) in order
to make sure there are no inconsistencies with the metrics
counters.tableloop_count : integer
events : integer
events_waiting : integer
utf16 value after converting it to WTF-8. The endianness of
the UTF-16 (or UCS-2) string is assumed to be the same as the
native endianness of the platform.utf16: string
integerutf16 to UTF-8 string. The
endianness of the UTF-16 (or UCS-2) string is assumed to be
the same as the native endianness of the platform.utf16: string
stringwtf8 value
after converting it to UTF-16 (or UCS-2).<number of code units> * 2.wtf8: string
integerwtf8 to UTF-16 (or UCS-2) string.
The endianness of the UTF-16 (or UCS-2) string is assumed to
be the same as the native endianness of the platform.wtf8: string
string