refactor: remove unneccessary async in embed#66
refactor: remove unneccessary async in embed#66nayounsang wants to merge 5 commits intocantoo-scribe:masterfrom
Conversation
delete lock file from PR
32cbe9b to
39e3a95
Compare
|
Please remove your changes to yarn and package-lock. I'll have a look at the rest. |
src/api/PDFDocument.ts
Outdated
| @@ -1070,7 +1065,7 @@ export default class PDFDocument { | |||
| async embedJpg(jpg: string | Uint8Array | ArrayBuffer): Promise<PDFImage> { | |||
There was a problem hiding this comment.
Then this async should not be needed anymore either, right?
src/api/PDFDocument.ts
Outdated
| @@ -1110,7 +1105,7 @@ export default class PDFDocument { | |||
| async embedPng(png: string | Uint8Array | ArrayBuffer): Promise<PDFImage> { | |||
There was a problem hiding this comment.
You should also be able to remove it from embedSvg. try to look for other impacts.
There was a problem hiding this comment.
Thx for review. I will check other async function.
There was a problem hiding this comment.
Thanks for review. Plz check for changes.
Oh, this is my mistake |
|
And I found a lot of things that were just another async function but were actually sync functions. |
|
Hi, @nayounsang There's also an explanation here: Hopding#134 (comment). The explanation is related to the document create/load process, but it's also valid for the embedding process. |
I have a question of this comment. const myFn = async () => {
let a = 10;
for (int i = 0; i < 1000000000; i++){
a += 1;
}
}
await myFn() // nothing to do with event-loopBut I am still a student so I may be confused about the event loop. Can you explain more about this? |
|
After asking js experts around me, they guessed that the maintainer probably used async with future scalability in mind. |
What?
I implement about this issue
Some of the embedded code is async, but Inside the function is synchronous.
Why?
I had a bottleneck in that library and found the code while looking inside. This may cause confusion in its internal workings.
How?
Remove async at embed PNG,JEPG,Fonts.
This is also reflected in where it is used.(PDF Document)
Testing?
I run test scripts. All passed.
And run test apps/web/test-htmls.
From my own experience, this works without a problem.
New Dependencies?
No
Screenshots
Suggested Reading?
Anything Else?
Checklist