Copper OS

A operating system for computercraft and what goes with it.

View on GitHub

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

Creates a new list

Adds a value to the beginning of the list

Adds a value to the end of the list

Removes and returns the first value of the list

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"}