https://github.com/robloach/chaiscript.js
JavaScript port of ChaiScript
https://github.com/robloach/chaiscript.js
chaiscript
Last synced: 28 days ago
JSON representation
JavaScript port of ChaiScript
- Host: GitHub
- URL: https://github.com/robloach/chaiscript.js
- Owner: RobLoach
- License: other
- Created: 2019-01-26T06:44:39.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-27T21:12:39.000Z (about 7 years ago)
- Last Synced: 2025-03-30T18:02:01.711Z (12 months ago)
- Topics: chaiscript
- Language: HTML
- Homepage: https://RobLoach.github.io/ChaiScript.js/
- Size: 1.33 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ChaiScript.js
JavaScript port of [ChaiScript](http://chaiscript.com), an easy to use embedded scripting language, powered through Emscripten.
## Node.js
``` bash
npm init
npm install chaiscript --save
```
``` javascript
// Load the ChaiScript module.
const chaiscript = require('chaiscript')
// Create the Chai instance.
const chai = new chaiscript.ChaiScript()
// Get some code to use.
const code = `
def hello(name) {
return "Hello " + name
}
var output = hello("Bob")
print(output)
`
// Run the code through the ChaiScript instance.
chai.eval(code)
// Make sure to clean up when you're done.
chai.delete()
```
## API
### `new chaiscript.ChaiScript()`
Create a new ChaiScript environment
### `.eval(string)`
Executes the given code.
### `.evalString(string)`
Executes the given code, and returns the output as a string.