How to run JSPython interpreterInstall JS Python Interpreter#npm i jspython-interpreterCopyHow to use JS Python Interpreter#ECMAScript module#import { jsPython } from 'jspython-interpreter';CopyCommonJS module#const jsPython = require('jspython-interpreter').jsPython;CopyAppend <script> in html#<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/jspython-interpreter/dist/jspython-interpreter.min.js"></script> <script>const jsPython = window.jspython.jsPython</script>CopyCreate interpreter and evaluate script.#const script = ` x = 2 + 3 x`;const interpreter = jsPython();interpreter.evaluate(script).then(res => { consoe.log(res); // 5})CopyExpose functions for JSPython import#Install needed modules localy using npm install moduleName command.#Register package loader function to use js libraries in your script.#In browser app#import * as papaparse from 'papaparse';import * as dataPipe from 'datapipe-js'; const AVAILABLE_PACKAGES = { papaparse, 'datapipe-js': dataPipe}; interpreter.registerPackagesLoader((packageName) => { return AVAILABLE_PACKAGES[packageName];}); CopyIn NodeJS#interpreter.registerPackagesLoader((packageName) => { return require(packageName);});CopyImport js libraries in script#import axios // import libraryfrom fs import readFileSync as rfs, writeFileSync // import only methods from libraryimport json5 as JSON5 // use as to provide appropriate name for lib.res = axios.get("data/url")CopyRegister to the global scope#Make custom function available in script.#interpreter.addFunction('greeting', (name) => { return 'Hello ' + name + '!';}); await interpreter.evaluate('greeting("John")') // Hello John.CopyMake object availabel in script#interpreter.assignGlobalContext({ method1: () => 1, prop1: 2})const script = ` v = method1() + prop1 v`await interpreter.evaluate(script) // 3.CopyProvide evaluation context#const script = ` v = prop1 + prop2 v`await interpreter.evaluate(script, {prop1: 3, prop2: -2}) // 1Copy