mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Replace *most* cases of var
with let
/const
in the examples/
folder
These changes were done automatically, by using the `gulp lint --fix` command, in preparation for the next patch.
This commit is contained in:
parent
56fd01bf8d
commit
276fa4ad8f
15 changed files with 196 additions and 194 deletions
|
@ -8,22 +8,23 @@
|
|||
//
|
||||
|
||||
// Run `gulp dist-install` to generate 'pdfjs-dist' npm package files.
|
||||
var pdfjsLib = require("pdfjs-dist/legacy/build/pdf.js");
|
||||
const pdfjsLib = require("pdfjs-dist/legacy/build/pdf.js");
|
||||
|
||||
// Loading file from file system into typed array
|
||||
var pdfPath = process.argv[2] || "../../web/compressed.tracemonkey-pldi-09.pdf";
|
||||
const pdfPath =
|
||||
process.argv[2] || "../../web/compressed.tracemonkey-pldi-09.pdf";
|
||||
|
||||
// Will be using promises to load document, pages and misc data instead of
|
||||
// callback.
|
||||
var loadingTask = pdfjsLib.getDocument(pdfPath);
|
||||
const loadingTask = pdfjsLib.getDocument(pdfPath);
|
||||
loadingTask.promise
|
||||
.then(function (doc) {
|
||||
var numPages = doc.numPages;
|
||||
const numPages = doc.numPages;
|
||||
console.log("# Document Loaded");
|
||||
console.log("Number of Pages: " + numPages);
|
||||
console.log();
|
||||
|
||||
var lastPromise; // will be used to chain promises
|
||||
let lastPromise; // will be used to chain promises
|
||||
lastPromise = doc.getMetadata().then(function (data) {
|
||||
console.log("# Metadata Is Loaded");
|
||||
console.log("## Info");
|
||||
|
@ -36,10 +37,10 @@ loadingTask.promise
|
|||
}
|
||||
});
|
||||
|
||||
var loadPage = function (pageNum) {
|
||||
const loadPage = function (pageNum) {
|
||||
return doc.getPage(pageNum).then(function (page) {
|
||||
console.log("# Page " + pageNum);
|
||||
var viewport = page.getViewport({ scale: 1.0 });
|
||||
const viewport = page.getViewport({ scale: 1.0 });
|
||||
console.log("Size: " + viewport.width + "x" + viewport.height);
|
||||
console.log();
|
||||
return page
|
||||
|
@ -47,7 +48,7 @@ loadingTask.promise
|
|||
.then(function (content) {
|
||||
// Content contains lots of information about the text layout and
|
||||
// styles, but we need only strings at the moment
|
||||
var strings = content.items.map(function (item) {
|
||||
const strings = content.items.map(function (item) {
|
||||
return item.str;
|
||||
});
|
||||
console.log("## Text Content");
|
||||
|
@ -60,7 +61,7 @@ loadingTask.promise
|
|||
};
|
||||
// Loading of the first page will wait on metadata and subsequent loadings
|
||||
// will wait on the previous pages.
|
||||
for (var i = 1; i <= numPages; i++) {
|
||||
for (let i = 1; i <= numPages; i++) {
|
||||
lastPromise = lastPromise.then(loadPage.bind(null, i));
|
||||
}
|
||||
return lastPromise;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue