diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-03-06 11:19:25 +0100 |
---|---|---|
committer | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-03-06 11:19:25 +0100 |
commit | c760da2581a144ca120b07c52963e1d422f725f1 (patch) | |
tree | c3594947d848ea536ba84a9148215375d9126d0d /src | |
parent | 9d78ee372d9d4db601098d4d302df48159d7b176 (diff) | |
download | fengari-c760da2581a144ca120b07c52963e1d422f725f1.tar.gz fengari-c760da2581a144ca120b07c52963e1d422f725f1.tar.bz2 fengari-c760da2581a144ca120b07c52963e1d422f725f1.zip |
string.reverse
Diffstat (limited to 'src')
-rw-r--r-- | src/lstrlib.js | 6 |
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 }; |