mevento 1.0.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,24 +1,59 @@
1
1
  # Mevento
2
2
 
3
- This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.1.0.
3
+ Mevento is a tiny VM one single file that handles `MEvento code` executions inside JS engine. `MEvento` is simple programming language that allows developers exposing an app host function, that way they have the ability to dynamically execute simple script that call host function.
4
4
 
5
- ## Code scaffolding
5
+ The VM uses a AST Walker to execute MEvento script, so of course the performace is not its concern a lot.
6
6
 
7
- Run `ng generate component component-name --project mevento` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project mevento`.
8
- > Note: Don't forget to add `--project mevento` or else it will be added to the default project in your `angular.json` file.
7
+ ## MEvento code syntax
8
+ Syntaxically MEvento is a c-like language, but very limited: no function declaration, no class, just assignation, function call and conditional check.
9
9
 
10
- ## Build
10
+ ```js
11
+ a = 12
12
+ a = 23
13
+ b = functon1()
14
+ c = function2()
15
+ d = a + b
16
+ if(a == b) {
17
+ log('a = b')
18
+ } else {
19
+ log("a != b")
20
+ }
21
+ ```
11
22
 
12
- Run `ng build mevento` to build the project. The build artifacts will be stored in the `dist/` directory.
23
+ ## How to use
24
+ The host application can expose functions through Mevento VM that way:
25
+ ```ts
26
+ import {MEvento} from 'mevento';
27
+ MEvento.register('log', (args) => console.log); // exposes console.log through MEvento as log function
28
+ MEvento.register('cos2', (args) => Math.cos);
29
+ ```
13
30
 
14
- ## Publishing
31
+ Let's assume you want to execute a `MEvento code`:
15
32
 
16
- After building your library with `ng build mevento`, go to the dist folder `cd dist/mevento` and run `npm publish`.
33
+ ```ts
34
+ import {MEvento} from 'mevento';
17
35
 
18
- ## Running unit tests
36
+ const mevento = MEvento.newInstance();
19
37
 
20
- Run `ng test mevento` to execute the unit tests via [Karma](https://karma-runner.github.io).
38
+ mevento.execute(`log("molo")`)
21
39
 
22
- ## Further help
40
+ ```
41
+
42
+ `MEvento` instance execution is syncrhrone, that's to say, if you wan to consume `async` function exposed through Mevento, you nee to use `MEventoAsync` instead.
43
+
44
+
45
+ ```ts
46
+ import {MEvento} from 'mevento';
47
+
48
+ MEvento.register('async', async (args) => await asyncF(args[0]));
49
+ const mevento = MEventoAsync.newInstance();
50
+
51
+ await mevento.execute(`async("molo")`)
52
+
53
+ ```
54
+ `execute` method on `MEventoAsync` instance return a `Promise`.
55
+
56
+
57
+ ## Notes
58
+ MEvento does not have scope variables, all variables are visible everywhere.
23
59
 
24
- To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.