_:dispatch(name, ...)
source |
event

Dispatches all events with matching `name`.

Arguments

name (string)
event name identifier.
... (mixed)
list of arguments to pass to event handler.

Returns

(void)
invokes all event handlers with registered with matching `name`.

Examples

			
-- local add = function(n) value = value + n end
-- local mul = function(n) value = value * n end
-- local sub = function(n) value = value - n end

-- 
			
_:dispatch('add', 4)
-- 16
			
_:dispatch('down', 2)
-- 7
			
			
    _:off(...)
source |
event

Unregisters existing event listener(s) by name.

All listeners registered with this name will be unregistered.

Arguments

... (string)
list of event name identifiers.

Returns

(void)
unregisters event handlers.

Examples

			
_:off('up')
-- removes multple event handlers registered at `up`.
			
_:off('down')
-- removes single event handler registred at `down`.
			
			
    _:on(name, ...)
source |
event

Register one or more event listener.

Arguments

name (string)
event name identifier.
... (function)
list of event handlers to invoke on event.

Returns

(void)
registers event handlers to be invoked upon event dispatch.

Examples

			
_:on('up', add, mul)
-- adds multiple events when `up` event is dispatched.
			
_:on('down', sub)
-- adds single events when `down` event is dispatched.
			
			
    _:clamp(num, min, max)
source |
math
number

Performs clamp on `num` so it fits between `min` and `max` values.

Arguments

num (number)
the number to clamp.
min (number)
maximum value to clamp to.
max (number)
minimum value to clamp to.

Returns

(number)
returns clamped value.

Examples

			
_:clamp(-5, -1, 2)
-- -1
			
_:clamp(0, -1, 2)
-- 0
			
_:clamp(3, -1, 2)
-- 2
			
			
    _:lerp(num, min, max)
source |
math
number

Performs linear interpolation on a `number` between `min` and `max` values.

Arguments

num (number)
the number to linear interpolate.
min (number)
maximum value in range.
max (number)
minimum value in range.

Returns

(number)
returns linear interpolated value.

Examples

			
_:lerp(0.3, 10, 20)
-- 13
			
_:lerp(0.75, 0, 100)
-- 75
			
			
    _:mapTo(num, minSource, maxSource, minDest, maxDest)
source |
math
number

Maps `num` from source range (`minSource/maxSource`) to destination range (`minDest/maxDest`).

Arguments

num (number)
the number to map.
minSource (number)
minimum value in source range.
maxSource (number)
maximum value in source range.
minDest (number)
minimum value in destination range.
maxDest (number)
maximum value in destination range.

Returns

(number)
returns mapped value.

Examples

			
_:mapTo(0.5, 1, 2, 10, 20)
-- 5
			
_:mapTo(9, 0, 1, 0, 25)
-- 225
			
			
    _:norm(num, [min=0], [max=1])
source |
math
number

Computes normalized `num` between `min/max` range.

Arguments

num (number)
the number to map.
min (number=0)
minimum value to normalize with.
max (number=1)
maximum alue to normalize with.

Returns

(number)
returns mapped value.

Examples

			
_:norm(5, 0, 10)
-- 0.5
			
_:norm(5, 4, 8)
-- 1.25
			
_:norm(9, 4, 8)
-- 0.25
			
			
    _:isArray(var)
source |
lang
array

"Array" functions will always use `ipairs`

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is an "array", else `false`.

Examples

			
_:isArray({a = 1, 2, 'c'})
-- false
			
_:isArray({a = 1, b = 2})
-- false
			
_:isArray({})
-- true
			
_:isArray({false, true})
-- true
			
_:isArray({1, 'b', 'c', 4})
-- true
			
			
    _:isBoolean(var)
source |
lang
boolean

Determines if `var` is a boolean value.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a boolean value, else `false`.

Examples

			
_:isBoolean('true')
-- false
			
_:isBoolean(true)
-- true
			
			
    _:isEmpty(var)
source |
lang

Determines if `var` is an "empty" value.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is an "empty" value, else `false`.

Examples

			
_:isEmpty('abc')
-- false
			
_:isEmpty(true)
-- false
			
_:isEmpty(1)
-- false
			
_:isEmpty({1, 2, 3})
-- false
			
_:isEmpty('')
-- true
			
_:isEmpty(false)
-- true
			
_:isEmpty(0)
-- true
			
_:isEmpty({})
-- true
			
_:isEmpty(nil)
-- true
			
			
    _:isEqual(left, right)
source |
lang

Determines if `left == right`, with tables undergoing recursive equality.

Arguments

left (mixed)
left side argument.
right (mixed)
left side argument.

Returns

(boolean)
returns `true` if `left == right`, else `false`.

Examples

			
_:isEqual(true, true)
-- true
			
_:isEqual(true, false)
-- false
			
_:isEqual(1, 1)
-- true
			
_:isEqual(1, 2)
-- false
			
_:isEqual('foo', 'foo')
-- true
			
_:isEqual('foo', 'bar')
-- false
			
_:isEqual({'a', 'b', 'c'}, {'a', 'b', 'c'})
-- true
			
_:isEqual({'a', 'b', 'c'}, {'a', 'c', 'b'})
-- false
			
_:isEqual({a = 1, b = 5, c = 3}, {c = 3, b = 5, a = 1})
-- true
			
_:isEqual({a = 1, b = 5, c = 3}, {c = 6, b = 10, a = 2})
-- false
			
			
    _:isEven(var)
source |
lang
boolean
number

Determines if `var` is an even number.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a even number, else `false`.

Examples

			
_:isEven(147)
-- false
			
_:isEven(168)
-- true
			
			
    _:isFalsey(var)
source |
lang
boolean

Determines if `var` is a falsey value (e.g. `nil`, `false`).

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a falsey value, else `false`.

Examples

			
_:isFalsey('abc')
-- false
			
_:isFalsey(42)
-- false
			
_:isFalsey(function() end))
-- false
			
_:isFalsey(nil)
-- true
			
_:isFalsey(false)
-- true
			
			
    _:isFunction(var)
source |
lang
function

Determines if `var` is a function.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a function, else `false`.

Examples

			
_:isFunction('Hello World!')
-- false
			
_:isFunction(function() return 'Hello World!' end))
-- true
			
_:isFunction('isEqual')
-- true
			
			
    _:isNaN(var)
source |
lang
number

Determines if `var` is not a `number`.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is not a number, else `false`.

Examples

			
_:isNaN('thirty-five')
-- false
			
_:isNaN(35)
-- true
			
			
    _:isNegative(var)
source |
lang
number

Determines if `var` is a negative number.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a negative number, else `false`.

Examples

			
_:isNegative('abc')
-- false
			
_:isNegative(3)
-- false
			
_:isNegative(-2)
-- true
			
			
    _:isNil(var)
source |
lang

Determines if `var` is nil.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is nil, else `false`.

Examples

			
_:isNil('abc')
-- false
			
_:isNil(nil)
-- true
			
			
    _:isNotNil(var)
source |
lang

Determines if `var` is not nil.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is not nil, else `false`.

Examples

			
_:isNotNil(nil)
-- false
			
_:isNotNil('abc')
-- true
			
			
    _:isNumber(var)
source |
lang
number

Determines if `var` is a number.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a number, else `false`.

Examples

			
_:isNumber('abc')
-- false
			
_:isNumber(42)
-- true
			
			
    _:isOdd(var)
source |
lang
boolean
number

Determines if `var` is an odd number.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is an odd number, else `false`.

Examples

			
_:isOdd(168)
-- false
			
_:isOdd(147)
-- true
			
			
    _:isPositive(var)
source |
lang
number

Determines if `var` is a positive number.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a positive number, else `false`.

Examples

			
_:isPositive('abc')
-- false
			
_:isPositive(-23)
-- false
			
_:isPositive(67)
-- true
			
			
    _:isPositive(var)
source |
lang
regex

Alias for _:isRegexPattern.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a regex pattern, else `false`.

Examples

			
_:isRegex('abc')
-- false
			
_:isRegex('^abc')
-- false
			
_:isRegex('[abc]')
-- true
			
_:isRegex('%a+')
-- true
			
			
    _:isRegexPattern(var)
source |
lang
regex

Determines if `var` is a regex pattern.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a regex pattern, else `false`.

Examples

			
_:isRegexPattern('abc')
-- false
			
_:isRegexPattern('^abc')
-- false
			
_:isRegexPattern('[abc]')
-- true
			
_:isRegexPattern('%a+')
-- true
			
			
    _:isSequence(var)
source |
lang

Determines if `var` is a "sequence" (e.g. an ordered, indexed table).

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a "sequence", else `false`.

Examples

			
_:isSequence({a = 1, b = 3, 4, 8})
-- false
			
_:isSequence({1, 4, 2, 10, 6})
-- false
			
_:isSequence({})
-- true
			
_:isSequence({1, 3, 5, 6, 7})
-- true
			
			
    _:isSet(var)
source |
lang

Determines if `var` is a "set" (e.g. a table with named indexes for uniqueness; order is not important).

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a "set", else `false`.

Examples

			
_:isSet({a = 1, b = 3, c = 4, 5, 8})
-- false
			
_:isSet({3, 3, 5, 6, 6})
-- false
			
_:isSet({})
-- true
			
_:isSet({1, 4, 2, 10, 6})
-- true
			
			
    _:isString(var)
source |
lang
string

Determines if `var` is a string value.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a string value, else `false`.

Examples

			
_:isString(42)
-- false
			
_:isString('abc')
-- true
			
			
    _:isTable(var)
source |
lang
table

Determines if `var` is a table value.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a table value, else `false`.

Examples

			
_:isTable('abc')
-- false
			
_:isTable({3, 3, 5, 6, 6})
-- true
			
			
    _:isThread(var)
source |
lang
thread

Determines if `var` is a thread.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a thread, else `false`.

Examples

			
_:isThread('I am a thread!')
-- false
			
_:isThread(coroutine.create(function() end))
-- true
			
			
    _:isTruthy(var)
source |
lang
boolean

Determines if `var` is a truthy value (e.g. anything but false and nil).

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a truthy value, else `false`.

Examples

			
_:isTruthy(nil)
-- false
			
_:isTruthy(false)
-- false
			
_:isTruthy('abc')
-- true
			
_:isTruthy(42)
-- true
			
_:isTruthy(function() end)
-- true
			
			
    _:isZero(var)
source |
lang

Determines if `var` is zero.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is zero, else `false`.

Examples

			
_:isZero('abc')
-- false
			
_:isZero(0)
-- true
			
			
    _:is_(var)
source |
lang
function

Determines if `var` is a native lander function.

Arguments

var (mixed)
variable to check.

Returns

(boolean)
returns `true` if value is a native lander function, else `false`.

Examples

			
_:is_(123)
-- false
			
_:is_('fakeFunction')
-- false
			
_:is_(function(v) return _:isTruthy(v) end))
-- false
			
_:is_('isTruthy')
-- true
			
			
    _:abs(num)
source |
math
number

Returns absolute value of `num`.

Arguments

num (number)
the number to modify

Returns

(number)
returns absolute value.

Examples

			
_:abs(4)
-- 4
			
_:abs(-4)
-- 4
			
			
    _:add(...)
source |
math
number

Adds all `...` numbers and returns sum.

Arguments

... (number)
the numbers to add.

Returns

(number)
returns summed value.

Examples

			
_:add(4, 6)
-- 10
			
_:add(4, 5, 3)
-- 12
			
			
    _:bin2Dec(bin)
source |
math
number
binary

Converts `bin` representation into it's base-10 numeric counterpart.

Arguments

bin (number)
binary number to convert.

Returns

(number)
returns base-10 numeric value.

Examples

			
_:bin2Dec('0011')
-- 3
			
_:bin2Dec('01010101')
-- 85
			
_:bin2Dec('101010111100')
-- 2748
			
			
    _:bin2Hex(bin)
source |
math
number
binary

Converts `bin` representation into it's hexadecimal string counterpart.

Arguments

bin (number)
binary number to convert.

Returns

(string)
returns hexadecimal value.

Examples

			
_:bin2Hex('0011')
-- 3
			
_:bin2Hex('01010101')
-- 55
			
_:bin2Hex('101010111100')
-- ABC
			
			
    _:bitwiseAND(x, y)
source |
math
number
binary

Perform bitwise AND operation on `x` and returns the result.

Arguments

x (number)
number to compare.
y (number)
number to compare.

Returns

(number)
returns result of computation value.

Examples

			
_:bitwiseAND(50, 25)
-- 16
			
_:bitwiseAND(128456, 6201938)
-- 41024
			
_:bitwiseAND(0x2BC, 0xAEF)
-- 684
			
			
    _:bitwiseNOT(x)
source |
math
number
binary

Perform bitwise NOT operation on `x` and returns the result.

Arguments

x (number)
number to compare.

Returns

(number)
returns result of computation value.

Examples

			
_:bitwiseNOT(546)
-- -547
			
_:bitwiseNOT(6589534)
-- -6589535
			
_:bitwiseNOT(0x2BC)
-- -701
			
			
    _:bitwiseOR(x, y)
source |
math
number
binary

Perform bitwise OR operation on `x` and returns the result.

Arguments

x (number)
number to compare.
y (number)
number to compare.

Returns

(number)
returns result of computation value.

Examples

			
_:bitwiseOR(50, 25)
-- 59
			
_:bitwiseOR(128456, 6201938)
-- 6289370
			
_:bitwiseOR(0x2BC, 0xAEF)
-- 2815
			
			
    _:bitwiseXOR(x, y)
source |
math
number
binary

Perform bitwise OR operation on `x` and returns the result.

Arguments

x (number)
number to compare.
y (number)
number to compare.

Returns

(number)
returns result of computation value.

Examples

			
_:bitwiseXOR(50, 25)
-- 43
			
_:bitwiseXOR(128456, 6201938)
-- 6248346
			
_:bitwiseXOR(0x2BC, 0xAEF)
-- 2131
			
			
    _:ceil(num, [precision=0])
source |
math
number

Rounds up `num` to desired `precision`.

Using a negative value for `precision` will round from right to left.

Arguments

num (number)
number to round up.
precision (number=0)
rounding precision.

Returns

(number)
returns rounded number.

Examples

			
_:ceil(4.006)
-- 5
			
_:ceil(6.004, 2)
-- 2
			
_:ceil(6040, -2)
-- 6100
			
			
    _:dec2Bin(dec)
source |
math
number
binary

Converts `dec` representation into it's binary string counterpart.

Arguments

dec (number)
base-10 number to convert.

Returns

(string)
returns binary value.

Examples

			
_:dec2Bin(55)
-- 00110111
			
_:dec2Bin(578)
-- 001001000010
			
			
    _:dec2Hex(dec)
source |
math
number
binary

Converts `dec` representation into it's hexadecimal string counterpart.

Arguments

dec (number)
base-10 number to convert.

Returns

(string)
returns hexadecimal value.

Examples

			
_:dec2Hex(7845)
-- 1EA5
			
_:dec2Hex(268)
-- 10C
			
			
    _:divide(...)
source |
math
number

Divides series of numbers and returns result.

Arguments

... (number)
the numbers to divide.

Returns

(number)
returns result of division.

Examples

			
_:divide(6, 4)
-- 1.5
			
_:divide(6, 3, 2)
-- 1
			
_:divide(2, 0)
-- throws error!
			
			
    _:floor(num, [precision=0])
source |
math
number

Rounds down `num` to desired `precision`.

Using a negative value for `precision` will round from right to left.

Arguments

num (number)
number to round down.
precision (number=0)
rounding precision.

Returns

(number)
returns rounded number.

Examples

			
_:floor(4.006)
-- 4
			
_:floor(0.046, 2)
-- 0.04
			
_:floor(4060, -2)
-- 4000
			
			
    _:hex2Bin(hex)
source |
math
number
binary

Converts `hex` representation into it's binary string counterpart.

Arguments

hex (string)
hexadecimal value to convert.

Returns

(string)
returns binary value.

Examples

			
_:hex2Bin('55')
-- 01010101
			
_:hex2Bin('AB14')
-- 1010101100010100
			
			
    _:hex2Dec(hex)
source |
math
number
binary

Converts `hex` representation into it's base-10 numeric counterpart.

Arguments

hex (string)
hexadecimal value to convert.

Returns

(number)
returns base-10 numeric value.

Examples

			
_:hex2Dec('55')
-- 85
			
_:hex2Dec('AB14')
-- 43796
			
			
    _:max(...)
source |
math
number

Finds max value in sequence of numbers.

Arguments

... (number)
the numbers to test.

Returns

(number)
returns max value of `...` number values.

Examples

			
_:max(4, 2, 8, 6)
-- 8
			
_:max()
-- nil
			
			
    _:maxBy(tabl, [iteratee])
source |
math
number

Finds max value in sequence of numbers, invoking `iteratee` function on every element.

Arguments

tabl (table)
table of numbers to test.
iteratee (function)
function to ivoke per element.

Returns

(number)
returns max value of `tabl` number values.

Examples

			
_:maxBy({4, 2, 8, 6}, function(v) return v * 2 end)
-- 16
			
			
    _:mean(...)
source |
math
number

Computes mean of sequence of numbers.

Arguments

... (number)
the numbers to test.

Returns

(number)
returns max value of `...` number values.

Examples

			
_:mean(4, 2, 8, 6)
-- 5
			
			
    _:meanBy(tabl, [iteratee])
source |
math
number

Computes mean of sequence of numbers, invoking `iteratee` function on every element.

Arguments

tabl (table)
table of numbers to test.
iteratee (function)
function to ivoke per element.

Returns

(number)
returns mean value of `tabl` number values.

Examples

			
_:meanBy({4, 2, 8, 6}, function(v) return v * 2 end)
-- 10
			
			
    _:min(...)
source |
math
number

Finds min value in sequence of numbers.

Arguments

... (number)
the numbers to test.

Returns

(number)
returns min value of `...` number values.

Examples

			
_:min(4, 2, 8, 6)
-- 2
			
_:min()
-- nil
			
			
    _:minBy(tabl, [iteratee])
source |
math
number

Finds min value in sequence of numbers, invoking `iteratee` function on every element.

Arguments

tabl (table)
table of numbers to test.
iteratee (function)
function to ivoke per element.

Returns

(number)
returns min value of `tabl` number values.

Examples

			
_:minBy({4, 2, 8, 6}, function(v) return v * 2 end)
-- 4
			
			
    _:multiply(...)
source |
math
number

Multiplies sequence of numbers.

Arguments

... (number)
the numbers to multiply.

Returns

(number)
returns result of multiplication.

Examples

			
_:multiply(2, 3)
-- 6
			
_:multiply(10, -2, 3)
-- -60
			
			
    _:multiplyBy(tabl, [iteratee])
source |
math
number

Multiplies sequence of numbers, invoking `iteratee` function on every element.

Arguments

tabl (table)
table of numbers to multiply.
iteratee (function)
function to ivoke per element.

Returns

(number)
returns result of multiplication.

Examples

			
_:multiplyBy({3, -2, 4}, function(v) return v * 2 end)
-- -192
			
			
    _:round(num, [precision=0])
source |
math
number

Computes `value` rounded to `precision`.

Arguments

num (number)
number to round.
precision (number=0)
rounding precision.

Returns

(number)
returns result of rounding.

Examples

			
_:round(4.006)
-- 4
			
_:round(4.006, 2)
-- 4.01
			
_:round(4060, -2)
-- 4100
			
			
    _:subtract(...)
source |
math
number

Subtracts sequence of numbers.

Arguments

... (number)
the numbers to subtract.

Returns

(number)
returns result of multiplication.

Examples

			
_:subtract(2, 3)
-- -1
			
_:subtract(10, -2, 3, 0)
-- 9
			
			
    _:subtractBy(tabl, [iteratee])
source |
math
number

Subtracts sequence of numbers, invoking `iteratee` function on every element.

Arguments

tabl (table)
table of numbers to subtract.
iteratee (function)
function to ivoke per element.

Returns

(number)
returns result of subtraction.

Examples

			
_:subtractBy({3, -2, 4}, function(v) return v * 2 end)
-- 2
			
			
    _:sum(...)
source |
math
number

Sums sequence of numbers.

Arguments

... (number)
the numbers to sum.

Returns

(number)
returns result of sum.

Examples

			
_:sum(2, 3)
-- 5
			
_:sum(2, 3, 4, 5)
-- 14
			
			
    _:sumBy(tabl, [iteratee])
source |
math
number

Sums sequence of numbers, invoking `iteratee` function on every element.

Arguments

tabl (table)
table of numbers to sum.
iteratee (function)
function to ivoke per element.

Returns

(number)
returns result of sum.

Examples

			
_:sumBy({1, 2, 3}, function(v) return v * 2 end)
-- 12
			
			
    _:toDeg(rad)
source |
math
number

Converts `rad` to degrees.

Arguments

rad (number)
radian value to be converted.

Returns

(number)
returns unit conversion of `rad` to `deg`.

Examples

			
_:toDeg(math.pi / 2)
-- 90
			
_:toDeg(math.pi / 3)
-- 60
			
			
    _:toRad(rad)
source |
math
number

Converts `deg` to radians.

Arguments

rad (number)
degrees value to be converted.

Returns

(number)
returns unit conversion of `deg` to `rad`.

Examples

			
_:toRad(30)
-- 0.523599
			
_:toRad(180)
-- 3.141593
			
			
    _:attempt(func, ...)
source |
function
number

Attempts to invoke `func` with `...` args.

Arguments

func (function)
the function to invoke.
... (mixed)
arguments of function.

Returns

(boolean)
status of return response.
(mixed)
result of function call, or error response.
    _:force(func, ...)
source |
function
number

Same as _:attempt, but doesn't use `pcall`.

Arguments

func (function)
the function to invoke.
... (mixed)
arguments of function.

Returns

(mixed)
result of function call, or error response.
    _:ifFalsey(func, ...)
source |
function
boolean

Intercept _:attempt by invoking `func` with `...` args, then sending the results to a user-specified callback only if falsey.

Arguments

func (function)
the function to invoke.
... (mixed)
arguments of function.

Returns

(mixed)
invokes callback; receiving results as arguments and returns it's result.
    _:ifTruthy(func, ...)
source |
function
boolean

Intercept _:attempt by invoking `func` with `...` args, then sending the results to a user-specified callback only if truthy.

Arguments

func (function)
the function to invoke.
... (mixed)
arguments of function.

Returns

(mixed)
invokes callback; receiving results as arguments and returns it's result.
    _:camelCase(str)
source |
string

Converts `str` to Camel Case.

Arguments

str (string)
the string to modify.

Returns

(string)
a new camel cased string.

Examples

			
_:camelCase('Foo Bar')
-- fooBar
			
_:camelCase('--foo-bar--')
-- fooBar
			
_:camelCase('__FOO_BAR__')
-- fooBar
			
			
    _:capitalize(str)
source |
string

Capitalizes first character of `str` and lower cases the rest.

Arguments

str (string)
the string to modify.

Returns

(string)
a new capitalized string.

Examples

			
_:capitalize('FOO')
-- Foo
			
_:capitalize('foo bar')
-- Foo Bar
			
			
    _:endsWith(str, target, [position=_:size(str)])
source |
string

Determines if `str` ends with `target` up until the end `position`.

Arguments

str (string)
the string to inspect.
target (string)
the string to search for.
position (string=_:size(str))
hard stop search position.

Returns

(boolean)
returns `true` if string ends in target, else `false`.

Examples

			
_:endsWith('abc', 'b')
-- false
			
_:endsWith('abc', 'c')
-- true
			
_:endsWith('abc', 'b', 2)
-- true
			
			
    _:kebabCase(str)
source |
string

Converts `str` to Kebab Case.

Arguments

str (string)
the string to modify.

Returns

(string)
a new kebab cased string.

Examples

			
_:kebabCase('Foo Bar')
-- foo-bar
			
_:kebabCase('--foo-bar--')
-- fooBar
			
_:kebabCase('__FOO_BAR__')
-- fooBar
			
			
    _:lowerCase(str)
source |
string

Converts `str` to lower-case, space-separated words.

Arguments

str (string)
the string to modify.

Returns

(string)
a new lowercase string.

Examples

			
_:lowerCase('---Foo-Bar--')
-- foo bar
			
_:lowerCase('fooBar')
-- foo bar
			
_:lowerCase('__FOO_BAR__')
-- foo bar
			
			
    _:lowerFirst(str)
source |
string

Lower-cases first character in `str`.

Arguments

str (string)
the string to modify.

Returns

(string)
a new string with first character lower cased.

Examples

			
_:lowerFirst('Foo')
-- foo
			
_:lowerFirst('FOO')
-- fOO
			
			
    _:pad(str, [length=0], [chars=' '])
source |
string

Pads both sides of `str` with `chars`, only if `str` is smaller than `length`.

Arguments

str (string)
the string to pad.
length (number=0)
desired string length.
chars (string=' ')
characters to use as padding.

Returns

(string)
a new padded string.

Examples

			
_:pad('abc', 8)
--   abc   
			
_:pad('abc', 8, '_-')
-- _-abc_-_
			
_:pad('abc', 3)
-- abc
			
			
    _:padEnd(str, [length=0], [chars=' '])
source |
string

Pads end of `str` with `chars`, only if `str` is smaller than `length`.

Arguments

str (string)
the string to pad.
length (number=0)
desired string length.
chars (string=' ')
characters to use as padding.

Returns

(string)
a new padded string.

Examples

			
_:padEnd('abc', 6)
-- abc   
			
_:padEnd('abc', 6)
-- abc_-_
			
_:padEnd('abc', 3)
-- abc
			
			
    _:padStart(str, [length=0], [chars=' '])
source |
string

Pads beginning of `str` with `chars`, only if `str` is smaller than `length`.

Arguments

str (string)
the string to pad.
length (number=0)
desired string length.
chars (string=' ')
characters to use as padding.

Returns

(string)
a new padded string.

Examples

			
_:padStart('abc', 6)
--    abc
			
_:padStart('abc', 6)
-- _-_abc
			
_:padStart('abc', 3)
-- abc
			
			
    _:rep(str, [n=1])
source |
string

Repeats given `str` `n` number of times.

Arguments

str (string)
the string to use for repetition.
n (number=1)
number of times to repeat.

Returns

(boolean)
returns `true` if string begins in target, else `false`.

Examples

			
_:rep('*', 6)
-- ******
			
_:rep('abc', 2, '_-')
-- abcabc
			
_:rep('abc', 0)
-- 
			
			
    _:replace(str, pattern, [repl=''], [n])
source |
string

Replaces matches from `pattern` in `str` with `repl` string.

Defers to Lua's native `string.gsub` function.

Arguments

str (string)
the string to modify.
pattern (string)
regular string or regex pattern
str (string='')
replacement string.
n (number)
n-th match.

Returns

(boolean)
a new string with modifications.

Examples

			
_:replace('Hi Fred', 'Fred', 'Barney')
-- Hi Barney
			
_:replace('Hello World', '(%w+)', '%1 %1')
-- Hello Hello World World
			
_:replace('Hello, World! Hello, Everyone!', 'Hello', 'Goodbye', 1)
-- Goodbye, World! Hello, Everyone!
			
			
    _:snakeCase(str)
source |
string

Converts `str` to Snake Case.

Arguments

str (string)
the string to modify.

Returns

(string)
a new snake cased string.

Examples

			
_:snakeCase('Foo Bar')
-- foo_bar
			
_:snakeCase('fooBar')
-- foo_bar
			
_:snakeCase('--FOO-BAR--')
-- foo_bar
			
			
    _:split(str, separator, [limit=_:size(str)])
source |
string

Creates new table by spliting `str` by `separator`. Result will be no larger than `limit`.

Arguments

str (string)
the string to split.
separator (string)
regex pattern to split on.
limit (number)
length to truncate final string to.

Returns

(table)
returns string segments.

Examples

			
_:split('a-b-c-', '-')
-- {"a", "b", "c"}
			
_:split('a-b-c', '-', 2)
-- {"a", "b"}
			
			
    _:startCase(str)
source |
string

Converts `str` to Start Case.

Arguments

str (string)
the string to convert.

Returns

(string)
a new start cased string.

Examples

			
_:startCase('--foo-bar--')
-- --foo-bar--
			
_:startCase('fooBar')
-- fooBar
			
_:startCase('__FOO_BAR__')
-- FOO BAR
			
			
    _:startsWith(str, target, [position=1])
source |
string

Determine if `str` starts with `target`, starting at `position`.

Arguments

str (string)
the string to inspect.
target (string)
the string to search for.
position (string=1)
position to start search.

Returns

(boolean)
returns `true` if string begins in target, else `false`.

Examples

			
_:startsWith('abc', 'b')
-- false
			
_:startsWith('abc', 'a')
-- true
			
_:startsWith('abc', 'b', 2)
-- true
			
			
    _:toLower(str)
source |
string

Converts entire `str` to lower case..

Defers to Lua's native `string.lower` function.

Arguments

str (string)
the string to modify.

Returns

(string)
a new string lower cased.

Examples

			
_:toLower('--Foo-Bar--')
-- --foo-bar--
			
_:toLower('fooBar')
-- foobar
			
_:toLower('__FOO_BAR__')
-- __foo_bar__
			
			
    _:toUpper(str)
source |
string

Converts entire `str` to upper case..

Defers to Lua's native `string.upper` function.

Arguments

str (string)
the string to modify.

Returns

(string)
a new string upper cased.

Examples

			
_:toUpper('--foo-bar--')
-- --FOO-BAR--
			
_:toUpper('fooBar')
-- FOOBAR
			
_:toUpper('__foo_bar__')
-- __FOO_BAR__
			
			
    _:trim(str, [pattern="%s+"])
source |
string

Removes leading and trailing `pattern` of `str`.

Arguments

str (string)
the string to trim.
pattern (string)
the string or regex pattern to trim.

Returns

(string)
returns new trimmed string.

Examples

			
_:trim('  abc  ')
-- abc
			
_:trim('-_-abc-_-', '_-')
-- abc
			
_:trim('-_-abc-_-', '%p+')
-- abc
			
			
    _:trimEnd(str, [pattern="%s+"])
source |
string

Removes trailing `pattern` of `str`.

Arguments

str (string)
the string to trim.
pattern (string)
the string or regex pattern to trim.

Returns

(string)
returns new trimmed string.

Examples

			
_:trim('  abc  ')
--   abc
			
_:trim('-_-abc-_-', '_-')
-- -_-abc
			
_:trim('-_-abc-_-', '%p+')
-- -_-abc
			
			
    _:trimStart(str, [pattern="%s+"])
source |
string

Removes leading `pattern` or `str`.

Arguments

str (string)
the string to trim.
pattern (string)
the string or regex pattern to trim.

Returns

(string)
returns new trimmed string.

Examples

			
_:trim('  abc  ')
-- abc  
			
_:trim('-_-abc-_-', '_-')
-- abc-_-
			
_:trim('-_-abc-_-', '%p+')
-- abc-_-
			
			
    _:truncate(str, [options])
source |
string

Truncates `str` with `options`.

Arguments

str (string)
the string to trim.
options.length (number=30)
maximum string length (including `omission`).
options.separator (string='')
the string or regex pattern to truncate to.
options.omission (string='...)
omitted text indicator.

Returns

(string)
returns new truncated string.

Examples

			
_:truncate('hi-diddly-ho there, neighborino')
-- hi-diddly-ho there, neighbo...
			
_:truncate('hi-diddly-ho there, neighborino', {length = 24, separator = ' '})
-- hi-diddly-ho...
			
_:truncate('hi-diddly-ho there, neighborino', {length = 24, separator = '[,?]%s+'})
-- hi-diddly-ho there...
			
_:truncate('hi-diddly-ho there, neighborino', {omission = ' [...]'})
-- hi-diddly-ho there, neig [...]
			
			
    _:upperCase(str)
source |
string

Converts `str` to space-separated, upper case string.

Arguments

str (string)
the string to modify.

Returns

(string)
a new space-separated, upper case string.

Examples

			
_:upperCase('--foo-bar')
-- FOO BAR
			
_:upperCase('fooBar')
-- FOO BAR
			
_:upperCase('__foo_bar__')
-- FOO BAR
			
			
    _:upperFirst(str)
source |
string

Converts first character in `str` to upper case, leaving the rest untouched.

Arguments

str (string)
the string to modify.

Returns

(string)
a new string with first character upper cased.

Examples

			
_:upperFirst('foo')
-- Foo
			
_:upperFirst('fooBar')
-- FOO
			
			
    _:words(str, [pattern='%a+'])
source |
string
table

Converts `str` into table of words, using `pattern` as separator.

Arguments

str (string)
the string to modify.
pattern (string='%a+')
string or regex pattern to split on.

Returns

(table)
returns table of string segments.

Examples

			
_:words('lister, cat, & kryton')
-- {"lister", "cat", "kryton"}
			
_:words('lister, cat, & kryton', "[^,%s]+")
-- {"lister", "cat", "&", "kryton"}
			
			
    _:chunki(tabl, [size=1])
source |
table

Splits elements of `tabl` into groups of `size`.

Only returns numeric indexes of `tabl`.

Arguments

tabl (table)
the table to split into chunks.
size (number=1)
size of each chunk.

Returns

(table)
returns new table of table chunks.

Examples

			
_:chunki({'a', 'b', 'c', 'd'}, 2)
-- {{"a", "b"}, {"c", "d"}}
			
_:chunki({'a', 'b', 'c', 'd'}, 3)
-- {{"a","b","c"}, {"d"}}
			
_:chunki({'a', 'b', c=1, d=2})
-- {{"a"}, {"b"}}
			
_:chunki({'a', 'b', c=1, d=2}, 4)
-- {{"a","b"}}
			
			
    _:differencei(tabl, other)
source |
table
array

Creates copy of `tabl`, excluding any same values from `other`.

Only affects numeric indexes of `tabl`.

Arguments

tabl (table)
the table to process.
other (table)
the table to compare.

Returns

(table)
returns new table without intersecting values.

Examples

			
_:differencei({2, 1}, {2, 3})
-- {1}
			
_:differencei({2, 1}, {2, 1})
-- {}
			
_:differencei({2, 1}, {4, 6})
-- {2, 1}
			
_:differencei({1, 2, 8, a=3, b=4}, {2, 4})
-- {1, 8, a=3, b=4}
			
			
    _:drop(tabl, [num])
source |
table
array

Creates copy of `tabl` dropping `n` x elements from beginning (or ending if `n` is negative).

Only affects numeric indexes of `tabl`.

Arguments

tabl (table)
the table to process.
num (number)
the number of elements to drop.

Returns

(table)
returns new table minus `num` of elements.

Examples

			
_:drop({2, 1, 2, 3}, 1)
-- {2, 1, 2}
			
_:drop({2, 1, 2, 3}, 3)
-- {2}
			
_:drop({2, 1, 2, 3}, -1)
-- {1, 2, 3}
			
_:drop({2, 1, 2, 3}, -3)
-- {3}
			
			
    _:fill(tabl, value, [n=_:size(tabl)], [fromIndex=1])
source |
table
array

Fills new `tabl` with `n` x `value` starting at `fromIndex`

Only affects numeric indexes of `tabl`.

Arguments

tabl (table)
the table to process.
value (mixed)
value to populate array with.
n (number=_:size(tabl))
the number of times to repeat `value`.
fromIndex (number=1)
position to start at.

Returns

(table)
returns new table with filled values.

Examples

			
_:fill({1, 2, 3, 4}, 8, 2, 4)
-- {1, 2, 3, 8, 8}
			
_:fill({}, 'hello', 3, 2)
-- {"hello", "hello", "hello"}
			
_:fill({2, 1, 3, a=4, b=6}, 9, 4)
-- {9, 9, 9, 9, a=4, b=6}
			
			
    _:findIndex(tabl, predicate, [fromIndex=1])
source |
table
array

Returns first index (starting from `formIndex`) of `tabl` where `predicate` returns a truthy value.

Arguments

tabl (table)
the table to process.
predicate (function)
function that invokes on every element.
fromIndex (number=1)
position to start at.

Returns

(number)
returns index of found element, otherwise nil.

Examples

			
_:findIndex({1, -2, 4, 7}, function(v, k) return v > 1 end)
-- 3
			
_:findIndex({true, false, 'abc'}, 'isBoolean')
-- 1
			
_:findIndex({true, false, 'abc'}, 'isBoolean', 3)
-- nil
			
_:findIndex({'a', 'b', 'c'}, 'isBoolean')
-- nil
			
			
    _:findLastIndex(tabl, predicate, [fromIndex=#tabl])
source |
table
array

Returns first index (starting from `formIndex` and moving to the left) of `tabl` where `predicate` returns a truthy value.

Arguments

tabl (table)
the table to process.
predicate (function)
function that invokes on every element.
fromIndex (number=#tabl)
position to start at (from right to left).

Returns

(number)
returns index of found element, otherwise nil.

Examples

			
_:findLastIndex({1, -2, 4, 7}, function(v, k) return v > 1 end)
-- 4
			
_:findLastIndex({true, false, 'abc'}, 'isBoolean')
-- 2
			
			
source |
table
array

Returns first indexed value of `tabl`.

Only affects indexed elements of `tabl`.

Arguments

tabl (table)
the table to process.

Returns

(mixed)
returns value at head of array.

Examples

			
_:head({c=10, 'a', 'b', 1})
-- a
			
_:head({})
-- nil
			
			
    _:indexOf(tabl, value)
source |
table
array

Returns index of first occurrence of `value` in `tabl`, checking only numeric-indexes.

Only checks indexed elements of `tabl`.

Arguments

tabl (table)
the table to process.
value (mixed)
the value to search for.

Returns

(number)
returns index of first occurrence of `value`.

Examples

			
_:indexOf({1, 5, 'r', 3}, 'r')
-- 3
			
_:indexOf({4, 2, 8, 1}, 3)
-- nil
			
_:indexOf({c=10, 'a', 'b', 1}, 'a')
-- 1
			
			
    _:initial(tabl)
source |
table
array

Creates copy of `table` including all elements but the tail.

Only affects indexed elements of `tabl`.

Arguments

tabl (table)
the table to process.

Returns

(table)
returns new table without last index.

Examples

			
_:initial({1, 5, 'r', 3})
-- {1, 5, "r"}
			
_:initial({4})
-- {}
			
_:initial({c=10, 'a', 'b', 1})
-- {"a", "b", c=10}
			
			
    _:join(tabl, separator)
source |
table
array

Converts all numeric-indexed elements in `tabl` to string separated by `separator`.

Only affects indexed elements of `tabl`.

Arguments

tabl (table)
the table to process.
separator (string)
the string to use as glue.

Returns

(string)
returns table elements as string joined together by `separator`.

Examples

			
_:join({'a', 'b', 'c'}, '~')
-- a~b~c
			
_:join({3, 2, 5, a='x', b='y'})
-- 3,2,5
			
			
    _:lastIndexOf(tabl, value)
source |
table
array

Returns index of last occurrence of `value` in `tabl`, checking only numeric-indexes.

Only checks indexed elements of `tabl`.

Arguments

tabl (table)
the table to process.
value (mixed)
the value to search for.

Returns

(number)
returns index of last occurrence of `value`.

Examples

			
_:lastIndexOf({1, 1, 2, 2, 3, 3}, 2)
-- 4
			
_:lastIndexOf({4, 2, 8, 1}, 3)
-- nil
			
_:lastIndexOf({'a', 'b', 'a', c=10}, 'a')
-- 3
			
			
    _:mapi(tabl, iteratee)
source |
table
array

Creates copy of `tabl`, invoking `iteratee` on every element.

Only affects indexed elements of `tabl`.

Arguments

tabl (table)
the table to process.
iteratee (function)
the function invoked per element.

Returns

(table)
returns new table modified.

Examples

			
_:mapi({'a', 'b', 'c'}, string.upper)
-- {"A", "B", "C"}
			
_:mapi({a='x', b='y', 'c', 2, 1}, 'isNumber')
-- {a="x", b="y", false, true, true}
			
			
    _:nth(tabl, [n=0])
source |
table
array

Returns `n`-th indexed value of `tabl`. Negative `n`-values will count from the right.

Only affects indexed elements of `tabl`.

Arguments

tabl (table)
the table to process.
n (number=0)
the index requested.

Returns

(mixed)
returns value at requested index.

Examples

			
_:nth({'a', 'b', 1, c=10}, 2)
-- b
			
_:nth({1, 2, 3, b=1, c=2}, -2)
-- 2
			
_:nth({1, 2, 3, b=1, c=2}, 4)
-- nil
			
			
    _:reverse(tabl)
source |
table
array

Returns copy of `tabl` reversing order of numeric indexes.

Only affects indexed elements of `tabl`.

Arguments

tabl (table)
the table to process.

Returns

(mixed)
returns new table in reverse order.

Examples

			
_:reverse({'a', 'b', 1, c=10})
-- {1, "b", "a", c=10}
			
			
    _:shuffle(tabl)
source |
table
array

Creates copy of `tabl` and shuffles it using Fisher-Yates shuffle.

Only affects indexed elements of `tabl`.

Arguments

tabl (table)
the table to process.

Returns

(mixed)
returns new table in shuffled order.

Examples

			
_:shuffle({'a', 'b', 1, c=10})
-- {"b", "a", 1, c=10}
			
			
    _:tail(tabl)
source |
table
array

Returns last indexed value of `tabl`.

Only affects indexed elements of `tabl`.

Arguments

tabl (table)
the table to process.

Returns

(mixed)
returns value at tail of array.

Examples

			
_:tail({'a', 'b', 1, c=10})
-- 1
			
_:tail({})
-- nil
			
			
    _:without(tabl, ...)
source |
table
array

Creates new table of values from `tabl` excluding all elements with `...` as it's value.

Only affects indexed elements of `tabl`.

Arguments

tabl (table)
the table to process.
... (mixed)
values to exclude from new array.

Returns

(table)
returns new table without `...` values.

Examples

			
_:without({1,2,3,3,5,6,6}, 3, 6)
-- {1, 2, 5}
			
_:without({1,2,3,3,5,6,6})
-- {1, 2, 3, 3, 5, 6, 6}
			
_:without({1,2,3,3,5,6,6}, 1, 2, 3, 5, 6)
-- {}
			
_:without({'a','b','c',d=10}, 'b', 10)
-- {"a", "c", d=10}
			
_:without({'a','b','c',d=10}, 'a', 'b', 'c')
-- {d=10}
			
			
    _:chunk(tabl, [size=1])
source |
table

Splits elements of `tabl` into groups of `size`.

This will chunk both named and numeric-indexed values of `tabl`. Use _:chunki to just chunk numeric-indexed values.

Arguments

tabl (table)
the table to split into chunks.
size (number=1)
size of each chunk.

Returns

(table)
returns new table of table chunks.

Examples

			
_:chunk({'a','b','c','d'}, 2)
-- {{"a","b"},{"c","d"}}
			
_:chunk({'a','b','c','d'}, 3)
-- {{"a","b","c"},{"d"}}
			
			
    _:combine(keys, values)
source |
table

Creates new table with `keys` as keys and `values` as values.

Requirement: both tables must be equal in size.

Arguments

keys (table)
table values will be used as keys in new table.
values (table)
table values will be used as values in new table.

Returns

(table)
returns new table with keys from `keys` table and values from `values` table.

Examples

			
_:combine({'a', 'b'}, {'c','d'})
-- {a = "c", b = "d"}
			
_:combine({1, 2, 3}, {5, 4, 3})
-- {5, 4, 3}
			
_:combine({1, 2, 3, a='x', b='y'}, {5, 4, 3, c='w', d='z'})
-- {a = "c", b = "d"}
			
_:combine({'a', 'b'}, {'c','d', 'e'})
-- throws error! table sizes not equal
			
			
    _:compact(tabl)
source |
table

Creates copy of `tabl` with Lua-falsy values filtered out.

Requirement: both tables must be equal in size.

Arguments

tabl (table)
the table to inspect.

Returns

(table)
returns new table without falsey values.

Examples

			
_:compact({0, 1, false, '', 2, nil, 3})
-- {0, 1, "", 2, 3 }
			
_:compact({a = 1, 5, b = false, 'foo', c = true})
-- {a = 1, 5, "foo", c = true}
			
			
    _:conformsTo(value, source)
source |
table

Determines if `value` conforms to `source`, by invoking the predicate properties of source with corresponding propery values of `value`.

Arguments

value (table)
the table to inspect.
source (table)
the table of property predicates to conform to.

Returns

(table)
returns new table with

Examples

			
_:conformsTo({a=2, b=4, c=6}, {b = function(v,k) return v < 2 end})
-- false
			
_:conformsTo({1, 2, 3, a='x', b='y'}, {'isString'})
-- false
			
_:conformsTo({a=2, b=4, c=6}, {b = function(v,k) return v > 2 end})
-- true
			
_:conformsTo({1, 2, 3, a='x', b='y'}, {'isNumeric'})
-- true
			
			
    _:difference(tabl)
source |
table

Creates copy of `tabl`, excluding any same values from `other`.

Arguments

tabl (table)
the table to process.
other (table)
the table to compare.

Returns

(table)
returns new table without intersecting values.

Examples

			
_:difference({x=2, y=1}, {x=3, y=4})
-- { x = 2, y = 1 }
			
_:difference({x=3, y=1}, {x=3, y=4})
-- { y = 1 }
			
_:difference({x=2, y=1}, {w=2, z=1})
-- { x = 2, y = 1 }
			
			
    _:filter(tabl, iteratee)
source |
table

Creates copy of `tabl` with values that fail `iteratee` filtered out.

`iteratee` will receive arguments:
  • `value`
  • 'key'

Arguments

value (table)
the table to inspect.
iteratee (function)
function invoked on every element.

Returns

(table)
returns new filtered table.

Examples

			
_:filter({1, false, nil, 'abc'}, 'isTruthy')
-- {1, "abc"}
			
_:filter({2, 1, 3, a=4, b=6}, function(v, k) return _:isNumber(k) end)
-- {2, 1, 3}
			
_:filter({1, 2, 3, 4, 5}, function(v, k) return v > 3 end)
-- {4, 5}
			
			
    _:find(tabl, predicate)
source |
table

Return first element in `tabl`, which `predicate` returns a truthy value.

Arguments

value (table)
the table to inspect.
predicate (function)
function invoked on every element.

Returns

(mixed)
returns first found element's value.
(mixed)
returns first found element's key.

Examples

			
_:find({a=1,b=2,c=2,d=4,e=5}, function(v, k) return v == 2 end)
-- {2, "b"}
			
_:find({1, 2, 3, 4, 5}, 'isString')
-- nil
			
			
    _:flatten(tabl)
source |
table

Creates new `tabl` flattened one level deep.

Arguments

value (table)
the table to flatten.

Returns

(table)
returns new flattened table.

Examples

			
_:flatten({1, 2, {3, {4}}, 5})
-- {1, 2, 3, {4}, 5}
			
_:flatten({1, {2, {3, {4}}, 5}})
-- {1, 2, {3, {4}}, 5}
			
			
    _:flattenDeep(tabl)
source |
table

Creates new `tabl`, recursively flattening table.

Arguments

value (table)
the table to flatten.

Returns

(table)
returns new recursively flattened table.

Examples

			
_:flattenDeep({1, 2, {3, {4}}, 5})
-- {1, 2, 3, 4, 5}
			
_:flattenDeep({1, {2, {3, {4}}, 5}})
-- {1, 2, 3, 4, 5}
			
			
    _:keys(tabl)
source |
table

Creates new table made up of keys from `tabl`.

Arguments

value (table)
the table to inspect.

Returns

(table)
returns new table with keys of `tabl`.

Examples

			
_:keys({'a', 'b', 'c'})
-- {1, 2, 3}
			
_:keys({a=1, b=2, c=3})
-- {"a", "b", "c"}
			
			
    _:map(tabl, iteratee)
source |
table

Creates new table executing `iteratee` on every element of `tabl`.

Arguments

value (table)
the table to inspect.
iteratee (function)
function invoked on every element.

Returns

(table)
returns new table with updated values.

Examples

			
_:map({'a', 'b', 'c'}, string.upper)
-- {"A", "B", "C"}
			
_:map({a='x', b='y', c=2, d='z'}, 'isString')
-- {a=true, b=true, c=false, d=true}
			
			
    _:merge(...)
source |
table

Creates new table merging from left to right.

Overwritting will occur when existing key found.

Arguments

... (table)
series of tables to merge.

Returns

(table)
returns new table with all tables merged.

Examples

			
_:merge({1, 2, 3, 4}, {2, 3, 4, 5})
-- {1, 2, 3, 4, 2, 3, 4, 5}
			
_:merge({a=1, b=2, 3, 4}, {c=2, b=3, 4, 5})
-- {3, 4, 4, 5, a=1, b=3, c=2}
			
			
    _:resize(tabl, size)
source |
table

Creates copy of `tabl`, resized to `size`.

Arguments

tabl (table)
the table to inspect
size (number)
size of new table.

Returns

(table)
returns newly sized table.

Examples

			
_:resize({'a', 'b', 'c', 'd'}, 3)
-- {"a", "b", "c"}
			
_:resize({'a', 'b', 'c', 'd'}, 0)
-- {}
			
_:resize({'a', 'b', 'c', 'd'}, -1)
-- {"d"}
			
_:resize({'a', 'b', 'c', 'd'}, -3)
-- {"b", "c", "d"}
			
_:resize({'a', 'b', 'c', 'd'}, 5)
-- {"a", "b", "c", "d"}
			
			
    _:unique(tabl)
source |
table

Creates unique set of elements, dropping duplicate indices.

Arguments

tabl (table)
the table to inspect

Returns

(table)
returns new table without duplicates.

Examples

			
_:unique({'a', 'd', 'b', 'c', 'c', 'd'})
-- {"a", "d", "b", "c"}
			
_:unique({a = 1, b = 2, c = 2, d = 3})
-- {a = 1, b = 2, d = 3}
			
			
    _:values(tabl)
source |
table

Creates new table made up of values from `tabl`.

Arguments

value (table)
the table to inspect.

Returns

(table)
returns new table with values of `tabl`.

Examples

			
_:values({'a', 'b', 'c'})
-- {1, 2, 3}
			
_:values({a=1, b=2, c=3}
-- {1, 2, 3}
			
			
    _:color(...)
source |
color

Returns r, g, b color component values between [0, 1].

Default color palettes inspired by tailwindcss.

Arguments

... (mixed)
input to colorify.

Returns

(number)
returns r, g, b color values.

Examples

			
_:color('black')
-- 0 0 0
			
_:color('white')
-- 1 1 1
			
_:color('black', 'white')
-- 0.5 0.5 0.5
			
_:color('#F6AD55')
-- 0.96 0.67 0.33
			
_:color('green-500')
-- 0.28 0.73 0.47
			
			
    _:colorByHex(value)
source |
color

Returns r,g,b color values by hext `value`.

Default color palettes inspired by tailwindcss.

Arguments

value (string)
hex value that represents color value.

Returns

(number)
returns r, g, b color values.

Examples

			
_:colorByHex('#FED7D7')
-- 0.996078 0.843137 0.843137
			
_:colorByHex('#38A169')
-- 0.219608 0.631373 0.411765
			
			
    _:colorByName(value)
source |
color

Returns r,g,b color values by name `value`.

Default color palettes inspired by tailwindcss.

Arguments

value (string)
name hint that represents color value.

Returns

(number)
returns r, g, b color values.

Examples

			
_:colorByName('gray-100')
-- 0.968627 0.980392 0.988235
			
_:colorByName('red-800')
-- 0.607843 0.172549 0.172549
			
			
    _:assertArgument(name, var, expect, [default])
source |
assert

Assert `var` is am `expect`ed data type, and assigns `default` if `var` = nil.

Arguments

name (string)
field identifier for error response.
var (mixed)
variable to check.
expect (string)
expected data type.
default (mixed)
default value if `var` is nil, otherwise passed-in `var`.

Returns

(mixed)
throws error if `var` is nil.

Examples

			
_:assertArgument('name', 10, 'string')
-- throws error!
			
_:assertArgument('age', '23', 'number')
-- throws error!
			
_:assertArgument('name', 'John Doe', 'string')
-- no error
			
_:assertArgument('age', 23, 'number'
-- no error
			
_:assertArgument('pattern', nil, 'string', '%s+')
-- %s+
			
_:assertArgument('age', nil, 'number', 21)
-- 21
			
			
    _:assertEqualSize(name, [...])
source |

Assert if not all `...` values are the same length.

Arguments

name (string)
field identifier for error response.
... (mixed)
values to check.

Returns

(mixed)
throws error if values of `...` are of varying size.

Examples

			
_:assertEqualSize('name', {1, 2, 3, 4}, {1, 2, 3})
-- throws error!
			
_:assertEqualSize('name', 'long', 'short')
-- throws error!
			
_:assertEqualSize('name', {1, 2}, {1, 2}, {1, 2})
-- no error
			
_:assertEqualSize('name', 'test', 'long')
-- no error
			
			
    _:assertIsBoolean(name, var)
source |

Asserts `var` is not a boolean data type.

Arguments

name (string)
field identifier for error response.
var (mixed)
values to check.

Returns

(mixed)
throws error if `var` is not a boolean.

Examples

			
_:assertIsBoolean('test', 'true')
-- throws error!
			
_:assertIsBoolean('test', true)
-- no error
			
			
    _:assertIsNumber(name, var)
source |

Asserts `var` is not a number data type.

Arguments

name (string)
field identifier for error response.
var (mixed)
values to check.

Returns

(mixed)
throws error if `var` is not a number.

Examples

			
_:assertIsNumber('age', 'thirty-five')
-- throws error!
			
_:assertIsNumber('age', 35)
-- no error
			
			
    _:assertIsRegex(name, var)
source |

Arguments

name (string)
field identifier for error response.
var (mixed)
values to check.

Returns

(mixed)
throws error if `var` is not a regex pattern.

Examples

			
_:assertIsPattern('pattern', 'abc')
-- throws error!
			
_:assertIsPattern('pattern', '[^,%s+]')
-- no error
			
			
    _:assertIsRegexPattern(name, var)
source |

Assert if `var` is not a regular expression pattern.

Arguments

name (string)
field identifier for error response.
var (mixed)
values to check.

Returns

(mixed)
throws error if `var` is not a regex pattern.

Examples

			
_:assertIsRegexPattern('pattern', 'abc')
-- throws error!
			
_:assertIsRegexPattern('pattern', '[^,%s+]')
-- no error
			
			
    _:assertIsString(name, var)
source |

Assert if `var` is not a `string` data type.

Arguments

name (string)
field identifier for error response.
var (mixed)
values to check.

Returns

(mixed)
throws error if `var` is not a string.

Examples

			
_:assertIsString('age', 35)
-- throws error!
			
_:assertIsString('age', 'thirty-five')
-- no error
			
			
    _:assertIsTable(name, var)
source |

Assert if `var` is not a `table` data type.

Arguments

name (string)
field identifier for error response.
var (mixed)
values to check.

Returns

(mixed)
throws error if `var` is not a table.

Examples

			
_:assertIsTable('table', '1-2-3')
-- throws error!
			
_:assertIsTable('table', {'a','b','c'})
-- no error
			
			
    _:assertMaxSize(name, var, expect)
source |

Assert if `var` is > `expect` size.

Arguments

name (string)
field identifier for error response.
var (mixed)
values to check.
expect (number)
minimum size expected.

Returns

(mixed)
throws error if `var` is > `expect` size.

Examples

			
_:assertMaxSize('age', 22, 21)
-- throws error!
			
_:assertMaxSize('age', 21, 21)
-- no error
			
_:assertMaxSize('age', 20, 21)
-- no error
			
			
    _:assertMinSize(name, var, expect)
source |

Assert if `var` is < `expect` size.

Arguments

name (string)
field identifier for error response.
var (mixed)
values to check.
expect (number)
maxiumum size expected.

Returns

(mixed)
throws error if `var` is < `expect` size.

Examples

			
_:assertMinSize('age', 20, 21)
-- throws error!
			
_:assertMinSize('age', 21, 21)
-- no error
			
_:assertMinSize('age', 22, 21)
-- no error
			
			
    _:assertNotNil(name, var)
source |

Assert if `var` is nil.

Arguments

name (string)
field identifier for error response.
var (mixed)
values to check.

Returns

(mixed)
throws error if `var` is nil.

Examples

			
_:assertNotNil('value', 'not-nil')
-- throws error!
			
_:assertNotNil('value', nil)
-- no error
			
			
    _:assertNotZero(name, var)
source |

Assert if `var` is 0.

Arguments

name (string)
field identifier for error response.
var (mixed)
values to check.

Returns

(mixed)
throws error if `var` is 0.

Examples

			
_:assertNotZero('value', 0)
-- throws error!
			
_:assertNotZero('value', 10)
-- no error