Internationalisation
Bundled Plugins API
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:
1
local is_nothing = require("cp.is").nothing
2
is_nothing(nil) == true
Copied!
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:
1
is.blank("") == true
2
is.nt.blank("") == false
Copied!
They can also be assigned directly to local values for better performance:
1
local isnt_blank = is.nt.blank
2
isnt_blank(nil) == false
Copied!

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
  • value - the value to check.
Returns
  • true if it matches, false if not.

boolean

Signature
cp.is.boolean(value) -> boolean
Type
Function
Description
Check if the value is a function.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.

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
  • value - the value to check
Returns
  • true if it matches, false if not.

falsey

Signature
cp.is.falsey(value) -> boolean
Type
Function
Description
Check if the value is a falsey value.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.

fn

Signature
cp.is.fn(value) -> boolean
Type
Function
Description
Check if the value is a function.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.

instance

Signature
cp.is.instance(value, class) -> boolean
Type
Function
Description
Check if the value is an instance of the provided class table. It is considered
Parameters
  • value - the value to check
  • class - the class table to check
Returns
  • true if it is an instance.

list

Signature
cp.is.list(value) -> boolean
Type
Function
Description
Check if the value is a list.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.

nothing

Signature
cp.is.nothing(value) -> boolean
Type
Function
Description
Check if the value is nil.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.

number

Signature
cp.is.number(value) -> boolean
Type
Function
Description
Check if the value is a number.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.

object

Signature
cp.is.object(value) -> boolean
Type
Function
Description
Check if the value is a object.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.

something

Signature
cp.is.something(value) -> boolean
Type
Function
Description
Check if the value is not nil.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.

string

Signature
cp.is.string(value) -> boolean
Type
Function
Description
Check if the value is a string.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.

table

Signature
cp.is.table(value) -> boolean
Type
Function
Description
Check if the value is a table.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.

truthy

Signature
cp.is.truthy(value) -> boolean
Type
Function
Description
Check if the value is a truthy value.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.

userdata

Signature
cp.is.userdata(value) -> boolean
Type
Function
Description
Check if the value is a userdata object.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.
Last modified 1mo ago
Export as PDF
Copy link