@@ -5,24 +5,20 @@ The Lua runtime for Node.js.
55## Usage
66
77``` js
8- const { doFile , doString } = require ( ' do-lua' ) ;
8+ import { doFile , doString } from ' do-lua' ;
99
1010const program = `
1111print("Hello, World!")
1212` ;
1313
14- doString (program).then (() => {
15- console .log (" Done doString" );
16- })
17- doFile (' examples/test1.lua' ).then (() => {
18- console .log (" Done doFile" );
19- })
14+ await doString (program);
15+ await doFile (' examples/test1.lua' );
2016```
2117
2218You cannot use ` this ` in functions of the passing table on ` loadProgram ` . Use arrow function instead of that.
2319
2420``` js
25- const { loadProgram } = require ( ' do-lua' ) ;
21+ import { loadProgram } from ' do-lua' ;
2622
2723const state = loadProgram (`
2824obj.ox = 50;
@@ -37,8 +33,8 @@ const table = {
3733};
3834state .setTable (' obj' , table);
3935
40- state . run (). then (( G ) => { // G is global table exclusive "package" and "_G"
41- console . log ( " ox: " , G . obj . ox ); // 50
42- console .log (" Message : " , message ); // Hello, World!
43- });
36+ // G is global table exclusive "package" and "_G"
37+ const G = await state . run ()
38+ console .log (" ox : " , G . obj . ox ); // 50
39+ console . log ( " Message: " , message); // Hello, World!
4440```
0 commit comments