vendor.allen module

  • Release: $Id: Allen.lua,v? ??/??/???? Roland_Yonaba$
  • Author: Roland Yonaba

Functions

_.byteAt(str, i) Returns the Ascii code of the i-th character in the given string
_.bytes(str) Returns an array of Ascii codes for a given set of characters
_.camelize(str) Converts a given string (underscored or dasherized) into camelized style
_.capitalize(str, i, j) Capitalizes substring i to j in a given string
Aliased as cap..
_.capitalizeFirst(str) Capitalizes the first character of a given string.
_.capitalizesEach(str) Capitalizes each word in a given string.
_.chars(str) Converts a given string to an array of chars
Aliased as explode..
_.chop(str, n) Converts a string to an array of n characters
Aliased as split..
_.clean(str, pat) Clears all special characters or characters matching a given pattern inside a given string
Aliased as trim..
_.count(str, sub) Returns the number of substring occurences in a given string
_.dasherize(str) Converts a given string (unerscored or camelized) into dasherized style
_.endsWith(str, ends) Tests if a given string ends with a given pattern
_.escape(str) Escapes any magic character in agiven string
Aliased as esc..
_.humanize(str) Converts a given string (underscored, humanized, dasherized or camelized) into a human-readable form
_.import([context[, noConflict]]) Imports library functions inside a given context or the global environment.
_.includes(str, sub) Tests if a given substring is included in a given string
_.index(str) Indexes a string like an array, returning a character.
_.insert(str, substring[, index]) Inserts a given substring at index position in a given string
_.is(var, expectedType) Checks if the given input is has a known Lua type or matches an expected type.
_.isAlpha(str) Checks if a given string contains only alphabetic characters
_.isBlank(str) Tests if a given string contain any alphanumeric character
_.isEmail(str) Checks if a given string matches an email address syntax.
_.isIdentifier(str) Tests if a given substring is a valid Lua identifier for a variable
Aliased as isIden and isVarName..
_.isLowerCase(str) Tests if a given string contains only upper-case characters.
_.isLuaKeyword(str) Checks if the given string is a Lua reserved keyword.
_.isNumeric(str) Checks if a given string contains only digits.
_.isToken(str) Tests if a given substring is a known Lua token (operator).
_.isUpperCase(str) Tests if a given string contains only lower-case characters.
_.join(sep, ...) Returns a string composed of a concatenation of all given arguments, separated with a given separator
_.levenshtein(strA, strB) Returns the Levenshtein distance between two strings.
_.lines(str) Splits a given string in an array on the basis of end-lines characters (\n and/or \r).
_.lower(str, i, j) Lowers substring i to j in a given string
_.lowerFirst(str) Lowers the first character in a given string
_.lpad(str, length, padStr) Left-pads a given string
Aliased as rjust..
_.lrpad(str, length, padStr) Left and right padding for strings.
_.numberFormat(num[, decimals[, thousandSeparator[, decimalSeparator[, sign]]]]) Formats a given number to a string
_.pad(str, length, padStr, side) Pads a given string with characters
_.pre(str, n) Returns the predecessor of a given character.
_.quote(str) Returns a quoted string
_.rep(str[, count[, sep]]) Repeats a given string concatenated with a given separator count times.
_.rpad(str, length, padStr) Right-pads a given string
Aliased as ljust..
_.splice(str, index, howMany, substring) Replaces howMany characters after index position in a given string with a given substring
_.startsLowerCase(str) Tests if a given string starts with a lower-case character
Aliased as startsLower..
_.startsUpperCase(str) Tests if a given string starts with an upper-case character
Aliased as startsUpper..
_.startsWith(str, starts) Tests if a given string starts with a given pattern
_.statistics(str, pat) Returns a table listing counts for each match to a given pattern
Aliased as stats..
_.strLeft(str, pattern) Returns the substring before the first pattern occurence in a given string
_.strLeftBack(str, pattern) Returns the substring before the last pattern occurence in a given string
_.strRight(str, pattern) Returns the substring after the first pattern occurence in a given string
_.strRightBack(str, pattern) Returns the substring after the last pattern occurence in a given string
_.substitute(str, var) Substitutes any sequence matching ${var} or $var with a given value
Aliased as subst and interpolate..
_.succ(str, n) Returns the successor of a given character.
_.surround(str) Wraps a given string
_.swapCase(str, i, int) Swaps the case of each characters in substring i to j inside a given string
_.titleize(str) Title-izes a given string (each word beginning with a capitalized letter)
_.toSentence(an[, delimiter[, lastDelimiter]]) Converts an array of strings into a human-readable string
_.underscored(str) Converts a given string (camelized or dasherized) into underscored style
_.words(str) Converts a given string into an array of words

Functions

# _.byteAt(str, i)

Returns the Ascii code of the i-th character in the given string

Parameters: Returns:
  • (int) a number representing the Ascii code of the i-th char
# _.bytes(str)

Returns an array of Ascii codes for a given set of characters

Parameters: Returns:
  • (array) an array of ascii codes
# _.camelize(str)

Converts a given string (underscored or dasherized) into camelized style

Parameters: Returns:
# _.capitalize(str, i, j)

Capitalizes substring i to j in a given string
Aliased as cap..

Parameters:
  • str : (string) a string
  • i : (int) the starting index. Defaults to 1 if not given. Can be negative (counting from right to left)
  • j : (int) the ending index. Defaults to the string length if not given.
Returns:
  • (string) a substring of the given string
See also:
# _.capitalizeFirst(str)

Capitalizes the first character of a given string.


Aliased as capFirst.

Parameters: Returns:
# _.capitalizesEach(str)

Capitalizes each word in a given string.


Aliased as capEach and caps.

Parameters: Returns: See also:
# _.chars(str)

Converts a given string to an array of chars
Aliased as explode..

Parameters: Returns:
  • (array) an array of chars
See also:
# _.chop(str, n)

Converts a string to an array of n characters
Aliased as split..

Parameters:
  • str : (string) a string
  • n : (int) an integer. Defaults to 1 if not given.
Returns:
  • (array) an array of strings, each one having a length of n characters at least.
See also:
# _.clean(str, pat)

Clears all special characters or characters matching a given pattern inside a given string
Aliased as trim..

Parameters:
  • str : (string) a string
  • pat : (string) a pattern matching string to be cleaned from the original string. If not given, will clean non-alphanumeric characters.
Returns: See also:
# _.count(str, sub)

Returns the number of substring occurences in a given string

Parameters:
  • str : (string) a string
  • sub : (string) a substring or a pattern matching string
Returns:
  • (int) the expected count
# _.dasherize(str)

Converts a given string (unerscored or camelized) into dasherized style

Parameters: Returns:
# _.endsWith(str, ends)

Tests if a given string ends with a given pattern

Parameters:
  • str : (string) a string
  • ends : (string) a pattern or a string
Returns:
# _.escape(str)

Escapes any magic character in agiven string
Aliased as esc..

Parameters: Returns: See also:
# _.humanize(str)

Converts a given string (underscored, humanized, dasherized or camelized) into a human-readable form

Parameters: Returns:
# _.import([context[, noConflict]])

Imports library functions inside a given context or the global environment.

Parameters:
  • context : (table) a context. Defaults to _G (global environment) when not given. (optional)
  • noConflict : (boolean) Skips function import in case its key already exists in the given context (optional)
Returns:
  • (table) the passed-in context
# _.includes(str, sub)

Tests if a given substring is included in a given string

Parameters: Returns:
# _.index(str)

Indexes a string like an array, returning a character.


Aliased as charAt..

Parameters: Returns:
  • (int) i an index
See also:
# _.insert(str, substring[, index])

Inserts a given substring at index position in a given string

Parameters:
  • str : (string) a string
  • substring : (string) the substring to be inserted
  • index : (int) the insert position, defaults to the end of the string when not given (optional)
Returns:
# _.is(var, expectedType)

Checks if the given input is has a known Lua type or matches an expected type.

Parameters:
  • var : (value) some variable
  • expectedType : (string) an expected type for the passed-in variable. If not given, the function will check if the actual variable type is known to Lua.
Returns:
# _.isAlpha(str)

Checks if a given string contains only alphabetic characters

Parameters: Returns:
# _.isBlank(str)

Tests if a given string contain any alphanumeric character

Parameters:
  • str
Returns:
# _.isEmail(str)

Checks if a given string matches an email address syntax.

Not compliant with any RFC standards though.

Parameters: Returns:
# _.isIdentifier(str)

Tests if a given substring is a valid Lua identifier for a variable
Aliased as isIden and isVarName..

Parameters: Returns: See also:
# _.isLowerCase(str)

Tests if a given string contains only upper-case characters.


Aliased as isLower..

Parameters: Returns:
  • (bool) a boolean
See also:
# _.isLuaKeyword(str)

Checks if the given string is a Lua reserved keyword.


Aliased as isLuaKword and isReserved..

Parameters: Returns: See also:
# _.isNumeric(str)

Checks if a given string contains only digits.


Aliased as isNum..

Parameters: Returns: See also:
# _.isToken(str)

Tests if a given substring is a known Lua token (operator).


Aliased as isOperator and isOp..

Parameters: Returns: See also:
# _.isUpperCase(str)

Tests if a given string contains only lower-case characters.


Aliased as isUpper..

Parameters: Returns:
  • (bool) a boolean
See also:
# _.join(sep, ...)

Returns a string composed of a concatenation of all given arguments, separated with a given separator

Parameters:
  • sep : (string) a string separator
  • ... : (var_arg) a list of strings to be concatenated
Returns:
# _.levenshtein(strA, strB)

Returns the Levenshtein distance between two strings.

See Levenshtein Distance on Wikipedia

Parameters:
  • strA : (strng) a string
  • strB : (string) another string
Returns:
  • (int) an integer representing the distance between the two given strings
# _.lines(str)

Splits a given string in an array on the basis of end-lines characters (\n and/or \r).

Parameters: Returns:
  • (array) an array of string
# _.lower(str, i, j)

Lowers substring i to j in a given string

Parameters:
  • str : (string) a string
  • i : (int) the starting index. Defaults to 1 if not given. Can be negative (counting from right to left)
  • j : (int) the ending index. Default to string length if not given.
Returns:
# _.lowerFirst(str)

Lowers the first character in a given string

Parameters: Returns:
# _.lpad(str, length, padStr)

Left-pads a given string
Aliased as rjust..

Parameters:
  • str : (string) a string
  • length : (int) the final string length
  • padStr : (string) the padding string character
Returns:
# _.lrpad(str, length, padStr)

Left and right padding for strings.


Aliased as center..

Parameters:
  • str : (string) a string
  • length : (int) the final string length
  • padStr : (string) the padding string character
Returns:
# _.numberFormat(num[, decimals[, thousandSeparator[, decimalSeparator[, sign]]]])

Formats a given number to a string

Parameters:
  • num : (number) a number.
  • decimals : (int) the number of decimals after the whole part. Defaults to 0 when omitted. (optional)
  • thousandSeparator : (string) the symbol used to separate thousands. Defaults to , when not given. (optional)
  • decimalSeparator : (string) the symbol used to separate the whole part from the decimal part. Defaults to . when not given. (optional)
  • sign : (string) the string to be used to replace the minus symbol for negative numbers. Defaults to - when omitted. (optional)
Returns:
# _.pad(str, length, padStr, side)

Pads a given string with characters

Parameters:
  • str : (string) a string
  • length : (int) the final string length
  • padStr : (string) the padding string character
  • side : (string) the padding direction. Should be either ‘left’ (see lpad), ‘right’ (see rpad) or ‘both’ (see lrpad).
Returns:
# _.pre(str, n)

Returns the predecessor of a given character.

In case the input was a string of characters, returns a new string where each character is the predecessor of the character at the same position in the passed-in string

Parameters:
  • str : (string) a string
  • n : (int) the n-th predecessor of a character in the Ascii set
Returns:
# _.quote(str)

Returns a quoted string

Parameters: Returns:
# _.rep(str[, count[, sep]])

Repeats a given string concatenated with a given separator count times.

Parameters:
  • str : (string) a string
  • count : (int) the repetitions count. Defaults to 2 when not given. (optional)
  • sep : (string) a separator. Defaults to space character when not given. (optional)
Returns:
# _.rpad(str, length, padStr)

Right-pads a given string
Aliased as ljust..

Parameters:
  • str : (string) a string
  • length : (int) the final string length
  • padStr : (string) the padding string character
Returns:
# _.splice(str, index, howMany, substring)

Replaces howMany characters after index position in a given string with a given substring

Parameters:
  • str : (string) a string
  • index : (int) an index position in the string
  • howMany : (int) the number of characters to be removed after index.
  • substring : (string) the substring that will replace the removed sequence.
Returns:
# _.startsLowerCase(str)

Tests if a given string starts with a lower-case character
Aliased as startsLower..

Parameters: Returns: See also:
# _.startsUpperCase(str)

Tests if a given string starts with an upper-case character
Aliased as startsUpper..

Parameters: Returns: See also:
# _.startsWith(str, starts)

Tests if a given string starts with a given pattern

Parameters:
  • str : (string) a string
  • starts : (string) a pattern or a string
Returns:
# _.statistics(str, pat)

Returns a table listing counts for each match to a given pattern
Aliased as stats..

Parameters:
  • str : (string) a string
  • pat : (string) a pattern matching string
Returns: See also:
# _.strLeft(str, pattern)

Returns the substring before the first pattern occurence in a given string

Parameters:
  • str : (string) a string
  • pattern : (string) a pattern-matching string
Returns:
# _.strLeftBack(str, pattern)

Returns the substring before the last pattern occurence in a given string

Parameters:
  • str : (string) a string
  • pattern : (string) a pattern-matching string
Returns:
# _.strRight(str, pattern)

Returns the substring after the first pattern occurence in a given string

Parameters:
  • str : (string) a string
  • pattern : (string) a pattern-matching string
Returns:
# _.strRightBack(str, pattern)

Returns the substring after the last pattern occurence in a given string

Parameters:
  • str : (string) a string
  • pattern : (string) a pattern-matching string
Returns:
# _.substitute(str, var)

Substitutes any sequence matching ${var} or $var with a given value
Aliased as subst and interpolate..

Parameters:
  • str : (string) a string
  • var : (value) a value to be used to replace ${var} or $var occurences
Returns: See also:
# _.succ(str, n)

Returns the successor of a given character.

In case the input was a string of characters, returns a new string where each character is the successor of the character at the same position in the passed-in string

Parameters:
  • str : (string) a string
  • n : (int) the n-th successor of a character in the Ascii set
Returns:
# _.surround(str)

Wraps a given string

Parameters: Returns:
# _.swapCase(str, i, int)

Swaps the case of each characters in substring i to j inside a given string

Parameters:
  • str : (string) a string
  • i : (int) the starting index. Defaults to 1 if not given. Can be negative (counting from right to left)
  • int : j the ending index. Default to string length if not given
Returns:
# _.titleize(str)

Title-izes a given string (each word beginning with a capitalized letter)

Parameters: Returns:
# _.toSentence(an[, delimiter[, lastDelimiter]])

Converts an array of strings into a human-readable string

Parameters:
  • an : (array) array of values
  • delimiter : (string) a delimiter. Defaults to comma character when not given. (optional)
  • lastDelimiter : (string) the last delimiter to be used. Defaults to and when not given. (optional)
Returns:
# _.underscored(str)

Converts a given string (camelized or dasherized) into underscored style

Parameters: Returns:
# _.words(str)

Converts a given string into an array of words

Parameters: Returns:
  • (array) an array of string