Skip to content

Fix semicolons in 1.11.6 (Promisification) #2255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions 1-js/11-async/06-promisify/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ Let's promisify it. The new `loadScriptPromise(src)` function achieves the same
let loadScriptPromise = function(src) {
return new Promise((resolve, reject) => {
loadScript(src, (err, script) => {
if (err) reject(err)
if (err) reject(err);
else resolve(script);
});
})
}
});
};

// usage:
// loadScriptPromise('path/script.js').then(...)
Expand Down Expand Up @@ -62,7 +62,7 @@ function promisify(f) {
f.call(this, ...args); // call the original function
});
};
};
}

// usage:
let loadScriptPromise = promisify(loadScript);
Expand Down Expand Up @@ -94,11 +94,11 @@ function promisify(f, manyArgs = false) {
f.call(this, ...args);
});
};
};
}

// usage:
f = promisify(f, true);
f(...).then(arrayOfResults => ..., err => ...)
f(...).then(arrayOfResults => ..., err => ...);
```

For more exotic callback formats, like those without `err` at all: `callback(result)`, we can promisify such functions manually without using the helper.
Expand Down