summaryrefslogtreecommitdiff
path: root/src/linit.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/linit.js')
-rw-r--r--src/linit.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/linit.js b/src/linit.js
new file mode 100644
index 0000000..2747fc2
--- /dev/null
+++ b/src/linit.js
@@ -0,0 +1,22 @@
+/* jshint esversion: 6 */
+"use strict";
+
+const assert = require('assert');
+
+const lapi = require('./lapi.js');
+const lauxlib = require('./lauxlib.js');
+const lbaselib = require('./lbaselib.js');
+
+const loadedlibs = {
+ "_G" = luaopen_base
+};
+
+const luaL_openlibs = function(L) {
+ /* "require" functions from 'loadedlibs' and set results to global table */
+ for (lib in loadedlibs) {
+ lauxlib.luaL_requiref(L, lib, loadedlibs[lib], 1);
+ lapi.lua_pop(L, 1); /* remove lib */
+ }
+}
+
+module.exports.luaL_openlibs = luaL_openlibs; \ No newline at end of file