is

A simple class that lets you test if a value is a particular type. Note: for best performance, assign the specific checks you want to use to local functions. Eg:

local is_nothing = require("cp.is").nothing
is_nothing(nil) == true

You can also get functions that negate the functions below by calling is.nt.XXX(...) (read: "isn't XXX"). The individual functions are not documented, but all will work as expected. Eg:

is.blank("") == true
is.nt.blank("") == false

They can also be assigned directly to local values for better performance:

local isnt_blank = is.nt.blank
isnt_blank(nil) == false

API Overview

API Documentation

Functions

blank

Signature

cp.is.blank(value) -> boolean

Type

Function

Description

Check if the value is a blank string value - either nil or tostring(value) == "".

Parameters

Returns

boolean

Signature

cp.is.boolean(value) -> boolean

Type

Function

Description

Check if the value is a function.

Parameters

Returns

callable

Signature

cp.is.callable(value) -> boolean

Type

Function

Description

Check if the value is a callable - either a function or a table with __call in it's metatable hierarchy.

Parameters

Returns

falsey

Signature

cp.is.falsey(value) -> boolean

Type

Function

Description

Check if the value is a falsey value.

Parameters

Returns

fn

Signature

cp.is.fn(value) -> boolean

Type

Function

Description

Check if the value is a function.

Parameters

Returns

list

Signature

cp.is.list(value) -> boolean

Type

Function

Description

Check if the value is a list.

Parameters

Returns

nothing

Signature

cp.is.nothing(value) -> boolean

Type

Function

Description

Check if the value is nil.

Parameters

Returns

number

Signature

cp.is.number(value) -> boolean

Type

Function

Description

Check if the value is a number.

Parameters

Returns

object

Signature

cp.is.object(value) -> boolean

Type

Function

Description

Check if the value is a object.

Parameters

Returns

something

Signature

cp.is.something(value) -> boolean

Type

Function

Description

Check if the value is not nil.

Parameters

Returns

string

Signature

cp.is.string(value) -> boolean

Type

Function

Description

Check if the value is a string.

Parameters

Returns

table

Signature

cp.is.table(value) -> boolean

Type

Function

Description

Check if the value is a table.

Parameters

Returns

truthy

Signature

cp.is.truthy(value) -> boolean

Type

Function

Description

Check if the value is a truthy value.

Parameters

Returns

userdata

Signature

cp.is.userdata(value) -> boolean

Type

Function

Description

Check if the value is a userdata object.

Parameters

Returns