Use the const keyword for constants in src/shared/util.js

Moreover, move general constants to the top of the file, i.e., those
that are not closely tied to a function in the file.
This commit is contained in:
Tim van der Meij 2018-09-11 15:27:15 +02:00
parent 99de25d6cc
commit bf13c8a50b
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762

View File

@ -17,7 +17,8 @@ import './compatibility';
import { ReadableStream } from './streams_polyfill'; import { ReadableStream } from './streams_polyfill';
import { URL } from './url_polyfill'; import { URL } from './url_polyfill';
var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0]; const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
const NativeImageDecoding = { const NativeImageDecoding = {
NONE: 'none', NONE: 'none',
@ -37,7 +38,7 @@ const PermissionFlag = {
PRINT_HIGH_QUALITY: 0x800, PRINT_HIGH_QUALITY: 0x800,
}; };
var TextRenderingMode = { const TextRenderingMode = {
FILL: 0, FILL: 0,
STROKE: 1, STROKE: 1,
FILL_STROKE: 2, FILL_STROKE: 2,
@ -50,13 +51,13 @@ var TextRenderingMode = {
ADD_TO_PATH_FLAG: 4, ADD_TO_PATH_FLAG: 4,
}; };
var ImageKind = { const ImageKind = {
GRAYSCALE_1BPP: 1, GRAYSCALE_1BPP: 1,
RGB_24BPP: 2, RGB_24BPP: 2,
RGBA_32BPP: 3, RGBA_32BPP: 3,
}; };
var AnnotationType = { const AnnotationType = {
TEXT: 1, TEXT: 1,
LINK: 2, LINK: 2,
FREETEXT: 3, FREETEXT: 3,
@ -85,7 +86,7 @@ var AnnotationType = {
REDACT: 26, REDACT: 26,
}; };
var AnnotationFlag = { const AnnotationFlag = {
INVISIBLE: 0x01, INVISIBLE: 0x01,
HIDDEN: 0x02, HIDDEN: 0x02,
PRINT: 0x04, PRINT: 0x04,
@ -98,7 +99,7 @@ var AnnotationFlag = {
LOCKEDCONTENTS: 0x200, LOCKEDCONTENTS: 0x200,
}; };
var AnnotationFieldFlag = { const AnnotationFieldFlag = {
READONLY: 0x0000001, READONLY: 0x0000001,
REQUIRED: 0x0000002, REQUIRED: 0x0000002,
NOEXPORT: 0x0000004, NOEXPORT: 0x0000004,
@ -120,7 +121,7 @@ var AnnotationFieldFlag = {
COMMITONSELCHANGE: 0x4000000, COMMITONSELCHANGE: 0x4000000,
}; };
var AnnotationBorderStyleType = { const AnnotationBorderStyleType = {
SOLID: 1, SOLID: 1,
DASHED: 2, DASHED: 2,
BEVELED: 3, BEVELED: 3,
@ -128,7 +129,7 @@ var AnnotationBorderStyleType = {
UNDERLINE: 5, UNDERLINE: 5,
}; };
var StreamType = { const StreamType = {
UNKNOWN: 0, UNKNOWN: 0,
FLATE: 1, FLATE: 1,
LZW: 2, LZW: 2,
@ -141,7 +142,7 @@ var StreamType = {
RL: 9, RL: 9,
}; };
var FontType = { const FontType = {
UNKNOWN: 0, UNKNOWN: 0,
TYPE1: 1, TYPE1: 1,
TYPE1C: 2, TYPE1C: 2,
@ -161,14 +162,14 @@ const VerbosityLevel = {
INFOS: 5, INFOS: 5,
}; };
var CMapCompressionType = { const CMapCompressionType = {
NONE: 0, NONE: 0,
BINARY: 1, BINARY: 1,
STREAM: 2, STREAM: 2,
}; };
// All the possible operations for an operator list. // All the possible operations for an operator list.
var OPS = { const OPS = {
// Intentionally start from 1 so it is easy to spot bad operators that will be // Intentionally start from 1 so it is easy to spot bad operators that will be
// 0's. // 0's.
dependency: 1, dependency: 1,
@ -264,6 +265,20 @@ var OPS = {
constructPath: 91, constructPath: 91,
}; };
const UNSUPPORTED_FEATURES = {
unknown: 'unknown',
forms: 'forms',
javaScript: 'javaScript',
smask: 'smask',
shadingPattern: 'shadingPattern',
font: 'font',
};
const PasswordResponses = {
NEED_PASSWORD: 1,
INCORRECT_PASSWORD: 2,
};
let verbosity = VerbosityLevel.WARNINGS; let verbosity = VerbosityLevel.WARNINGS;
function setVerbosityLevel(level) { function setVerbosityLevel(level) {
@ -307,15 +322,6 @@ function assert(cond, msg) {
} }
} }
var UNSUPPORTED_FEATURES = {
unknown: 'unknown',
forms: 'forms',
javaScript: 'javaScript',
smask: 'smask',
shadingPattern: 'shadingPattern',
font: 'font',
};
// Checks if URLs have the same origin. For non-HTTP based URLs, returns false. // Checks if URLs have the same origin. For non-HTTP based URLs, returns false.
function isSameOrigin(baseUrl, otherUrl) { function isSameOrigin(baseUrl, otherUrl) {
try { try {
@ -388,11 +394,6 @@ function getLookupTableFactory(initializer) {
}; };
} }
var PasswordResponses = {
NEED_PASSWORD: 1,
INCORRECT_PASSWORD: 2,
};
var PasswordException = (function PasswordExceptionClosure() { var PasswordException = (function PasswordExceptionClosure() {
function PasswordException(msg, code) { function PasswordException(msg, code) {
this.name = 'PasswordException'; this.name = 'PasswordException';
@ -693,8 +694,6 @@ function getInheritableProperty({ dict, key, getArray = false,
return values; return values;
} }
var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
var Util = (function UtilClosure() { var Util = (function UtilClosure() {
function Util() {} function Util() {}
@ -892,7 +891,7 @@ function toRomanNumerals(number, lowerCase = false) {
return (lowerCase ? romanStr.toLowerCase() : romanStr); return (lowerCase ? romanStr.toLowerCase() : romanStr);
} }
var PDFStringTranslateTable = [ const PDFStringTranslateTable = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0, 0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,