summaryrefslogtreecommitdiff
path: root/src/lstrlib.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lstrlib.js')
-rw-r--r--src/lstrlib.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index 11b266a..2f89777 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -25,6 +25,11 @@ const str_char = function(L) {
return 1;
};
+const str_reverse = function(L) {
+ lapi.lua_pushstring(L, lauxlib.luaL_checkstring(L, 1).split("").reverse().join(""));
+ return 1;
+};
+
const str_lower = function(L) {
lapi.lua_pushstring(L, lauxlib.luaL_checkstring(L, 1).toLowerCase());
return 1;
@@ -49,6 +54,7 @@ const strlib = {
"len": str_len,
"lower": str_lower,
"rep": str_rep,
+ "reverse": str_reverse,
"upper": str_upper
};