Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/retejs/code-plugin
https://github.com/retejs/code-plugin
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/retejs/code-plugin
- Owner: retejs
- Created: 2018-10-06T21:35:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-20T16:25:42.000Z (over 5 years ago)
- Last Synced: 2024-10-30T00:54:46.060Z (21 days ago)
- Language: JavaScript
- Size: 62.5 KB
- Stars: 8
- Watchers: 3
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Code
====
#### Rete.js plugin```js
import CodePlugin from 'rete-code-plugin';class NumComponent extends Rete.Component {
// ...code(node, inputs, add) { // 'node' param is similar to worker's "node"
// "inputs" contains variables name
add('console.log("hello!")') // add code line
add('num', node.data.num); // add variable with value "node.data.num"
}
}const sourceCode = await CodePlugin.generate(engine, editor.toJSON());
```For example, the scheme with such nodes
```
Number 6
\ Add 11 -- Add 16
/ /
Number 5 ---------
```will generate the next `sourceCode`
```js
console.log("hello!");
const number1num = 5;
console.log("hello!");
const number3num = 6;
const add4num = number3num + number1num;
const add2num = add4num + number1num;
```