Skip to content

Commit 8b54c14

Browse files
committed
doc(readme): update example
1 parent 9a24739 commit 8b54c14

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,19 @@ compiler.hide('console', 'Math')
100100
code({num: 1.8}) // throws an error, console and Math are undefined
101101
```
102102

103-
Context variables are always favored over global ones, when both are present (with the same name).
103+
Context variables are always favored over global ones when both are present (with the same name).
104104

105105
## Example
106106

107107
```js
108108
const compiler = require('@risingstack/nx-compile')
109109

110-
const context = {name: 'nx-compile', version: '4.0.0'}
111-
const expression = compiler.compileExpression('name + version)', sandbox)
110+
compiler.expose('console')
111+
const context = {name: 'nx-compile'}
112+
const tempVars = {version: '4.2.0'}
113+
const code = compiler.compileCode('console.log(name + version)')
112114

113-
// outputs 'nx-compile4.0.0' to console
114-
console.log(expression(context))
115+
code(context, tempVars) // outputs 'nx-compile4.2.0' to console
115116
```
116117

117118
## Contributions

0 commit comments

Comments
 (0)