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)

Functions

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

Is Table

Is Is the test true.

Is Table Callers

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

Functions

# Table(var)

Returns the var if the passed variable is a table.

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

Returns the var if the passed variable is a string.

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

Returns the var if the passed variable is a number.

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:
# Boolean(var)

Returns true if the passed variable is a boolean.

Parameters:
  • var : (mixed) The variable to check
Returns:
# 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)
# 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:
# 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:
# Positive(var)

Returns the passed var if it is positive.

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)
# even(var)

Returns the passed var if it is even.

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)
# NaN(var)

Returns the passed var if it is not a number.

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

Returns the passed var if it is finite.

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)
# Int8(var)

Returns the passed var if it is an int8.

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)
# Unsigned(var)

Returns the passed var if it is an unsigned int.

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)
# UInt8(var)

Returns the passed var if it is an unsigned int8.

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)
# Float(var)

Returns the passed var if it is a float.

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

Returns the passed var if it is a full position.

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

Returns the passed var if it is a full area.

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

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

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

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

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)
# 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
# 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
# Object(var)

Is this a factorio object

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

Is this factorio object valid

Parameters: Returns:
  • (mixed) the var if this is a valid LuaObject
# 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

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

# Is(var)

Is the test truthy

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

Is the test not truthy

Parameters:
  • var : (mixed)
Returns:
# 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: