-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Replace unnecessary bind(this)
and var self = this
statements with arrow functions in remaining src/core/
files
#8357
Conversation
/botio test |
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.
Looks good. But I think (as in #8358) we shall start using params destructuring when array is arg, especially for Promise.all, e.g.
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
dataPromises.then(([contentStream]) => {
(at least for the affected code above)
…h arrow functions in remaining `src/core/` files
Thank you for the review! Here's an interdiff of the changes, in case that's helpful (since Reviewable didn't want to create one). diff --git a/src/core/document.js b/src/core/document.js
index a35a0a75..c338f704 100644
--- a/src/core/document.js
+++ b/src/core/document.js
@@ -256,8 +256,7 @@ var Page = (function PageClosure() {
this.evaluatorOptions);
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
- var pageListPromise = dataPromises.then((data) => {
- var [contentStream] = data;
+ var pageListPromise = dataPromises.then(([contentStream]) => {
var opList = new OperatorList(intent, handler, this.pageIndex);
handler.send('StartRenderPage', {
@@ -274,9 +273,8 @@ var Page = (function PageClosure() {
// Fetch the page's annotations and add their operator lists to the
// page's operator list to render them.
var annotationsPromise = pdfManager.ensure(this, 'annotations');
- return Promise.all([pageListPromise, annotationsPromise]).then((data) => {
- var [pageOpList, annotations] = data;
-
+ return Promise.all([pageListPromise, annotationsPromise]).then(
+ function ([pageOpList, annotations]) {
if (annotations.length === 0) {
pageOpList.flush(true);
return pageOpList;
@@ -317,8 +315,7 @@ var Page = (function PageClosure() {
]);
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
- return dataPromises.then((data) => {
- var [contentStream] = data;
+ return dataPromises.then(([contentStream]) => {
var partialEvaluator = new PartialEvaluator(pdfManager, this.xref,
handler, this.pageIndex,
this.idFactory,
diff --git a/src/core/obj.js b/src/core/obj.js
index d58bffbe..18d017a6 100644
--- a/src/core/obj.js
+++ b/src/core/obj.js
@@ -441,8 +441,8 @@ var Catalog = (function CatalogClosure() {
getPage: function Catalog_getPage(pageIndex) {
if (!(pageIndex in this.pagePromises)) {
- this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then((a) => {
- var [dict, ref] = a;
+ this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(
+ ([dict, ref]) => {
return this.pageFactory.createPage(pageIndex, dict, ref,
this.fontCache,
this.builtInCMapCache);
|
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.21.233.14:8877/46562ba0a0aa730/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.215.176.217:8877/3628c731e7fab3f/output.txt |
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/3628c731e7fab3f/output.txt Total script time: 21.17 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/46562ba0a0aa730/output.txt Total script time: 32.78 mins
|
Thank you for the patch. |
Nice work! I didn't really have experience with parameter destructuring, but it looks much shorter and more readable. |
Replace unnecessary `bind(this)` and `var self = this` statements with arrow functions in remaining `src/core/` files
Smaller diff with https://github.com/mozilla/pdf.js/pull/8357/files?w=1.
This change is