From c760da2581a144ca120b07c52963e1d422f725f1 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Mon, 6 Mar 2017 11:19:25 +0100 Subject: string.reverse --- src/lstrlib.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') 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 }; -- cgit v1.2.3-70-g09d2