Skip to content

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:

FunctionDescription
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:

FunctionDescription
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:

FunctionDescription
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.

lua
is.boolean(true)

Function(v) ​

Returns true when v is a function.

lua
is.Function(function() end)

Nil(v) ​

Returns true when v is nil.

lua
is.Nil(nil)

number(v) ​

Returns true when v is a number.

lua
is.number(3.14)

string(v) ​

Returns true when v is a string.

lua
is.string("hello")

table(v) ​

Returns true when v is a table.

lua
is.table({})

thread(v) ​

Returns true when v is a thread.

lua
is.thread(coroutine.create(function() end))

userdata(v) ​

Returns true when v is userdata.

lua
is.userdata(io.stdout)

Value Checks ​

False(v) ​

Returns true when v is exactly false.

lua
is.False(false)

True(v) ​

Returns true when v is exactly true.

lua
is.True(true)

falsy(v) ​

Returns true when v is falsy.

lua
is.falsy(false)

callable(v) ​

Returns true when v is callable.

lua
is.callable(function() end)

integer(v) ​

Returns true when v is an integer.

lua
is.integer(42)

truthy(v) ​

Returns true when v is truthy.

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
is.socket("/path/to/socket")