Skip to content

Commit

Permalink
Fix typos (mdn#20300)
Browse files Browse the repository at this point in the history
* Fix typos

* use 'some of the'
  • Loading branch information
OnkarRuikar authored Sep 5, 2022
1 parent fa1c80d commit 12c70e5
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion files/en-us/webassembly/c_to_wasm/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Sometimes you will want to use a custom HTML template. Let's look at how we can
}
```

2. Search for the file `shell_minimal.html` in your emsdk repo. Copy it into a sub-directory called `html_template` inside your previous new directory.
2. Search for the file `shell_minimal.html` in your emsdk repo. Copy it into a subdirectory called `html_template` inside your previous new directory.
3. Now navigate into your new directory (again, in your Emscripten compiler environment terminal window), and run the following command:

```bash
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/webassembly/caching_modules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tags:

> **Warning:** Experimental {{jsxref("WebAssembly.Module")}} IndexedDB serialization support is being removed from browsers; see {{bug("1469395")}} and [this spec issue](https://github.com/WebAssembly/spec/issues/821).
Caching is useful for improving the performance of an app — we can store compiled WebAssembly modules on the client so they don't have to be downloaded and compiled every time. This article explains the best practices around this.
Caching is useful for improving the performance of an app — we can store compiled WebAssembly modules on the client, so they don't have to be downloaded and compiled every time. This article explains the best practices around this.

## Caching via IndexedDB

Expand Down
4 changes: 2 additions & 2 deletions files/en-us/webassembly/exported_functions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ WebAssembly.instantiateStreaming(fetch('table.wasm'))
});
```

Here we create a table (`otherTable`) from JavaScript using the {{jsxref("WebAssembly.Table")}} constructor, then we load table.wasm into our page using the {{jsxref("WebAssembly.instantiateStreaming()")}} method.
Here we create a table (`otherTable`) from JavaScript using the {{jsxref("WebAssembly.Table")}} constructor, then we load `table.wasm` into our page using the {{jsxref("WebAssembly.instantiateStreaming()")}} method.

We then get the function exported from the module, retrieve the functions it references via [`tbl.get()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get) and log the result of invoking each one to the console. Next, we use `set()` to make the `otherTable` table contain references to the same functions as the `tbl` table.

Expand Down Expand Up @@ -75,4 +75,4 @@ Some other particulars to be aware of with exported WebAssembly functions:

- Their [length](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length) property is the number of declared arguments in the wasm function signature.
- Their [name](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name) property is the `toString()` result of the function's index in the wasm module.
- If you try to call a exported wasm function that takes or returns an i64 type value, it currently throws an error because JavaScript currently has no precise way to represent an i64. This may well change in the future though — a new int64 type is being considered for future standards, which could then be used by wasm.
- If you try to call an exported wasm function that takes or returns an i64 type value, it currently throws an error because JavaScript currently has no precise way to represent an i64. This may well change in the future though — a new int64 type is being considered for future standards, which could then be used by wasm.
2 changes: 1 addition & 1 deletion files/en-us/webassembly/reference/memory/load/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tags:

The **`load`** instructions, are used to load a number from memory onto the stack.

For the integer numbers, you can also load a narrower number from memory and extend it into a wider type, e.g. load a unsigned 8-bit number and convert it into a i32 (**`i32.load8_u`**). These instructions are separate for signed and unsigned numbers.
For the integer numbers, you can also load a narrower number from memory and extend it into a wider type, e.g. load an unsigned 8-bit number and convert it into an i32 (**`i32.load8_u`**). These instructions are separate for signed and unsigned numbers.

{{EmbedInteractiveExample("pages/wat/load.html", "tabbed-taller")}}

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/webassembly/reference/memory/store/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tags:

The **`store`** instructions, are used to store a number in memory.

For the integer numbers, you can also store a wide typed number as a narrower number in memory, e.g. store a 32-bit number in a 8-bit slot (**`i32.store8`**). If the number doesn't fit in the narrower number type it will wrap.
For the integer numbers, you can also store a wide typed number as a narrower number in memory, e.g. store a 32-bit number in an 8-bit slot (**`i32.store8`**). If the number doesn't fit in the narrower number type it will wrap.

{{EmbedInteractiveExample("pages/wat/store.html", "tabbed-taller")}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tags:
---
{{WebAssemblySidebar}}

The **`trunc`** instructions, short for _truncate_, are used for getting the value of a number without it's fractional part.
The **`trunc`** instructions, short for _truncate_, are used for getting the value of a number without its fractional part.

**`trunc`** differs from **`floor`** when used on negative numbers, **`floor`** will round down in those cases while **`trunc`** will round up.

Expand Down
6 changes: 3 additions & 3 deletions files/en-us/webassembly/rust_to_wasm/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ This does a number of things (and they take a lot of time, especially the first
4. Reads your `Cargo.toml` and produces an equivalent `package.json`.
5. Copies your `README.md` (if you have one) into the package.

The end result? You have a package inside of the `pkg` directory.
The end result? You have a package inside the `pkg` directory.

#### A digression about code size

Expand Down Expand Up @@ -231,7 +231,7 @@ The script in this file will import the js glue code, initialize the wasm module

Serve the root directory of the project with a local web server, (e.g. `python3 -m http.server`). If you're not sure how to do that, refer to [Running a simple local HTTP server](/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server#running_a_simple_local_http_server).

> **Note:** Make sure to use an up to date web server that supports the `application/wasm` MIME type. Older web servers might not support it yet.
> **Note:** Make sure to use an up-to-date web server that supports the `application/wasm` MIME type. Older web servers might not support it yet.
Load `index.html` from the web server (if you used the Python3 example: `http://localhost:8000`). An alert box appears on the screen, with `Hello, WebAssembly!` in it. We've successfully called from JavaScript into Rust, and from Rust into JavaScript.

Expand Down Expand Up @@ -262,7 +262,7 @@ We now have an npm package, written in Rust, but compiled to WebAssembly. It's r

### Using the npm package on the web

Let's build a website that uses our new npm package. Many people use npm packages through various bundler tools, and we'll be using one of them, `webpack`, in this tutorial. It's only a little bit complex, and shows a realistic use-case.
Let's build a website that uses our new npm package. Many people use npm packages through various bundler tools, and we'll be using one of them, `webpack`, in this tutorial. It's only a bit complex, and shows a realistic use-case.

Let's move back out of the `pkg` directory, and make a new directory, `site`, to try this out in:

Expand Down
14 changes: 7 additions & 7 deletions files/en-us/webassembly/understanding_the_text_format/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ If we convert our module to binary now (see [Converting WebAssembly text format

Ok, that's not very interesting, let's add some executable code to this module.

All code in a webassembly module is grouped into functions, which have the following pseudo-code structure:
All code in a webassembly module is grouped into functions, which have the following pseudocode structure:

```wasm
( func <signature> <locals> <body> )
Expand Down Expand Up @@ -105,7 +105,7 @@ The instruction `local.get 0` would get the i32 parameter, `local.get 1` would g

There is another issue here — using numeric indices to refer to items can be confusing and annoying, so the text format allows you to name parameters, locals, and most other items by including a name prefixed by a dollar symbol (`$`) just before the type declaration.

Thus you could rewrite our previous signature like so:
Thus, you could rewrite our previous signature like so:

```wasm
(func (param $p1 i32) (param $p2 f32) (local $loc f64) …)
Expand Down Expand Up @@ -305,7 +305,7 @@ The key is that JavaScript can create WebAssembly linear memory instances via th

Memory instances can also grow, for example via the [`Memory.grow()`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory/grow) method in JavaScript. When growth occurs, since `ArrayBuffer`s can't change size, the current `ArrayBuffer` is detached and a new `ArrayBuffer` is created to point to the newer, bigger memory. This means all we need to do to pass a string to JavaScript is to pass out the offset of the string in linear memory along with some way to indicate the length.

While there are many different ways to encode a string's length in the string itself (for example, C strings); for simplicity here we just pass both offset and length as parameters:
While there are many ways to encode a string's length in the string itself (for example, C strings); for simplicity here we just pass both offset and length as parameters:

```wasm
(import "console" "log" (func $log (param i32) (param i32)))
Expand Down Expand Up @@ -346,7 +346,7 @@ Our final wasm module looks like this:
call $log))
```

> **Note:** Above, note the double semi-colon syntax (`;;`) for allowing comments in WebAssembly files.
> **Note:** Above, note the double semicolon syntax (`;;`) for allowing comments in WebAssembly files.
Now from JavaScript we can create a Memory with 1 page and pass it in. This results in "Hi" being printed to the console:

Expand All @@ -369,7 +369,7 @@ To finish this tour of the WebAssembly text format, let's look at the most intri

To see why tables are needed, we need to first observe that the `call` instruction we saw earlier (see [Calling functions from other functions in the same module](#calling_functions_from_other_functions_in_the_same_module)) takes a static function index and thus can only ever call one function — but what if the callee is a runtime value?

- In JavaScript we see this all the time: functions are first-class values.
- In JavaScript, we see this all the time: functions are first-class values.
- In C/C++, we see this with function pointers.
- In C++, we see this with virtual functions.

Expand Down Expand Up @@ -441,7 +441,7 @@ You could also declare the `call_indirect` parameter explicitly during the comma
(call_indirect (type $return_i32) (local.get $i))
```

In a higher level, more expressive language like JavaScript, you could imagine doing the same thing with an array (or probably more likely, object) containing functions. The pseudo code would look something like `tbl[i]()`.
In a higher level, more expressive language like JavaScript, you could imagine doing the same thing with an array (or probably more likely, object) containing functions. The pseudocode would look something like `tbl[i]()`.

So, back to the typechecking. Since WebAssembly is type checked, and the `funcref` can be potentially any function signature, we have to supply the presumed signature of the callee at the callsite, hence we include the `$return_i32` type, to tell the program a function returning an `i32` is expected. If the callee doesn't have a matching signature (say an `f32` is returned instead), a {{JSxRef("WebAssembly.RuntimeError")}} is thrown.

Expand Down Expand Up @@ -618,7 +618,7 @@ At the time of writing (June 2020) this is at an early stage, and the only multi
)
```

But this will pave the way for more useful instruction types, and other things besides. For a useful write up of progress so far and how this works, see [Multi-Value All The Wasm!](https://hacks.mozilla.org/2019/11/multi-value-all-the-wasm/) by Nick Fitzgerald.
But this will pave the way for more useful instruction types, and other things besides. For a useful write-up of progress so far and how this works, see [Multi-Value All The Wasm!](https://hacks.mozilla.org/2019/11/multi-value-all-the-wasm/) by Nick Fitzgerald.

## WebAssembly threads

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/webassembly/using_the_javascript_api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Let's run through some examples that explain how to use the WebAssembly JavaScri
### Preparing the example

1. First we need a wasm module! Grab our [simple.wasm](https://raw.githubusercontent.com/mdn/webassembly-examples/master/js-api-examples/simple.wasm) file and save a copy in a new directory on your local machine.
1. First we need a wasm module! Grab our [`simple.wasm`](https://raw.githubusercontent.com/mdn/webassembly-examples/master/js-api-examples/simple.wasm) file and save a copy in a new directory on your local machine.
2. Next, let's create a simple HTML file called `index.html` in the same directory as your wasm file (can use our [simple template](https://github.com/mdn/webassembly-examples/blob/master/template/template.html) if you haven't got one easily available).
3. Now, to help us understand what is going on here, let's look at the text representation of our wasm module (which we also meet in [Converting WebAssembly format to wasm](/en-US/docs/WebAssembly/Text_format_to_wasm#a_first_look_at_the_text_format)):

Expand Down

0 comments on commit 12c70e5

Please sign in to comment.