Skip to content

Commit 3e50b13

Browse files
authored
Merge pull request bytecodealliance#187 from kxxt/patch-1
Fix typos in javascript.md
2 parents 449f64e + 16506d1 commit 3e50b13

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# JavaScript Tooling
22

3-
[WebAssembly][mdn-wasm] was originally developed as a technology for running non-Javascript workloads in the browser at near-native speed.
3+
[WebAssembly][mdn-wasm] was originally developed as a technology for running non-JavaScript workloads in the browser at near-native speed.
44

5-
Javascript WebAssembly component model support is provided primarily by [`jco`](https://github.com/bytecodealliance/jco), a command line tool
5+
JavaScript WebAssembly component model support is provided primarily by [`jco`](https://github.com/bytecodealliance/jco), a command line tool
66
which provides tooling for building WebAssembly components.
77

88
[Typescript][ts] can *also* be used, given that it is transpiled to JS first by relevant tooling (`tsc`).
@@ -35,13 +35,13 @@ npm install -g @bytecodealliance/componentize-js @bytecodealliance/jco
3535
[jco]: https://github.com/bytecodealliance/jco
3636
[componentize-js]: https://github.com/bytecodealliance/ComponentizeJS
3737

38-
## Overview of Building a Component with Javascript
38+
## Overview of Building a Component with JavaScript
3939

40-
Building a WebAssembly component with Javascript often consists of:
40+
Building a WebAssembly component with JavaScript often consists of:
4141

4242
1. Determining which interface our functionality will target (i.e. a [WebAssembly Interface Types ("WIT")][wit] world)
43-
2. Writing Javscript that satisfies the interface
44-
3. Packaging our project Javscript as WebAssembly (whether for use in WebAssembly runtimes, other JS projects, or the browser)
43+
2. Writing JavaScript that satisfies the interface
44+
3. Packaging our project JavaScript as WebAssembly (whether for use in WebAssembly runtimes, other JS projects, or the browser)
4545

4646
[WebAssembly Interface Types ("WIT")][wit] is a featureful Interface Definition Language ("IDL") for defining functionality, but most
4747
of the time, you shouldn't need to write WIT from scratch. Often, it's sufficient to download a pre-existing interface that defines what
@@ -78,13 +78,13 @@ export const add = (x, y) => {
7878
```
7979

8080
> [!WARNING]
81-
> When building your Javascript project, ensure to set the `"type":"module"` option in `package.json`,
82-
> as `jco` works exclusively with Javascript modules.
81+
> When building your JavaScript project, ensure to set the `"type":"module"` option in `package.json`,
82+
> as `jco` works exclusively with JavaScript modules.
8383
84-
In the code above, the `example` world is analogous to the Javascript module itself, with the exported `add` function
84+
In the code above, the `example` world is analogous to the JavaScript module itself, with the exported `add` function
8585
mirroring `add` function `export`ed in the WIT.
8686

87-
With the WIT and Javascript in place, we can use [`jco`][jco] to create a WebAssembly component from the JS module, using `jco componentize`.
87+
With the WIT and JavaScript in place, we can use [`jco`][jco] to create a WebAssembly component from the JS module, using `jco componentize`.
8888

8989
Our component is *so simple* (reminiscent of [Core WebAssembly][wasm-core], which deals primarily in numeric values) that we're actually *not using* any of the [WebAssembly System Interface][wasi] -- this means that we can `--disable` it when we invoke `jco componentize`
9090

@@ -143,7 +143,7 @@ instance
143143
.context("Failed to call add function")
144144
```
145145

146-
A quick reminder on the power and new capabilities afforded by WebAssembly -- we've written, loaded, instantiated and executed Javascript from Rust with a strict interface, without the need for FFI, subprocesses or a network call.
146+
A quick reminder on the power and new capabilities afforded by WebAssembly -- we've written, loaded, instantiated and executed JavaScript from Rust with a strict interface, without the need for FFI, subprocesses or a network call.
147147

148148
[rust-toolchain]: https://www.rust-lang.org/tools/install
149149
[example-host]: https://github.com/bytecodealliance/component-docs/tree/main/component-model/examples/example-host
@@ -156,10 +156,10 @@ A quick reminder on the power and new capabilities afforded by WebAssembly -- we
156156
## Running a Component from JavaScript Applications (including the Browser)
157157

158158
JavaScript runtimes available in browsers cannot yet execute WebAssembly components, so WebAssembly components
159-
(Javascript or otherwise) must be "transpiled" into a JavaScript wrapper and one or more [WebAssembly core modules][wasm-core-module]
159+
(JavaScript or otherwise) must be "transpiled" into a JavaScript wrapper and one or more [WebAssembly core modules][wasm-core-module]
160160
which *can* be run by in-browser WebAssembly runtimes.
161161

162-
Given an existing WebAssembly component (e.g. `add.wasm` which implements the [`example` world][wit-example-world]), we can "transpile" the component into runnable Javscript by using `jco tranpsile`:
162+
Given an existing WebAssembly component (e.g. `add.wasm` which implements the [`example` world][wit-example-world]), we can "transpile" the component into runnable JavaScript by using `jco tranpsile`:
163163

164164
```console
165165
jco transpile add.wasm -o dist
@@ -182,7 +182,7 @@ You should see output similar to the following:
182182
183183

184184
Thanks to `jco` transpilation, you can import the resulting `dist/add.js` file and run it from any JavaScript application
185-
using a runtime that supports the [core WebAssembly specification][core-wasm] as implemented for Javascript.
185+
using a runtime that supports the [core WebAssembly specification][core-wasm] as implemented for JavaScript.
186186

187187
To use this component from [NodeJS][nodejs], you can write code like the following:
188188

@@ -192,7 +192,7 @@ import { add } from "./dist/add.js";
192192
console.log("1 + 2 = " + add(1, 2));
193193
```
194194

195-
You can execute the Javascript module with `node` directly:
195+
You can execute the JavaScript module with `node` directly:
196196

197197
```console
198198
node run.js
@@ -207,7 +207,7 @@ You should see output like the following:
207207
This is directly comparable to the Rust host code mentioned in the previous section. Here, we are able to
208208
use NodeJS as a host for running WebAssembly, thanks to `jco`'s ability to transpile components.
209209

210-
With `jco transpile` any WebAssembly binary (compiled from any language) can be run in Javascript natively.
210+
With `jco transpile` any WebAssembly binary (compiled from any language) can be run in JavaScript natively.
211211

212212
[wasm-core-module]: https://webassembly.github.io/spec/core/binary/modules.html
213213
[core-wasm]: https://webassembly.github.io/spec/core/
@@ -270,15 +270,15 @@ OK now let's see what the JS code looks like to *implement* the `component` worl
270270
*/
271271

272272
/**
273-
* This Javascript will be interpreted by `jco` and turned into a
273+
* This JavaScript will be interpreted by `jco` and turned into a
274274
* WebAssembly binary with a single export (this `reverse` function).
275275
*/
276276
function reverseString(s) {
277277
return s.reverse();
278278
}
279279

280280
/**
281-
* The Javascript export below represents the export of the `reverse` interface,
281+
* The JavaScript export below represents the export of the `reverse` interface,
282282
* which which contains `reverse-string` as it's primary exported function.
283283
*/
284284
export const reverse = {
@@ -312,7 +312,7 @@ You should see output like the following:
312312
OK Successfully written string-reverse.wasm.
313313
```
314314

315-
Now that we have a WebAssembly binary, we can *also* use `jco` to run it in a native Javascript context by *transpiling* the WebAsssembly binary (which could have come from anywhere!) to a Javascript module.
315+
Now that we have a WebAssembly binary, we can *also* use `jco` to run it in a native JavaScript context by *transpiling* the WebAsssembly binary (which could have come from anywhere!) to a JavaScript module.
316316

317317
```console
318318
npx jco transpile string-reverse.wasm -o dist/transpiled
@@ -332,7 +332,7 @@ You should see the following output:
332332
> [!TIP]
333333
> A gentle reminder that, transpilation *does* produce [Typescript declaration file][ts-decl-file], for use in Typescript projects.
334334
335-
Now that we have a transpiled module, we can run it from any Javascript context that supports core WebAssembly (whether NodeJS or the browser).
335+
Now that we have a transpiled module, we can run it from any JavaScript context that supports core WebAssembly (whether NodeJS or the browser).
336336

337337
For NodeJS, we can use code like the following:
338338

@@ -356,9 +356,9 @@ reverseString('!dlrow olleh') = hello world!
356356

357357
While it's somewhat redundant in this context, what we've done from NodeJS demonstrates the usefulness of WebAssembly and the `jco` toolchain. With the help of `jco`, we have:
358358

359-
- Compiled Javascript to a WebAssembly module (`jco compile`), adhering to an interface defined via WIT
359+
- Compiled JavaScript to a WebAssembly module (`jco compile`), adhering to an interface defined via WIT
360360
- Converted the compiled WebAssembly module (which could be from *any* language) to a module that can be used from any compliant JS runtime (`jco transpile`)
361-
- Run the transpiled WebAssembly component from a Javascript native runtime (NodeJS)
361+
- Run the transpiled WebAssembly component from a JavaScript native runtime (NodeJS)
362362

363363
[repo]: https://github.com/bytecodealliance/component-docs
364364
[jco-examples-string-reverse]: https://github.com/bytecodealliance/jco/tree/main/examples/components/string-reverse
@@ -407,7 +407,7 @@ The `revup` world `import`s (and makes use) of `reverse` in order to `export` (p
407407
> [!NOTE]
408408
> Functionality is imported from the `interface`, *not* the `world`. `world`s can be included/used, but the syntax is slightly different for that.
409409
410-
The Javascript to make this work ([`string-reverse-upper.mjs` in `jco/examples`](https://github.com/bytecodealliance/jco/blob/main/examples/components/string-reverse-upper/string-reverse-upper.mjs)) looks like this:
410+
The JavaScript to make this work ([`string-reverse-upper.mjs` in `jco/examples`](https://github.com/bytecodealliance/jco/blob/main/examples/components/string-reverse-upper/string-reverse-upper.mjs)) looks like this:
411411

412412
```js
413413
/**
@@ -423,7 +423,7 @@ The Javascript to make this work ([`string-reverse-upper.mjs` in `jco/examples`]
423423
import { reverseString } from 'example:string-reverse/reverse@0.1.0';
424424

425425
/**
426-
* The Javascript export below represents the export of the `reversed-upper` interface,
426+
* The JavaScript export below represents the export of the `reversed-upper` interface,
427427
* which which contains `revup` as it's primary exported function.
428428
*/
429429
export const reversedUpper = {
@@ -495,7 +495,7 @@ world root {
495495

496496
It's as-if we never imported any functionality at all -- the functionality present in `string-reverse.wasm` has been *merged into* `string-reverse-upper.wasm`, and it now simply `export`s the advanced functionality.
497497

498-
We can run this completed component with in any WebAssembly-capable native Javascript environment by using a the transpiled result:
498+
We can run this completed component with in any WebAssembly-capable native JavaScript environment by using a the transpiled result:
499499

500500
```console
501501
npx jco transpile string-reverse-upper.wasm -o dist/transpiled

0 commit comments

Comments
 (0)