4.4.8 • Published 3 years ago

jsinterpret v4.4.8

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

jsinterpret

A JavaScript interpreter inside of NodeJS.

Usage

NodeJS

First, use this:

npm install jsinterpret

Then, if you already have NodeJS installed, run npm init -y and create index.js.

Contents of index.js:

var jsinterpret=require('jsinterpret');

jsinterpret.interpret("console.log('Hello World!');");

To require() a package, use jsinterpret.addPackage(packageName) before any script, or install it in your machine. Example:

var jsinterpret=require('jsinterpret');

jsinterpret.addPackage("chalk")

jsinterpret.interpret(`const chalk=require('chalk'); 
console.log(chalk.blue('Hello World!'));`, function(e){
  console.log(e);
});

If you wanna use it for another reason instead of logging it in the console, use this:

var jsinterpret=require('jsinterpret');

jsinterpret.interpret("console.log('Hello World!')", function(result){
alert(result);
});

Note: DO NOT USE CALLBACK IF YOU ARE TRYING TO LOG A MESSAGE, BECAUSE IT WILL GIVE AN ERROR. Instead, if you are trying to log a message, only use the code and not the callback.

Browser

First, get the script from a CDN

<script src="https://cdn.jsdelivr.net/gh/Unzor/jsinterpret/browser/jsinterpret_browser.min.js"></script>

or download it. Then, use it like this:

var jsinterpret=new JSInterpret();
jsinterpret.interpret("console.log('Hello World!')");

If you wanna use it for another reason instead of logging it in the console, use this:

var jsinterpret=new JSInterpret();
jsinterpret.interpret("console.log('Hello World!')", function(result){
alert(result);
});

Note: DO NOT USE CALLBACK IF YOU ARE TRYING TO LOG A MESSAGE, BECAUSE IT WILL GIVE AN ERROR. Instead, if you are trying to log a message, only use the code and not the callback.

You can also require() the VM module in the interpreter.

4.4.8

3 years ago

4.4.7

3 years ago

4.4.6

3 years ago

4.4.5

3 years ago

4.4.4

3 years ago

4.4.1

3 years ago

4.4.0

3 years ago

4.4.3

3 years ago

4.4.2

3 years ago

4.0.1

3 years ago

4.3.0

3 years ago

4.1.2

3 years ago

4.2.0

3 years ago

4.1.1

3 years ago

4.0.0

3 years ago

3.0.0

3 years ago

2.0.0

3 years ago

1.0.0

3 years ago