Errata

JavaScript with Promises

Errata for JavaScript with Promises

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
n/a
the paragraph under Example 5-5

Two getData should be getReportData.

Note from the Author or Editor:
The paragraph immediately following Example 5-5 refers to the getData function twice. The correct name of the function is getReportData.

wkl  Sep 02, 2015 
Printed
Page 6
Example 1-8

The first line of Example 1-8 should read:
jQuery(document).ready(function () {

instead of:
jQuery.ready(function () {

Daniel Parker
 
Jun 17, 2015  Jul 17, 2015
Printed
Page 7
Example 1-9

The url in Example 1-9 should begin with http:// instead of https:// and the err parameter in the callback should be removed.

Daniel Parker
 
Jun 17, 2015  Jul 17, 2015
Printed
Page 30
Example 3-8

The last line of Example 3-8 which describes the console output should read "2 out of 3 balances were updated" instead of "2 balances out of 3 were updated".

Daniel Parker
 
Jun 18, 2015  Jul 17, 2015
Printed
Page 36
Example 3-16

In Example 3-16 the call to scaleToFit inside the processImage function should be preceded by a call to Promise.resolve(image) so the function begins:

function processImage(image) {
return Promise.resolve(image).then(function (image) {
return scaleToFit(300, 450, image);
}).then(function (image) {

instead of:
function processImage(image) {
return scaleToFit(300, 450, image).then(function (image) {

Daniel Parker
 
Jun 17, 2015  Jul 17, 2015
Printed
Page 41
Example 4-2

In Example 4-2 the lines that check the state of the promise and log it to the console should be wrapped in a call to setTimeout as follows:

// Force event loop to turn
setTimeout(function () {
console.log('Pending? ' + b.isPending()); // Pending? false
console.log('Fulfilled? ' + b.isFulfilled()); // Fulfilled? true
console.log('Rejected? ' + b.isRejected()); // Rejected? false
}, 0);

Daniel Parker
 
Jun 17, 2015  Jul 17, 2015
Printed
Page 43
Example 4-5

In Example 4-5 null should be used as an argument to bind() in the last line of the function assigned to printer.shutdown so the line reads as:

}).bind(null); // mask the previous binding

instead of:

}).bind(); // mask the previous binding

Daniel Parker
 
Jun 17, 2015  Jul 17, 2015
Printed
Page 52
Example 4-19

In Example 4-19 the function declaration in task.js should be assigned to onmessage and the listener in the main script should be registered using worker.onmessage so the first half of the example reads as:

// Contents of task.js
onmessage = function(event) {
postMessage({
status: 'completed',
id: event.data.id,
result: 'some calculated result'
});
};

// Contents of main script
var worker = new Worker('task.js');
var deferreds = {};
var counter = 0;

worker.onmessage = function (msg) {
var d = deferreds[msg.data.id];
d.resolve(msg.data.result);
};

Daniel Parker
 
Jun 17, 2015  Jul 17, 2015
Printed
Page 57
Example 5-4

In Example 5-4 the semicolon after the connect function declaration should be replaced by a comma and the semicolon after the query function declaration should be removed so the first four lines of the example read as:

var db = {
connect: function () {/*...*/},
query: function () {/*...*/}
};

instead of:

var db = {
connect: function () {/*...*/};
query: function () {/*...*/};
};

Daniel Parker
 
Jun 17, 2015  Jul 17, 2015
Printed
Page 67
Example 6-6

In Example 6-6 the map function should be used instead of foreach so the entire example reads as:

requests = accounts.map(function (account) {
return getBalance(account);
});

instead of:

requests = accounts.forEach(function (account) {
return getBalance(account);
});

Daniel Parker
 
Jun 17, 2015  Jul 17, 2015