2.0.5 • Published 2 months ago

mevento v2.0.5

Weekly downloads
-
License
-
Repository
-
Last release
2 months ago

Mevento

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.

The VM uses a AST Walker to execute MEvento script, so of course the performace is not its concern a lot.

MEvento code syntax

Syntaxically MEvento is a c-like language, but very limited: no function declaration, no class, just assignation, function call and conditional check.

a = 12
a = 23
b = functon1()
c = function2()
d = a + b
if(a == b) {
    log('a = b')
} else {
    log("a != b")
}

How to use

The host application can expose functions through Mevento VM that way:

import {MEvento} from 'mevento';
MEvento.register('log', (args) => console.log); // exposes console.log through MEvento as log function
MEvento.register('cos2', (args) => Math.cos);

Let's assume you want to execute a MEvento code:

import {MEvento} from 'mevento';

const mevento = MEvento.newInstance();

mevento.execute(`log("molo")`)

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.

import {MEvento} from 'mevento';

MEvento.register('async', async (args) => await asyncF(args[0]));
const mevento = MEventoAsync.newInstance();

await mevento.execute(`async("molo")`)

execute method on MEventoAsync instance return a Promise.

Notes

MEvento does not have scope variables, all variables are visible everywhere.

2.0.5

2 months ago

2.0.3

10 months ago

2.0.4

9 months ago

2.0.1

12 months ago

2.0.0

12 months ago

1.9.9

1 year ago

1.9.8

1 year ago

1.9.6

1 year ago

1.9.5

1 year ago

1.9.4

1 year ago

1.9.1

1 year ago

1.9.0

1 year ago

1.8.0

1 year ago

1.4.0

1 year ago

1.2.2

1 year ago

1.2.0

1 year ago

1.0.0

1 year ago