summaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-15 14:57:13 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-15 14:57:13 +1100
commite0e5d05626fcd6cb4622abcaae9fc951d9ae91b1 (patch)
tree49531b2a69c166ad193adddf50edbadb5e1a91a1 /src/lapi.js
parent6099ba186c38c854332ec483edd6cbca3cf94871 (diff)
parent8249248f80467f1660509a30623f40bb9ff1eba7 (diff)
downloadfengari-e0e5d05626fcd6cb4622abcaae9fc951d9ae91b1.tar.gz
fengari-e0e5d05626fcd6cb4622abcaae9fc951d9ae91b1.tar.bz2
fengari-e0e5d05626fcd6cb4622abcaae9fc951d9ae91b1.zip
Merge branch 'Uint8Array'
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/lapi.js b/src/lapi.js
index afa94ce..111735f 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -672,19 +672,8 @@ const lua_toljsstring = function(L, idx) {
const lua_tojsstring = lua_toljsstring;
const lua_todataview = function(L, idx) {
- let o = index2addr(L, idx);
-
- if (!o.ttisstring()) {
- if (!lvm.cvt2str(o)) { /* not convertible? */
- return null;
- }
- lobject.luaO_tostring(L, o);
- }
-
- let dv = new DataView(new ArrayBuffer(o.vslen()));
- o.svalue().forEach((e, i) => dv.setUint8(i, e, true));
-
- return dv;
+ let u8 = lua_tolstring(L, idx);
+ return new DataView(u8.buffer, u8.byteOffset, u8.byteLength);
};
const lua_rawlen = function(L, idx) {