-
Notifications
You must be signed in to change notification settings - Fork 29
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
refactor: remove unneccessary async in embed #66
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also be able to remove it from embedSvg. try to look for other impacts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx for review. I will check other async function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-loop But 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