Skip to content

Commit

Permalink
Use the const keyword for constants in src/shared/util.js
Browse files Browse the repository at this point in the history
Moreover, move general constants to the top of the file, i.e., those
that are not closely tied to a function in the file.
  • Loading branch information
timvandermeij committed Sep 11, 2018
1 parent 9463a28 commit e362d96
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import './compatibility';
import { ReadableStream } from './streams_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 = {
NONE: 'none',
Expand All @@ -37,7 +38,7 @@ const PermissionFlag = {
PRINT_HIGH_QUALITY: 0x800,
};

var TextRenderingMode = {
const TextRenderingMode = {
FILL: 0,
STROKE: 1,
FILL_STROKE: 2,
Expand All @@ -50,13 +51,13 @@ var TextRenderingMode = {
ADD_TO_PATH_FLAG: 4,
};

var ImageKind = {
const ImageKind = {
GRAYSCALE_1BPP: 1,
RGB_24BPP: 2,
RGBA_32BPP: 3,
};

var AnnotationType = {
const AnnotationType = {
TEXT: 1,
LINK: 2,
FREETEXT: 3,
Expand Down Expand Up @@ -85,7 +86,7 @@ var AnnotationType = {
REDACT: 26,
};

var AnnotationFlag = {
const AnnotationFlag = {
INVISIBLE: 0x01,
HIDDEN: 0x02,
PRINT: 0x04,
Expand All @@ -98,7 +99,7 @@ var AnnotationFlag = {
LOCKEDCONTENTS: 0x200,
};

var AnnotationFieldFlag = {
const AnnotationFieldFlag = {
READONLY: 0x0000001,
REQUIRED: 0x0000002,
NOEXPORT: 0x0000004,
Expand All @@ -120,15 +121,15 @@ var AnnotationFieldFlag = {
COMMITONSELCHANGE: 0x4000000,
};

var AnnotationBorderStyleType = {
const AnnotationBorderStyleType = {
SOLID: 1,
DASHED: 2,
BEVELED: 3,
INSET: 4,
UNDERLINE: 5,
};

var StreamType = {
const StreamType = {
UNKNOWN: 0,
FLATE: 1,
LZW: 2,
Expand All @@ -141,7 +142,7 @@ var StreamType = {
RL: 9,
};

var FontType = {
const FontType = {
UNKNOWN: 0,
TYPE1: 1,
TYPE1C: 2,
Expand All @@ -161,14 +162,14 @@ const VerbosityLevel = {
INFOS: 5,
};

var CMapCompressionType = {
const CMapCompressionType = {
NONE: 0,
BINARY: 1,
STREAM: 2,
};

// 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
// 0's.
dependency: 1,
Expand Down Expand Up @@ -264,6 +265,20 @@ var OPS = {
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;

function setVerbosityLevel(level) {
Expand Down Expand Up @@ -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.
function isSameOrigin(baseUrl, otherUrl) {
try {
Expand Down Expand Up @@ -388,11 +394,6 @@ function getLookupTableFactory(initializer) {
};
}

var PasswordResponses = {
NEED_PASSWORD: 1,
INCORRECT_PASSWORD: 2,
};

var PasswordException = (function PasswordExceptionClosure() {
function PasswordException(msg, code) {
this.name = 'PasswordException';
Expand Down Expand Up @@ -693,8 +694,6 @@ function getInheritableProperty({ dict, key, getArray = false,
return values;
}

var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];

var Util = (function UtilClosure() {
function Util() {}

Expand Down Expand Up @@ -892,7 +891,7 @@ function toRomanNumerals(number, lowerCase = false) {
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,
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,
Expand Down

0 comments on commit e362d96

Please sign in to comment.