summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--misc/freeswitch/scripts/common/str.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/common/str.lua b/misc/freeswitch/scripts/common/str.lua
index 72ff388..541199f 100644
--- a/misc/freeswitch/scripts/common/str.lua
+++ b/misc/freeswitch/scripts/common/str.lua
@@ -146,3 +146,37 @@ end
function blank(value)
return (value == nil or to_s(value) == '');
end
+
+-- concatenate string to buffer
+function append(buffer, value, separator, prefix, suffix)
+ separator = separator or '';
+ prefix = prefix or '';
+ suffix = suffix or '';
+ if buffer ~= '' then
+ buffer = buffer .. separator .. prefix .. value .. suffix;
+ else
+ buffer = prefix .. value .. suffix;
+ end
+
+ return buffer;
+end
+
+-- concatenate array values to string
+function concat(array, separator, prefix, suffix)
+ local buffer = '';
+ for key, value in pairs(array) do
+ buffer = append(buffer, value, separator, prefix, suffix);
+ end
+
+ return buffer;
+end
+
+-- concatenate array keys to string
+function concat_keys(array, separator, prefix, suffix)
+ local buffer = '';
+ for key, value in pairs(array) do
+ buffer = append(buffer, key, separator, prefix, suffix);
+ end
+
+ return buffer;
+end