Utils.Is module

Is expression library

Usage

local Is = require('__stdlib__/stdlib/utils/is')
Is.True(true)
Is.Not.True(false)
Is.Assert.True(true)
Is.Assert.Not.True(false)

Is Table

Is Is the test true.

Is Table Callers

Assert(var) Assert that the test is Truthy
Assert.Not(var) Assert that the test is not Truthy
Is(var) Is the test truthy
Not(var) Is the test not truthy

Functions

AlphabetWord(var) Returns true if the passed variable is a single alphbetical word.
AlphanumWord(var) Returns true if the passed variable is a single alphbetical word.
Area(var) Returns the passed var if it is a full area.
Boolean(var) Returns true if the passed variable is a boolean.
BoundingBox(var) Returns the passed var if it is a simple area/boundingbox.
Callable(var) Returns true if the passed variable is a callable function.
Empty(var) Returns true if the passed variable is nil, an empty table, or an empty string.
False(var) Returns true if the passed variable is false.
Falsy(var) Returns true if the passed variable is false or nil.
Finite(var) Returns the passed var if it is finite.
Float(var) Returns the passed var if it is a float.
Hex(var) Returns the hex value of the passed var if it is hexadecimal.
Int(var) Returns the passed var if it is an int.
Int16(var) Returns the passed var if it is an int16.
Int32(var) Returns the passed var if it is an int32.
Int8(var) Returns the passed var if it is an int8.
NaN(var) Returns the passed var if it is not a number.
Negative(var) Returns the passed var if it is negative.
Nil(var) Returns true if the passed variable is nil.
Number(var) Returns the var if the passed variable is a number.
Object(var) Is this a factorio object
Position(var) Returns the passed var if it is a full position.
Positive(var) Returns the passed var if it is positive.
StrictWord(var) Returns true if the passed variable is a single alphbetical word.
String(var) Returns the var if the passed variable is a string.
Table(var) Returns the var if the passed variable is a table.
True(var) Returns true if the passed variable is true
Truthy(var) Returns the var if the passed variable is not nil or false.
UInt(var) Returns the passed var if it is an unsigned int.
UInt16(var) Returns the passed var if it is an unsigned int16.
UInt32(var) Returns the passed var if it is an unsigned int32.
UInt8(var) Returns the passed var if it is an unsigned int8.
Unsigned(var) Returns the passed var if it is an unsigned int.
Valid(var) Is this factorio object valid
Vector(var) Returns the passed var if it is a simple position/vector.
even(var) Returns the passed var if it is even.
odd(var) Returns the passed var if it is odd.

Is Table

# Is

Is the test true.

Fields:
  • Not : Is the test not true.
  • Assert : Assert that the test is true.
    • Not : Assert that the test is not true.

Is Table Callers

# Assert(var)

Assert that the test is Truthy

Parameters:
  • var : (mixed)
Returns:
# Assert.Not(var)

Assert that the test is not Truthy

Parameters:
  • var : (mixed)
Returns:
# Is(var)

Is the test truthy

Parameters:
  • var : (mixed)
Returns:
# Not(var)

Is the test not truthy

Parameters:
  • var : (mixed)
Returns:

Functions

# AlphabetWord(var)

Returns true if the passed variable is a single alphbetical word.

Allows _ and – as part of the word

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (boolean) true if the passed variable is a single alphbetical word
# AlphanumWord(var)

Returns true if the passed variable is a single alphbetical word.

Must start with a letter, allows _ and – as part of the word

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (boolean) true if the passed variable is a single alphbetical word
# Area(var)

Returns the passed var if it is a full area.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Boolean(var)

Returns true if the passed variable is a boolean.

Parameters:
  • var : (mixed) The variable to check
Returns:
# BoundingBox(var)

Returns the passed var if it is a simple area/boundingbox.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Callable(var)

Returns true if the passed variable is a callable function.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (boolean) true if the passed variable is a callable function
# Empty(var)

Returns true if the passed variable is nil, an empty table, or an empty string.

Parameters:
  • var : (mixed) The variable to check
Returns:
# False(var)

Returns true if the passed variable is false.

Parameters:
  • var : (mixed) The variable to check
Returns:
# Falsy(var)

Returns true if the passed variable is false or nil.

Parameters:
  • var : (mixed) The variable to check
Returns:
# Finite(var)

Returns the passed var if it is finite.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Float(var)

Returns the passed var if it is a float.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Hex(var)

Returns the hex value of the passed var if it is hexadecimal.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Int(var)

Returns the passed var if it is an int.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Int16(var)

Returns the passed var if it is an int16.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Int32(var)

Returns the passed var if it is an int32.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Int8(var)

Returns the passed var if it is an int8.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# NaN(var)

Returns the passed var if it is not a number.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Negative(var)

Returns the passed var if it is negative.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Nil(var)

Returns true if the passed variable is nil.

Parameters:
  • var : (mixed) The variable to check
Returns:
# Number(var)

Returns the var if the passed variable is a number.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Object(var)

Is this a factorio object

Parameters: Returns:
  • (mixed) the var if this is an LuaObject
# Position(var)

Returns the passed var if it is a full position.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Positive(var)

Returns the passed var if it is positive.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# StrictWord(var)

Returns true if the passed variable is a single alphbetical word.

Does not allow any special chars

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (boolean) true if the passed variable is a single alphbetical word
# String(var)

Returns the var if the passed variable is a string.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Table(var)

Returns the var if the passed variable is a table.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# True(var)

Returns true if the passed variable is true

Parameters:
  • var : (mixed) The variable to check
Returns:
# Truthy(var)

Returns the var if the passed variable is not nil or false.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# UInt(var)

Returns the passed var if it is an unsigned int.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# UInt16(var)

Returns the passed var if it is an unsigned int16.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# UInt32(var)

Returns the passed var if it is an unsigned int32.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# UInt8(var)

Returns the passed var if it is an unsigned int8.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Unsigned(var)

Returns the passed var if it is an unsigned int.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# Valid(var)

Is this factorio object valid

Parameters: Returns:
  • (mixed) the var if this is a valid LuaObject
# Vector(var)

Returns the passed var if it is a simple position/vector.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# even(var)

Returns the passed var if it is even.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)
# odd(var)

Returns the passed var if it is odd.

Parameters:
  • var : (mixed) The variable to check
Returns:
  • (mixed)