Skip to content

Commit

Permalink
fix code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
pnedelko committed Jul 4, 2023
1 parent 137d834 commit a88cfe7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ Use code is very simple, just do following:

```JavaScript
async function run(msg, cfg, snapshot) {
console.log('Incoming message is %s', JSON.stringify(msg));
const body = { result : 'Hello world!' };
this.logger.info('Incoming message is %j', msg);
const data = { result : 'Hello world!' };
// You can emit as many data messages as required
await this.emit('data', { body });
console.log('Execution finished');
await this.emit('data', { data });
this.logger.info('Execution finished');
}
```

Expand All @@ -40,7 +40,7 @@ of your function, it will be automatically emitted as data.

### Doing complex data transformation

[JSONata](http://jsonata.org/) is great however sometimes it's easier to do things in JavaScript, if you want to transorm
[JSONata](http://jsonata.org/) is great however sometimes it's easier to do things in JavaScript, if you want to transform
an incoming message with code, just use following sample:

```JavaScript
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"viewClass": "CodeFieldView",
"label": "Code",
"required": true,
"default": "// Please note only Node.js code is supported here\nasync function run(msg, cfg, snapshot) {\n\tthis.logger.info('Incoming message is %s', JSON.stringify(msg));\n\tconst body = { result : 'Hello world!' };\n\t// You can emit as many data messages as required\n\tawait this.emit('data', { body });\n\tthis.logger.info('Execution finished');\n}"
"default": "// Please note only Node.js code is supported here\nasync function run(msg, cfg, snapshot) {\n\tthis.logger.info('Incoming message is %j', msg);\n\tconst data = { result : 'Hello world!' };\n\t// You can emit as many data messages as required\n\tawait this.emit('data', { data });\n\tthis.logger.info('Execution finished');\n}"
}
},
"actions": {
Expand Down

0 comments on commit a88cfe7

Please sign in to comment.