Skip to content

Commit 2ad0207

Browse files
committed
docs(README): update example code
1 parent 30f2a2a commit 2ad0207

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ npm install module-from-string
1919
const { requireFromString, importFromString } = require('module-from-string')
2020

2121
requireFromString("module.exports = 'hi'") // => 'hi'
22-
requireFromString("exports.salute = 'hi'") // => { salute: 'hi' }
22+
requireFromString("exports.greet = 'hi'") // => { greet: 'hi' }
2323

2424
;(async () => {
2525
await importFromString("export default 'hi'" ) // => { default: 'hi' }
26-
await importFromString("export const salute = 'hi'") // => { salute: 'hi' }
26+
await importFromString("export const greet = 'hi'") // => { greet: 'hi' }
2727
})()
2828
```
2929

@@ -82,12 +82,12 @@ importFromStringSync({
8282
Function `importFromString` and `importFromStringSync` use esbuild to transform ES Module syntax to CommonJS. So it can do much more by providing transform options to esbuild. See [esbuild Transform API](https://esbuild.github.io/api/#transform-api) for documentation.
8383

8484
```js
85-
const { salute } = importFromStringSync({
86-
code: "export const salute: () => string = () => 'hi'",
85+
const { greet } = importFromStringSync({
86+
code: "export const greet: () => string = () => 'hi'",
8787
transformOptions: { loader: 'ts' }
8888
})
8989

90-
salute() // => 'hi'
90+
greet() // => 'hi'
9191
```
9292

9393
## License

0 commit comments

Comments
 (0)