is ​
Type predicates for Lua values and filesystem path kinds.
Function names exist in both lowercase and capitalized forms (for example, is.table or is.Table).
is is callable as is(v, tp) where v is the value and tp is any supported type name.
Quick Reference ​
Type Checks:
| Function | Description |
|---|---|
boolean(v) | Returns true when v is a boolean. |
Function(v) | Returns true when v is a function. |
Nil(v) | Returns true when v is nil. |
number(v) | Returns true when v is a number. |
string(v) | Returns true when v is a string. |
table(v) | Returns true when v is a table. |
thread(v) | Returns true when v is a thread. |
userdata(v) | Returns true when v is userdata. |
Value Checks:
| Function | Description |
|---|---|
False(v) | Returns true when v is exactly false. |
True(v) | Returns true when v is exactly true. |
falsy(v) | Returns true when v is falsy. |
callable(v) | Returns true when v is callable. |
integer(v) | Returns true when v is an integer. |
truthy(v) | Returns true when v is truthy. |
Path Checks:
| Function | Description |
|---|---|
block(v) | Returns true when v is a block device path. |
char(v) | Returns true when v is a char device path. |
device(v) | Returns true when v is a block or char device path. |
dir(v) | Returns true when v is a directory path. |
fifo(v) | Returns true when v is a FIFO path. |
file(v) | Returns true when v is a file path. |
link(v) | Returns true when v is a symlink path. |
socket(v) | Returns true when v is a socket path. |
Functions ​
Type Checks ​
boolean(v) ​
Returns true when v is a boolean.
is.boolean(true)Function(v) ​
Returns true when v is a function.
is.Function(function() end)Nil(v) ​
Returns true when v is nil.
is.Nil(nil)number(v) ​
Returns true when v is a number.
is.number(3.14)string(v) ​
Returns true when v is a string.
is.string("hello")table(v) ​
Returns true when v is a table.
is.table({})thread(v) ​
Returns true when v is a thread.
is.thread(coroutine.create(function() end))userdata(v) ​
Returns true when v is userdata.
is.userdata(io.stdout)Value Checks ​
False(v) ​
Returns true when v is exactly false.
is.False(false)True(v) ​
Returns true when v is exactly true.
is.True(true)falsy(v) ​
Returns true when v is falsy.
is.falsy(false)callable(v) ​
Returns true when v is callable.
is.callable(function() end)integer(v) ​
Returns true when v is an integer.
is.integer(42)truthy(v) ​
Returns true when v is truthy.
is.truthy("non-empty")Path Checks ​
block(v) ​
Returns true when v is a block device path.
Raises an error if lfs is not installed.
Requires [`lfs`](https://github.com/lunarmodules/luafilesystem).
is.block("/dev/sda")char(v) ​
Returns true when v is a char device path.
Raises an error if lfs is not installed.
Requires [`lfs`](https://github.com/lunarmodules/luafilesystem).
is.char("/dev/null")device(v) ​
Returns true when v is a block or char device path.
Raises an error if lfs is not installed.
Requires [`lfs`](https://github.com/lunarmodules/luafilesystem).
is.device("/dev/null")dir(v) ​
Returns true when v is a directory path.
Raises an error if lfs is not installed.
Requires [`lfs`](https://github.com/lunarmodules/luafilesystem).
is.dir("/tmp")fifo(v) ​
Returns true when v is a FIFO path.
Raises an error if lfs is not installed.
Requires [`lfs`](https://github.com/lunarmodules/luafilesystem).
is.fifo("/path/to/fifo")file(v) ​
Returns true when v is a file path.
Raises an error if lfs is not installed.
Requires [`lfs`](https://github.com/lunarmodules/luafilesystem).
is.file("README.md")link(v) ​
Returns true when v is a symlink path.
Raises an error if lfs is not installed.
Requires [`lfs`](https://github.com/lunarmodules/luafilesystem).
is.link("/path/to/link")socket(v) ​
Returns true when v is a socket path.
Raises an error if lfs is not installed.
Requires [`lfs`](https://github.com/lunarmodules/luafilesystem).
is.socket("/path/to/socket")