Skip to content

Commit dc66801

Browse files
authored
Small corrections to Javascript section (#278)
* use `add.add`, not just `add`, in Node example in "Running a Component from JavaScript Applications (including the Browser)" section, what is exported from `./dist/transpiled/adder.js` is an `add` object and not a function. You can see this difference in the example application at https://github.com/bytecodealliance/jco/blob/b2e8641d15dbc25a1d68b66451ab670a47a963d5/examples/components/adder/run-transpiled.js * fix "AKA" on `reverse-string` I'm not 100% sure of this, but I think this full `example:string-reverse/reverse.reverse-string` path is meant to break down as: * package: `example:string-reverse` * interface: `reverse` * function name: `reverse-string` If so, then the first part should be `example:string-reverse` and not `example:reverse-string`
1 parent a3b4d15 commit dc66801

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

component-model/src/language-support/javascript.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ To use this component from [NodeJS][nodejs], you can write code like the followi
215215
```mjs
216216
import { add } from "./dist/transpiled/adder.js";
217217

218-
console.log("1 + 2 = " + add(1, 2));
218+
console.log("1 + 2 = " + add.add(1, 2));
219219
```
220220

221221
You can execute the JavaScript module with `node` directly:
@@ -281,7 +281,7 @@ As a slightly deeper crash course on [WIT][wit], here's what the above code desc
281281
- This WIT file corresponds to version `0.1.0` of `example:string-reverse` package
282282
- We've defined an interface called `reverse` which contains *one* function called `reverse-string`
283283
- We specify that the `reverse` interface has existed *since* the `0.1.0` version
284-
- The `reverse-string` function (AKA. `example:reverse-string/reverse.reverse-string`) takes a string and returns a string
284+
- The `reverse-string` function (AKA. `example:string-reverse/reverse.reverse-string`) takes a string and returns a string
285285
- We've defined a `world` called `string-reverse` which exports the functionality provided by the `reverse` interface
286286

287287
> [!WARNING]

0 commit comments

Comments
 (0)