Skip to content
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

Simplify extractText, and replace unnecessary var self = this statements with arrow functions, in web/pdf_find_controller.js #8397

Merged
merged 2 commits into from
May 10, 2017

Conversation

Snuffleupagus
Copy link
Collaborator

  • Simplify extractText in web/pdf_find_controller.js
    Currently this method first uses a loop to build a temporary array to hold Promises, which are then resolved from a recursive helper function once the textContent is fetched for each page.

    To me, this is unncessarily complicated, since we can do everything within one loop by simply chaining the asynchronous calls to retrieve the textContent. (Note that this guarantees that the textContent of the pages is still fetched sequentially.)

  • Replace unnecessary var self = this statements with arrow functions in web/pdf_find_controller.js

Currently this method first uses a loop to build a temporary array to hold Promises, which are then resolved from a recursive helper function once the textContent is fetched for each page.

To me, this is unncessarily complicated, since we can do everything within one loop by simply chaining the asynchronous calls to retrieve the textContent. (Note that this guarantees that the textContent of the pages is still fetched sequentially.)
@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_preview from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/913dce57cf3e0ae/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/913dce57cf3e0ae/output.txt

Total script time: 2.00 mins

Published

Copy link
Contributor

@yurydelendik yurydelendik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@Snuffleupagus Snuffleupagus merged commit 52998c5 into mozilla:master May 10, 2017
@Snuffleupagus Snuffleupagus deleted the extractText-refactor branch May 10, 2017 15:18
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Simplify `extractText`, and replace unnecessary `var self = this` statements with arrow functions, in `web/pdf_find_controller.js`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants