Errata: December 8, 2019

Thank you for purchasing WebAssembly in Action.

Please post errata not listed below in this book's LiveBook Errata thread. We'll update this list as necessary. Thank you!


In chapter 1, page 14, section 1.5:

The last paragraph of the section before the 'Looking Ahead' callout indicates the preamble bytes but the colon doesn't have a space before the number 0061. It should be:

"...only the preamble bytes: 0061 736d..."

In chapter 3, page 43, section 3.6.2 'Promises and arrow function expressions:'

The three annotations for the first two code snippets should have a capital 'P' for the word 'promise.'

In chapter 3, page 44, section 3.6.2 'Promises and arrow function expressions:'

The first annotation for the code snippet just before section 'JavaScript object shorthand' should have a capital 'P' for the word 'promise.'

In chapter 3, page 48, section 'Creating the JavaScript to fetch and instantiate the module:'

1) The third paragraph, second sentence, doesn't have the 'i' in 'instantiateStreaming' using the same format as the rest of the word.
2) In the same sentence, the word 'promise' should have a capital 'P.'

In chapter 4, page 65, section 4.1.3:

In Listing 4.3, all the links within the head tag include the text 'W3Schools' which shouldn’t be there. The links should be:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>

In chapter 4, page 77, section 'The implementation file for the side module's system functions:'

The paragraph following the snippet for the closing curly brace of the extern "C" block (after Listing 4.9) indicates to copy the 'validate  .cpp' file. There shouldn't be a space before the .'cpp' extension. The text should be:

"...copy the validate.cpp file from the..."

In chapter 6, page 116, listing 6.4:

1) The annotation for the 'function createPointers(resolve, reject, returnPointers) {' line of code should have a capital 'P' for the word 'promise.'
2) The annotation for the 'resolve();' line of code should have a capital 'P' for the word 'promise.'
3) The annotation for the 'reject(Module.UTF8ToString(errorMessage));' line of code should have a capital 'P' for the word 'promise.'

In chapter 6, page 125 and 126, listing 6.7:

The closing curly braces of the 'env' object and the parent 'importObject' shouldn't be bold.

In chapter 6, page 126, the last code snippet on the page in section 'The addToTable function:'

1) The annotation for the 'moduleTable.grow' line of code says 'Growa.' It should be 'Grow.a
2) Likewise, the annotation for the 'moduleTable.set' line of code says 'Converta.' It should be 'Convert.'

In chapter 6, page 127, section 'The onSuccessCallback function'

The annotation for the 'validateCallbacks.resolve();' line of code should have a capital 'P' for 'promise.'

In chapter 6, page 128, section 'The onErrorCallback function:'

The annotation for the 'validateCallbacks.reject(errorMessage);' line of code should have a capital 'P' for 'promise.'

In chapter 6, page 129, section 'The createPointers function:'

The word 'promise' at the end of bullets 2 and 3 (resolve and reject) should have a capital 'P.'

In chapter 6, page 129, listing 6.9:

1) The annotation for the 'validateNameCallbacks.resolve = resolve;' line of code should have a capital 'P' for the word 'promise.'
2) Likewise for the word 'promise' in the annotation for the 'validateCategoryCallbacks.resolve = resolve;' line of code should have a capital 'P.'

In chapter 6, page 129, section 'The validateName function:'

The word 'promise' in the second sentence should have a capital 'P.'

In chapter 6, page 130, section 'The validateName function:'

The word "promise's" in the first sentence of the first paragraph should have a capital 'P.'

In chapter 6, page 132, section 'Real-world use cases:'

The word 'promise' in the first sentence of the first bullet point should have a capital 'P.'

In chapter 7, page 158, listing 7.6:

The last annotation on the page ('The find_primes module is ready.') is pointing to one line too high. It should be pointing to the following line of code:

.then(module => {

In chapter 9, page 200, section 9.3.1 'Adjusting the calculate_primes logic:'

The third paragraph should have the word 'chrono' in the same style as 'high_resolution_clock' to match how 'vector' is formatted in the same paragraph.

In chapter 9, page 212, listing 9.3:

In the 'FindPrimes(3, 199999, args[0].primes_found);' line of code, the .'' after 'args[0]' should be bold.

In chapter 10, page 222, section 10.3.1 'Loading a WebAssembly module'

In the first paragraph, second sentence, the path shouldn't have a space between 'Chapter 10\10.3.1 JsPlumbingPrimes\' and 'backend\.' It should be:

Chapter 10\10.3.1 JsPlumbingPrimes\backend\

In chapter 10, page 222, section 10.3.1 'Loading a WebAssembly module:'

In the first paragraph, last sentence, the path indicates 'Chapter 3\3.4 js_plumbing\.' It should be:

Chapter 3\3.5 js_plumbing\

In chapter 10, page 224, section 'Implementing the server code for Node.js:'

In the paragraph before the clientData code snippet, the word 'InitialData' should have a lowercase 'i.' It should be:

initialData

In chapter 10, page 227, section 'Implementing the server code for Node.js:'

In the paragraph before the clientData code snippet, the word 'InitialData' should have a lowercase 'i.' It should be:

initialData

In chapter 10, page 227, section 'Implementing the server code for Node.js:'

The last paragraph on the page says .'..validate.js-generated code...' It should be:

...Emscripten-generated code...

In chapter 10, page 229, section 'Implementing the server code for Node.js:'

The last paragraph on the page, the word 'InitialData' should have a lowercase 'i.' It should be:

initialData

In chapter 10, page 232, section 'Implementing the server code for Node.js:'

The first bullet indicates the path 'Chapter 3\3.5.1 side_module\.' It should be:

Chapter 3\3.6 side_module\

In chapter 10, page 243, listing 10.7:

Some formatting improvements for listing 10.7...
1) The 'moduleTable' line of code should be indented to match the 'const importObject' line of code. There should also be a line feed between the 'moduleTable' and 'const importObject' lines of code.
2) In the 'then' method of the WebAssembly.instantiate call, there should be a linefeed between the 'moduleExports' and 'validateOnSuccessNameIndex' line of code.
3) The 'validateOnSuccessNameIndex' line of code should be indented to match the 'moduleExports' line of code.
4) For the 'validateOnErrorCategoryIndex' lines of code, the closing "}, 'vi');" should be indented to match the 'validateOnErrorCategoryIndex' line of code. It also should be the same font as the rest of the code and not be bold.
5) The 'validateData();' function call should be on its own line and indented to match the 'validateOnErrorCategoryIndex' line of code.

Listing 10.7 should look like the following:

function instantiateWebAssembly(bytes) {
  moduleMemory = new WebAssembly.Memory({initial: 256});
  moduleTable = new WebAssembly.Table({initial: 1, element: "anyfunc"});

  const importObject = {    
    env: {
      __memory_base: 0,
      memory: moduleMemory,
      __table_base: 0,
      table: moduleTable,
      abort: function(i) { throw new Error('abort'); },
    }
  };

  WebAssembly.instantiate(bytes, importObject).then(result => {
    moduleExports = result.instance.exports;

    validateOnSuccessNameIndex = addToTable(() => { 
      onSuccessCallback(validateNameCallbacks);
    }, 'v');

    validateOnSuccessCategoryIndex = addToTable(() => {
      onSuccessCallback(validateCategoryCallbacks);
    }, 'v');

    validateOnErrorNameIndex = addToTable((errorMessagePointer) => {
      onErrorCallback(validateNameCallbacks, errorMessagePointer);
    }, 'vi');

    validateOnErrorCategoryIndex = addToTable((errorMessagePointer) => {
      onErrorCallback(validateCategoryCallbacks, errorMessagePointer);
    }, 'vi');

    validateData();
  });
}

In chapter 10, page 245, section 'Summary:'

At the end of the third bullet, it indicates that feature detection was in section 3.6. It should be:

chapter 3, section 3.7

In chapter 11, page 254, table 11.1:

The Text format column value 'elem' isn't formatted the same way as the other words in that column.

In chapter 11, page 256, section 11.1.3 'Function signatures:'

In the second paragraph, before the '(func (param i32 i32) (result i32))' snippet, the second sentence says '32-bit' twice but doesn't indicate if it's a 32-bit integer or float. The sentence should be:

The following is an example of a signature that has two 32-bit integer parameters and returns a 32-bit integer value:

In chapter 11, page 258, table 11.2:

In the Purpose column for the _FlipCard item, the last sentence should end with 'it.'

In chapter 11, page 270, section 'The $InitializeCards function:'

In the last paragraph on the page, removed the word 'the' from before '$ShuffleArray.'

In chapter 11, page 274, section 'The $ShuffleArray function:'

In the second last paragraph before listing 11.7, the word '$index' uses a '$' character that differs from the other '$' characters used throughout the chapter.