summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-09-12 10:00:04 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-09-13 09:42:57 +0200
commit9d6c4a49e0b6c845bc3fdeb4959377ca42e56832 (patch)
treeea84003a0a9c5a94ed9865d9471c2c6838eb190e /README.md
parent2c3dba7d0c37b1a2ffbc09906dc9d309e8f4bcf3 (diff)
downloadfengari-9d6c4a49e0b6c845bc3fdeb4959377ca42e56832.tar.gz
fengari-9d6c4a49e0b6c845bc3fdeb4959377ca42e56832.tar.bz2
fengari-9d6c4a49e0b6c845bc3fdeb4959377ca42e56832.zip
README.md: added section about using the JS API
Diffstat (limited to 'README.md')
-rw-r--r--README.md26
1 files changed, 24 insertions, 2 deletions
diff --git a/README.md b/README.md
index 391be3f..0d10e5f 100644
--- a/README.md
+++ b/README.md
@@ -11,9 +11,31 @@
🐺 φεγγάρι - The Lua VM written in JS ES6 for Node and the browser
-## Getting started in the browser
+This repository contains the core fengari code (which is a port of the Lua C library) which includes parser, virtual machine and base libraries.
+However it is rare to use this repository directly.
+
+- To use fengari in a web browser as easily as you might use JavaScript, see [fengari-web](https://github.com/fengari-lua/fengari-web)
+- [fengari-interop](https://github.com/fengari-lua/fengari-interop) is a lua library that makes interoperating with JavaScript objects simple, it is already included in fengari-web.
+- For a clone of the `lua` command line tool, but running under node.js, see [fengari-node-cli](https://github.com/fengari-lua/fengari-node-cli)
+
+### The JS API
+
+Once you've loaded fengari, you can use the JS API:
+
+```javascript
+const lua = fengari.lua;
+const lauxlib = fengari.lauxlib;
+const lualib = fengari.lualib;
+
+const L = lauxlib.luaL_newstate();
+
+lualib.luaL_openlibs(L);
+
+lua.lua_pushliteral(L, "hello world!");
+```
+
+The JS API is exactly the same as the C API so `fengari.lua` exposes the same constants and functions as `lua.h`, `fengari.lauxlib` the same as `lauxlib.h` and `fengari.lualib` the same as `lualib.h`. If you're unfamiliar with the C API, you can take a look at [the manual](http://www.lua.org/manual/5.3/manual.html#4).
-Fengari is not released yet but you can experiment with it in the browser by following the instructions of the [fengari-web](https://github.com/fengari-lua/fengari-web) repository.
## Semantics