summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lstrlib.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index e31c0fe..6cb8df9 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -595,7 +595,12 @@ const str_pack = function(L) {
};
const str_reverse = function(L) {
- lua.lua_pushstring(L, lauxlib.luaL_checkstring(L, 1).slice(0).reverse());
+ let s = lauxlib.luaL_checkstring(L, 1);
+ let l = s.length;
+ let r = new Uint8Array(l);
+ for (let i=0; i<l; i++)
+ r[i] = s[l-1-i];
+ lua.lua_pushstring(L, r);
return 1;
};