# cp.is

A simple class that lets you test if a value is a particular type. Notes: 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

Functions - API calls offered directly by the extension

  • blank
  • boolean
  • callable
  • falsey
  • fn
  • instance
  • list
  • nothing
  • number
  • object
  • something
  • string
  • table
  • truthy
  • userdata

# 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.
Notes None
Examples None
Source src/extensions/cp//is.lua line 222

# 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.
Notes None
Examples None
Source src/extensions/cp//is.lua line 93

# 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.
Notes None
Examples None
Source src/extensions/cp//is.lua line 209

# falsey

Signature cp.is.falsey(value) -> boolean
Type Function
Description Check if the value is a falsey value. A value is considered to be falsey if it is nil or false.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.
Notes None
Examples None
Source src/extensions/cp//is.lua line 171

# 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.
Notes None
Examples None
Source src/extensions/cp//is.lua line 67

# 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 an instance if the class is either the value itself, or is the __index or __class field of the metatable.
Parameters
  • value - the value to check
  • class - the class table to check
Returns
  • true if it is an instance.
Notes None
Examples None
Source src/extensions/cp//is.lua line 235

# 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.
Notes None
Examples None
Source src/extensions/cp//is.lua line 145

# 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.
Notes None
Examples None
Source src/extensions/cp//is.lua line 28

# 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.
Notes None
Examples None
Source src/extensions/cp//is.lua line 80

# 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.
Notes None
Examples None
Source src/extensions/cp//is.lua line 132

# 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.
Notes None
Examples None
Source src/extensions/cp//is.lua line 41

# 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.
Notes None
Examples None
Source src/extensions/cp//is.lua line 54

# 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.
Notes None
Examples None
Source src/extensions/cp//is.lua line 106

# truthy

Signature cp.is.truthy(value) -> boolean
Type Function
Description Check if the value is a truthy value. A value is considered to be truthy if it is not nil nor false.
Parameters
  • value - the value to check
Returns
  • true if it matches, false if not.
Notes None
Examples None
Source src/extensions/cp//is.lua line 158

# 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.
Notes None
Examples None
Source src/extensions/cp//is.lua line 119