Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jrainlau/canjs
CanJS is a javascript interpreter, which can run JS code in JS.
https://github.com/jrainlau/canjs
frontend javascript javascript-interpreter
Last synced: 3 days ago
JSON representation
CanJS is a javascript interpreter, which can run JS code in JS.
- Host: GitHub
- URL: https://github.com/jrainlau/canjs
- Owner: jrainlau
- License: mit
- Created: 2018-11-30T02:00:49.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-23T06:53:56.000Z (over 4 years ago)
- Last Synced: 2024-08-02T07:01:46.035Z (3 months ago)
- Topics: frontend, javascript, javascript-interpreter
- Language: JavaScript
- Homepage: https://codepen.io/jrainlau/pen/YRgQXo
- Size: 222 KB
- Stars: 338
- Watchers: 10
- Forks: 63
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CanJS
`CanJS` is a javascript interpreter, which can run JS code in JS.
Relate article: [《
前端与编译原理——用JS写一个JS解释器》](http://sfau.lt/b5bkvoY)## Install
``` sh
git clone https://github.com/jrainlau/canjs.git
```## Usage
It's fine to run the JS code in string directly.```javascript
const Canjs = require('./dist/index.js')new Canjs(`
console.log('Hello World!')
`).run()
````CanJS` uses ES5 standard library, but you can also provide custom variables to it:
```javascript
const Canjs = require('./dist/index.js')const wx = {
name: 'wx'
}new Canjs(`
console.log(wx.name)
`, { wx }).run()
```## License
MIT