String
The string plugin exposes common string manipulation operations through Simorg vibrations. Each key maps to a dedicated string action function. Valid inputs produce a value and invalid inputs result in no vibration.
Functions
append
Concatenates array of strings.
("a","b","c") string.append ? // "abc"
Non-string array members result in no vibration.
("a",1) string.append ? // no vibration
- Type: ERROR
- Code: INVALID_ARGUMENT_TYPE
- Message: append expects all arguments to be strings.
at
Returns character at index.
("hello",1) string.at ? // "e"
Non-numeric index results in no vibration.
("hello","1") string.at ? // no vibration
- Type: ERROR
- Code: INVALID_INDEX_TYPE
- Message: at expects a numeric index.
format
Replaces {} placeholders with provided values.
("hello {}", "world") string.format ? // "hello world"
Placeholder/value count mismatch results in no vibration.
("{} {}", "x") string.format ? // no vibration
- Type: ERROR
- Code: FORMAT_ARG_MISMATCH
- Message: Number of placeholders must match argument count.
back
Returns last character of a string.
"abc" string.back ? // "c"
Non-string input results in no vibration.
12 string.back ? // no vibration
- Type: ERROR
- Code: INVALID_ARGUMENT_TYPE
- Message: back expects a string.
erase
Erases count chars starting at index.
("abcdef",2,2) string.erase ? // "abef"
Invalid index types result in no vibration.
("abcdef","2",2) string.erase ? // no vibration
- Type: ERROR
- Code: INVALID_INDEX_TYPE
- Message: erase expects numeric index and count.
front
Returns first character of a string.
"abc" string.front ? // "a"
Non-string input results in no vibration.
true string.front ? // no vibration
- Type: ERROR
- Code: INVALID_ARGUMENT_TYPE
- Message: front expects a string.
insert
Inserts string at index.
("ac","b",1) string.insert ? // "abc"
Invalid index type results in no vibration.
("ac","b","1") string.insert ? // no vibration
- Type: ERROR
- Code: INVALID_INDEX_TYPE
- Message: insert expects numeric position.
popBack
Removes last character.
"abc" string.popBack ? // "ab"
Non-string input results in no vibration.
0 string.popBack ? // no vibration
- Type: ERROR
- Code: INVALID_ARGUMENT_TYPE
- Message: popBack expects a string.
pushBack
Appends one character from second arg.
("ab","c") string.pushBack ? // "abc"
Non-string args result in no vibration.
("ab",3) string.pushBack ? // no vibration
- Type: ERROR
- Code: INVALID_ARGUMENT_TYPE
- Message: pushBack expects string and character string.
replace
Replaces a substring at index with new string.
("hello","y",1,1) string.replace ? // "hyllo"
Invalid numeric args result in no vibration.
("hello","y","1",1) string.replace ? // no vibration
- Type: ERROR
- Code: INVALID_INDEX_TYPE
- Message: replace expects numeric position and length.
substr
Returns substring with start and length.
("hello",1,3) string.substr ? // "ell"
Invalid index args result in no vibration.
("hello",1,"3") string.substr ? // no vibration
- Type: ERROR
- Code: INVALID_INDEX_TYPE
- Message: substr expects numeric start and length.
compare
Lexicographically compares two strings.
("a","b") string.compare ? // -1
Non-string args result in no vibration.
("a",1) string.compare ? // no vibration
- Type: ERROR
- Code: INVALID_ARGUMENT_TYPE
- Message: compare expects two strings.
empty
Checks whether string is empty.
"" string.empty ? // true
Non-string input results in no vibration.
11 string.empty ? // no vibration
- Type: ERROR
- Code: INVALID_ARGUMENT_TYPE
- Message: empty expects a string.
length
Returns string length.
"hello" string.length ? // 5
Non-string input results in no vibration.
12 string.length ? // no vibration
- Type: ERROR
- Code: INVALID_ARGUMENT_TYPE
- Message: length expects a string.