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