mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
Convert the TTX driver code to promises
This commit removes the final callbacks in this code by switching to a promises-based interface, overall simplifying the code. Moreover, we document why we write to files on disk and modernize the code using e.g. template strings.
This commit is contained in:
parent
64065141b6
commit
ac03d7054d
2 changed files with 43 additions and 32 deletions
|
@ -840,12 +840,14 @@ function unitTestPostHandler(req, res) {
|
|||
req.on("data", function (data) {
|
||||
body += data;
|
||||
});
|
||||
req.on("end", function () {
|
||||
req.on("end", async function () {
|
||||
if (pathname === "/ttx") {
|
||||
translateFont(body, function (err, xml) {
|
||||
res.writeHead(200, { "Content-Type": "text/xml" });
|
||||
res.end(err ? "<error>" + err + "</error>" : xml);
|
||||
});
|
||||
res.writeHead(200, { "Content-Type": "text/xml" });
|
||||
try {
|
||||
res.end(await translateFont(body));
|
||||
} catch (error) {
|
||||
res.end(`<error>${error}</error>`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue