CopperUtility
CopperUtility is a collection of utility functions for various Copper OS libraries.
Classes
List
first |
The index of the first element in the list |
last |
The index of the last element in the list |
- new(): List
Creates a new list
- pushLeft(
value
: any)
Adds a value to the beginning of the list
- pushRight(
value
: any)
Adds a value to the end of the list
- popLeft() : any
Removes and returns the first value of the list
- popRight() : any
Removes and returns the last value of the list
Functions
Splits a string into a table of strings based on a separator.
-- String Splitting Example
local utility = require "CopperUtility"
utility.splitString("string, seperated, by, seperators", ", ")
-->> {"string", "seperated", "by", "seperators"}
Split a string into chunks of a given size.
-- Split by Chunk Example
local utility = require "CopperUtility"
utility.splitByChunk("Hello, World!", 3)
-->> {"Hel", "lo,", " Wo", "rld", "!"}
Removes whitespaces from the start and end of a string
-- String Trimming Example
local utility = require "CopperUtility"
utility.trimString(" string with spaces ")
-->> "string with spaces"
Concatenates two tables. The first table is modified.
-- Table Concatenation Example
local utility = require "CopperUtility"
local t1 = {"a", "b", "c"}
local t2 = {"d", "e", "f"}
utility.concatTables(t1, t2)
-->> {"a", "b", "c", "d", "e", "f"}