mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
Enable the ESLint prefer-const
rule globally (PR 11450 follow-up)
Please find additional details about the ESLint rule at https://eslint.org/docs/rules/prefer-const With the recent introduction of Prettier this sort of mass enabling of ESLint rules becomes a lot easier, since the code will be automatically reformatted as necessary to account for e.g. changed line lengths. Note that this patch is generated automatically, by using the ESLint `--fix` argument, and will thus require some additional clean-up (which is done separately).
This commit is contained in:
parent
d2d9441373
commit
9e262ae7fa
54 changed files with 676 additions and 661 deletions
|
@ -25,7 +25,7 @@ import { JpegImage } from "./jpg.js";
|
|||
* a library to decode these images and the stream behaves like all the other
|
||||
* DecodeStreams.
|
||||
*/
|
||||
let JpegStream = (function JpegStreamClosure() {
|
||||
const JpegStream = (function JpegStreamClosure() {
|
||||
function JpegStream(stream, maybeLength, dict, params) {
|
||||
// Some images may contain 'junk' before the SOI (start-of-image) marker.
|
||||
// Note: this seems to mainly affect inline images.
|
||||
|
@ -64,19 +64,19 @@ let JpegStream = (function JpegStreamClosure() {
|
|||
if (this.eof) {
|
||||
return;
|
||||
}
|
||||
let jpegOptions = {
|
||||
const jpegOptions = {
|
||||
decodeTransform: undefined,
|
||||
colorTransform: undefined,
|
||||
};
|
||||
|
||||
// Checking if values need to be transformed before conversion.
|
||||
let decodeArr = this.dict.getArray("Decode", "D");
|
||||
const decodeArr = this.dict.getArray("Decode", "D");
|
||||
if (this.forceRGB && Array.isArray(decodeArr)) {
|
||||
let bitsPerComponent = this.dict.get("BitsPerComponent") || 8;
|
||||
let decodeArrLength = decodeArr.length;
|
||||
let transform = new Int32Array(decodeArrLength);
|
||||
const bitsPerComponent = this.dict.get("BitsPerComponent") || 8;
|
||||
const decodeArrLength = decodeArr.length;
|
||||
const transform = new Int32Array(decodeArrLength);
|
||||
let transformNeeded = false;
|
||||
let maxValue = (1 << bitsPerComponent) - 1;
|
||||
const maxValue = (1 << bitsPerComponent) - 1;
|
||||
for (let i = 0; i < decodeArrLength; i += 2) {
|
||||
transform[i] = ((decodeArr[i + 1] - decodeArr[i]) * 256) | 0;
|
||||
transform[i + 1] = (decodeArr[i] * maxValue) | 0;
|
||||
|
@ -90,7 +90,7 @@ let JpegStream = (function JpegStreamClosure() {
|
|||
}
|
||||
// Fetching the 'ColorTransform' entry, if it exists.
|
||||
if (isDict(this.params)) {
|
||||
let colorTransform = this.params.get("ColorTransform");
|
||||
const colorTransform = this.params.get("ColorTransform");
|
||||
if (Number.isInteger(colorTransform)) {
|
||||
jpegOptions.colorTransform = colorTransform;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ let JpegStream = (function JpegStreamClosure() {
|
|||
const jpegImage = new JpegImage(jpegOptions);
|
||||
|
||||
jpegImage.parse(this.bytes);
|
||||
let data = jpegImage.getData({
|
||||
const data = jpegImage.getData({
|
||||
width: this.drawWidth,
|
||||
height: this.drawHeight,
|
||||
forceRGB: this.forceRGB,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue