Replace the isInt
helper function with the native Number.isInteger
function
*Follow-up to PR 8643.*
This commit is contained in:
parent
066fea9c8b
commit
11408da340
@ -15,8 +15,7 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
AnnotationBorderStyleType, AnnotationFieldFlag, AnnotationFlag,
|
AnnotationBorderStyleType, AnnotationFieldFlag, AnnotationFlag,
|
||||||
AnnotationType, isArray, isInt, OPS, stringToBytes, stringToPDFString, Util,
|
AnnotationType, isArray, OPS, stringToBytes, stringToPDFString, Util, warn
|
||||||
warn
|
|
||||||
} from '../shared/util';
|
} from '../shared/util';
|
||||||
import { Catalog, FileSpec, ObjectLoader } from './obj';
|
import { Catalog, FileSpec, ObjectLoader } from './obj';
|
||||||
import { Dict, isDict, isName, isRef, isStream } from './primitives';
|
import { Dict, isDict, isName, isRef, isStream } from './primitives';
|
||||||
@ -212,7 +211,7 @@ class Annotation {
|
|||||||
* @see {@link shared/util.js}
|
* @see {@link shared/util.js}
|
||||||
*/
|
*/
|
||||||
setFlags(flags) {
|
setFlags(flags) {
|
||||||
this.flags = (isInt(flags) && flags > 0) ? flags : 0;
|
this.flags = (Number.isInteger(flags) && flags > 0) ? flags : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -575,7 +574,7 @@ class WidgetAnnotation extends Annotation {
|
|||||||
this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
|
this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
|
||||||
|
|
||||||
data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
|
data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
|
||||||
if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
|
if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) {
|
||||||
data.fieldFlags = 0;
|
data.fieldFlags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,14 +665,14 @@ class TextWidgetAnnotation extends WidgetAnnotation {
|
|||||||
|
|
||||||
// Determine the alignment of text in the field.
|
// Determine the alignment of text in the field.
|
||||||
let alignment = Util.getInheritableProperty(params.dict, 'Q');
|
let alignment = Util.getInheritableProperty(params.dict, 'Q');
|
||||||
if (!isInt(alignment) || alignment < 0 || alignment > 2) {
|
if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) {
|
||||||
alignment = null;
|
alignment = null;
|
||||||
}
|
}
|
||||||
this.data.textAlignment = alignment;
|
this.data.textAlignment = alignment;
|
||||||
|
|
||||||
// Determine the maximum length of text in the field.
|
// Determine the maximum length of text in the field.
|
||||||
let maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
|
let maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
|
||||||
if (!isInt(maximumLength) || maximumLength < 0) {
|
if (!Number.isInteger(maximumLength) || maximumLength < 0) {
|
||||||
maximumLength = null;
|
maximumLength = null;
|
||||||
}
|
}
|
||||||
this.data.maxLen = maximumLength;
|
this.data.maxLen = maximumLength;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
arrayByteLength, arraysToBytes, createPromiseCapability, isEmptyObj, isInt,
|
arrayByteLength, arraysToBytes, createPromiseCapability, isEmptyObj,
|
||||||
MissingDataException
|
MissingDataException
|
||||||
} from '../shared/util';
|
} from '../shared/util';
|
||||||
|
|
||||||
@ -518,7 +518,7 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
|||||||
} else {
|
} else {
|
||||||
nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
|
nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
|
||||||
}
|
}
|
||||||
if (isInt(nextEmptyChunk)) {
|
if (Number.isInteger(nextEmptyChunk)) {
|
||||||
this._requestChunks([nextEmptyChunk]);
|
this._requestChunks([nextEmptyChunk]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CMapCompressionType, FormatError, isInt, isString, MissingDataException, Util,
|
CMapCompressionType, FormatError, isString, MissingDataException, Util, warn
|
||||||
warn
|
|
||||||
} from '../shared/util';
|
} from '../shared/util';
|
||||||
import { isCmd, isEOF, isName, isStream } from './primitives';
|
import { isCmd, isEOF, isName, isStream } from './primitives';
|
||||||
import { Lexer } from './parser';
|
import { Lexer } from './parser';
|
||||||
@ -370,11 +369,11 @@ var IdentityCMap = (function IdentityCMapClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
lookup(code) {
|
lookup(code) {
|
||||||
return (isInt(code) && code <= 0xffff) ? code : undefined;
|
return (Number.isInteger(code) && code <= 0xffff) ? code : undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
contains(code) {
|
contains(code) {
|
||||||
return isInt(code) && code <= 0xffff;
|
return Number.isInteger(code) && code <= 0xffff;
|
||||||
},
|
},
|
||||||
|
|
||||||
forEach(callback) {
|
forEach(callback) {
|
||||||
@ -384,7 +383,7 @@ var IdentityCMap = (function IdentityCMapClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
charCodeOf(value) {
|
charCodeOf(value) {
|
||||||
return (isInt(value) && value <= 0xffff) ? value : -1;
|
return (Number.isInteger(value) && value <= 0xffff) ? value : -1;
|
||||||
},
|
},
|
||||||
|
|
||||||
getMap() {
|
getMap() {
|
||||||
@ -718,7 +717,7 @@ var CMapFactory = (function CMapFactoryClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function expectInt(obj) {
|
function expectInt(obj) {
|
||||||
if (!isInt(obj)) {
|
if (!Number.isInteger(obj)) {
|
||||||
throw new FormatError('Malformed CMap: expected int.');
|
throw new FormatError('Malformed CMap: expected int.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -757,8 +756,8 @@ var CMapFactory = (function CMapFactoryClosure() {
|
|||||||
expectString(obj);
|
expectString(obj);
|
||||||
var high = strToInt(obj);
|
var high = strToInt(obj);
|
||||||
obj = lexer.getObj();
|
obj = lexer.getObj();
|
||||||
if (isInt(obj) || isString(obj)) {
|
if (Number.isInteger(obj) || isString(obj)) {
|
||||||
var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
|
var dstLow = Number.isInteger(obj) ? String.fromCharCode(obj) : obj;
|
||||||
cMap.mapBfRange(low, high, dstLow);
|
cMap.mapBfRange(low, high, dstLow);
|
||||||
} else if (isCmd(obj, '[')) {
|
} else if (isCmd(obj, '[')) {
|
||||||
obj = lexer.getObj();
|
obj = lexer.getObj();
|
||||||
@ -839,7 +838,7 @@ var CMapFactory = (function CMapFactoryClosure() {
|
|||||||
|
|
||||||
function parseWMode(cMap, lexer) {
|
function parseWMode(cMap, lexer) {
|
||||||
var obj = lexer.getObj();
|
var obj = lexer.getObj();
|
||||||
if (isInt(obj)) {
|
if (Number.isInteger(obj)) {
|
||||||
cMap.vertical = !!obj;
|
cMap.vertical = !!obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
bytesToString, FormatError, isInt, PasswordException, PasswordResponses,
|
bytesToString, FormatError, PasswordException, PasswordResponses,
|
||||||
stringToBytes, utf8StringToString, warn
|
stringToBytes, utf8StringToString, warn
|
||||||
} from '../shared/util';
|
} from '../shared/util';
|
||||||
import { isDict, isName, Name } from './primitives';
|
import { isDict, isName, Name } from './primitives';
|
||||||
@ -1862,7 +1862,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
|
|||||||
}
|
}
|
||||||
this.dict = dict;
|
this.dict = dict;
|
||||||
var algorithm = dict.get('V');
|
var algorithm = dict.get('V');
|
||||||
if (!isInt(algorithm) ||
|
if (!Number.isInteger(algorithm) ||
|
||||||
(algorithm !== 1 && algorithm !== 2 && algorithm !== 4 &&
|
(algorithm !== 1 && algorithm !== 2 && algorithm !== 4 &&
|
||||||
algorithm !== 5)) {
|
algorithm !== 5)) {
|
||||||
throw new FormatError('unsupported encryption algorithm');
|
throw new FormatError('unsupported encryption algorithm');
|
||||||
@ -1890,7 +1890,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isInt(keyLength) ||
|
if (!Number.isInteger(keyLength) ||
|
||||||
keyLength < 40 || (keyLength % 8) !== 0) {
|
keyLength < 40 || (keyLength % 8) !== 0) {
|
||||||
throw new FormatError('invalid key length');
|
throw new FormatError('invalid key length');
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
bytesToString, FONT_IDENTITY_MATRIX, FontType, FormatError, info, isArray,
|
bytesToString, FONT_IDENTITY_MATRIX, FontType, FormatError, info, isArray,
|
||||||
isInt, isNum, isSpace, MissingDataException, readUint32, shadow, string32,
|
isNum, isSpace, MissingDataException, readUint32, shadow, string32, warn
|
||||||
warn
|
|
||||||
} from '../shared/util';
|
} from '../shared/util';
|
||||||
import {
|
import {
|
||||||
CFF, CFFCharset, CFFCompiler, CFFHeader, CFFIndex, CFFParser, CFFPrivateDict,
|
CFF, CFFCharset, CFFCompiler, CFFHeader, CFFIndex, CFFParser, CFFPrivateDict,
|
||||||
@ -291,7 +290,8 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
charCodeOf(v) {
|
charCodeOf(v) {
|
||||||
return (isInt(v) && v >= this.firstChar && v <= this.lastChar) ? v : -1;
|
return (Number.isInteger(v) &&
|
||||||
|
v >= this.firstChar && v <= this.lastChar) ? v : -1;
|
||||||
},
|
},
|
||||||
|
|
||||||
amend(map) {
|
amend(map) {
|
||||||
|
@ -15,9 +15,8 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
bytesToString, createPromiseCapability, createValidAbsoluteUrl, FormatError,
|
bytesToString, createPromiseCapability, createValidAbsoluteUrl, FormatError,
|
||||||
info, InvalidPDFException, isArray, isBool, isInt, isString,
|
info, InvalidPDFException, isArray, isBool, isString, MissingDataException,
|
||||||
MissingDataException, shadow, stringToPDFString, stringToUTF8String, Util,
|
shadow, stringToPDFString, stringToUTF8String, Util, warn, XRefParseException
|
||||||
warn, XRefParseException
|
|
||||||
} from '../shared/util';
|
} from '../shared/util';
|
||||||
import {
|
import {
|
||||||
Dict, isCmd, isDict, isName, isRef, isRefsEqual, isStream, Ref, RefSet,
|
Dict, isCmd, isDict, isName, isRef, isRefsEqual, isStream, Ref, RefSet,
|
||||||
@ -169,7 +168,7 @@ var Catalog = (function CatalogClosure() {
|
|||||||
},
|
},
|
||||||
get numPages() {
|
get numPages() {
|
||||||
var obj = this.toplevelPagesDict.get('Count');
|
var obj = this.toplevelPagesDict.get('Count');
|
||||||
if (!isInt(obj)) {
|
if (!Number.isInteger(obj)) {
|
||||||
throw new FormatError(
|
throw new FormatError(
|
||||||
'page count in top level pages object is not an integer');
|
'page count in top level pages object is not an integer');
|
||||||
}
|
}
|
||||||
@ -286,7 +285,7 @@ var Catalog = (function CatalogClosure() {
|
|||||||
prefix = p ? stringToPDFString(p) : '';
|
prefix = p ? stringToPDFString(p) : '';
|
||||||
|
|
||||||
var st = labelDict.get('St');
|
var st = labelDict.get('St');
|
||||||
if (st && !(isInt(st) && st >= 1)) {
|
if (st && !(Number.isInteger(st) && st >= 1)) {
|
||||||
throw new FormatError('Invalid start in PageLabel dictionary.');
|
throw new FormatError('Invalid start in PageLabel dictionary.');
|
||||||
}
|
}
|
||||||
currentIndex = st || 1;
|
currentIndex = st || 1;
|
||||||
@ -912,7 +911,7 @@ var XRef = (function XRefClosure() {
|
|||||||
|
|
||||||
var first = tableState.firstEntryNum;
|
var first = tableState.firstEntryNum;
|
||||||
var count = tableState.entryCount;
|
var count = tableState.entryCount;
|
||||||
if (!isInt(first) || !isInt(count)) {
|
if (!Number.isInteger(first) || !Number.isInteger(count)) {
|
||||||
throw new FormatError(
|
throw new FormatError(
|
||||||
'Invalid XRef table: wrong types in subsection header');
|
'Invalid XRef table: wrong types in subsection header');
|
||||||
}
|
}
|
||||||
@ -935,7 +934,7 @@ var XRef = (function XRefClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate entry obj
|
// Validate entry obj
|
||||||
if (!isInt(entry.offset) || !isInt(entry.gen) ||
|
if (!Number.isInteger(entry.offset) || !Number.isInteger(entry.gen) ||
|
||||||
!(entry.free || entry.uncompressed)) {
|
!(entry.free || entry.uncompressed)) {
|
||||||
throw new FormatError(
|
throw new FormatError(
|
||||||
`Invalid entry in XRef subsection: ${first}, ${count}`);
|
`Invalid entry in XRef subsection: ${first}, ${count}`);
|
||||||
@ -1007,12 +1006,13 @@ var XRef = (function XRefClosure() {
|
|||||||
var first = entryRanges[0];
|
var first = entryRanges[0];
|
||||||
var n = entryRanges[1];
|
var n = entryRanges[1];
|
||||||
|
|
||||||
if (!isInt(first) || !isInt(n)) {
|
if (!Number.isInteger(first) || !Number.isInteger(n)) {
|
||||||
throw new FormatError(
|
throw new FormatError(
|
||||||
`Invalid XRef range fields: ${first}, ${n}`);
|
`Invalid XRef range fields: ${first}, ${n}`);
|
||||||
}
|
}
|
||||||
if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) ||
|
if (!Number.isInteger(typeFieldWidth) ||
|
||||||
!isInt(generationFieldWidth)) {
|
!Number.isInteger(offsetFieldWidth) ||
|
||||||
|
!Number.isInteger(generationFieldWidth)) {
|
||||||
throw new FormatError(
|
throw new FormatError(
|
||||||
`Invalid XRef entry fields length: ${first}, ${n}`);
|
`Invalid XRef entry fields length: ${first}, ${n}`);
|
||||||
}
|
}
|
||||||
@ -1229,7 +1229,7 @@ var XRef = (function XRefClosure() {
|
|||||||
|
|
||||||
// Recursively get other XRefs 'XRefStm', if any
|
// Recursively get other XRefs 'XRefStm', if any
|
||||||
obj = dict.get('XRefStm');
|
obj = dict.get('XRefStm');
|
||||||
if (isInt(obj)) {
|
if (Number.isInteger(obj)) {
|
||||||
var pos = obj;
|
var pos = obj;
|
||||||
// ignore previously loaded xref streams
|
// ignore previously loaded xref streams
|
||||||
// (possible infinite recursion)
|
// (possible infinite recursion)
|
||||||
@ -1238,9 +1238,9 @@ var XRef = (function XRefClosure() {
|
|||||||
this.startXRefQueue.push(pos);
|
this.startXRefQueue.push(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (isInt(obj)) {
|
} else if (Number.isInteger(obj)) {
|
||||||
// Parse in-stream XRef
|
// Parse in-stream XRef
|
||||||
if (!isInt(parser.getObj()) ||
|
if (!Number.isInteger(parser.getObj()) ||
|
||||||
!isCmd(parser.getObj(), 'obj') ||
|
!isCmd(parser.getObj(), 'obj') ||
|
||||||
!isStream(obj = parser.getObj())) {
|
!isStream(obj = parser.getObj())) {
|
||||||
throw new FormatError('Invalid XRef stream');
|
throw new FormatError('Invalid XRef stream');
|
||||||
@ -1258,7 +1258,7 @@ var XRef = (function XRefClosure() {
|
|||||||
|
|
||||||
// Recursively get previous dictionary, if any
|
// Recursively get previous dictionary, if any
|
||||||
obj = dict.get('Prev');
|
obj = dict.get('Prev');
|
||||||
if (isInt(obj)) {
|
if (Number.isInteger(obj)) {
|
||||||
this.startXRefQueue.push(obj);
|
this.startXRefQueue.push(obj);
|
||||||
} else if (isRef(obj)) {
|
} else if (isRef(obj)) {
|
||||||
// The spec says Prev must not be a reference, i.e. "/Prev NNN"
|
// The spec says Prev must not be a reference, i.e. "/Prev NNN"
|
||||||
@ -1386,7 +1386,7 @@ var XRef = (function XRefClosure() {
|
|||||||
}
|
}
|
||||||
var first = stream.dict.get('First');
|
var first = stream.dict.get('First');
|
||||||
var n = stream.dict.get('N');
|
var n = stream.dict.get('N');
|
||||||
if (!isInt(first) || !isInt(n)) {
|
if (!Number.isInteger(first) || !Number.isInteger(n)) {
|
||||||
throw new FormatError(
|
throw new FormatError(
|
||||||
'invalid first and n parameters for ObjStm stream');
|
'invalid first and n parameters for ObjStm stream');
|
||||||
}
|
}
|
||||||
@ -1396,13 +1396,13 @@ var XRef = (function XRefClosure() {
|
|||||||
// read the object numbers to populate cache
|
// read the object numbers to populate cache
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
num = parser.getObj();
|
num = parser.getObj();
|
||||||
if (!isInt(num)) {
|
if (!Number.isInteger(num)) {
|
||||||
throw new FormatError(
|
throw new FormatError(
|
||||||
`invalid object number in the ObjStm stream: ${num}`);
|
`invalid object number in the ObjStm stream: ${num}`);
|
||||||
}
|
}
|
||||||
nums.push(num);
|
nums.push(num);
|
||||||
var offset = parser.getObj();
|
var offset = parser.getObj();
|
||||||
if (!isInt(offset)) {
|
if (!Number.isInteger(offset)) {
|
||||||
throw new FormatError(
|
throw new FormatError(
|
||||||
`invalid object offset in the ObjStm stream: ${offset}`);
|
`invalid object offset in the ObjStm stream: ${offset}`);
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ import {
|
|||||||
JpegStream, JpxStream, LZWStream, NullStream, PredictorStream, RunLengthStream
|
JpegStream, JpxStream, LZWStream, NullStream, PredictorStream, RunLengthStream
|
||||||
} from './stream';
|
} from './stream';
|
||||||
import {
|
import {
|
||||||
assert, FormatError, info, isArray, isInt, isNum, isString,
|
assert, FormatError, info, isArray, isNum, isString, MissingDataException,
|
||||||
MissingDataException, StreamType, warn
|
StreamType, warn
|
||||||
} from '../shared/util';
|
} from '../shared/util';
|
||||||
import {
|
import {
|
||||||
Cmd, Dict, EOF, isCmd, isDict, isEOF, isName, Name, Ref
|
Cmd, Dict, EOF, isCmd, isDict, isEOF, isName, Name, Ref
|
||||||
@ -121,9 +121,9 @@ var Parser = (function ParserClosure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInt(buf1)) { // indirect reference or integer
|
if (Number.isInteger(buf1)) { // indirect reference or integer
|
||||||
var num = buf1;
|
var num = buf1;
|
||||||
if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
|
if (Number.isInteger(this.buf1) && isCmd(this.buf2, 'R')) {
|
||||||
var ref = new Ref(num, this.buf1);
|
var ref = new Ref(num, this.buf1);
|
||||||
this.shift();
|
this.shift();
|
||||||
this.shift();
|
this.shift();
|
||||||
@ -456,7 +456,7 @@ var Parser = (function ParserClosure() {
|
|||||||
|
|
||||||
// get length
|
// get length
|
||||||
var length = dict.get('Length');
|
var length = dict.get('Length');
|
||||||
if (!isInt(length)) {
|
if (!Number.isInteger(length)) {
|
||||||
info('Bad ' + length + ' attribute in stream');
|
info('Bad ' + length + ' attribute in stream');
|
||||||
length = 0;
|
length = 0;
|
||||||
}
|
}
|
||||||
@ -1069,7 +1069,7 @@ var Linearization = {
|
|||||||
create: function LinearizationCreate(stream) {
|
create: function LinearizationCreate(stream) {
|
||||||
function getInt(name, allowZeroValue) {
|
function getInt(name, allowZeroValue) {
|
||||||
var obj = linDict.get(name);
|
var obj = linDict.get(name);
|
||||||
if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
|
if (Number.isInteger(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
throw new Error('The "' + name + '" parameter in the linearization ' +
|
throw new Error('The "' + name + '" parameter in the linearization ' +
|
||||||
@ -1080,7 +1080,7 @@ var Linearization = {
|
|||||||
if (isArray(hints) &&
|
if (isArray(hints) &&
|
||||||
((hintsLength = hints.length) === 2 || hintsLength === 4)) {
|
((hintsLength = hints.length) === 2 || hintsLength === 4)) {
|
||||||
for (var index = 0; index < hintsLength; index++) {
|
for (var index = 0; index < hintsLength; index++) {
|
||||||
if (!(isInt(item = hints[index]) && item > 0)) {
|
if (!(Number.isInteger(item = hints[index]) && item > 0)) {
|
||||||
throw new Error('Hint (' + index +
|
throw new Error('Hint (' + index +
|
||||||
') in the linearization dictionary is invalid.');
|
') in the linearization dictionary is invalid.');
|
||||||
}
|
}
|
||||||
@ -1095,7 +1095,8 @@ var Linearization = {
|
|||||||
var obj3 = parser.getObj();
|
var obj3 = parser.getObj();
|
||||||
var linDict = parser.getObj();
|
var linDict = parser.getObj();
|
||||||
var obj, length;
|
var obj, length;
|
||||||
if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) &&
|
if (!(Number.isInteger(obj1) && Number.isInteger(obj2) &&
|
||||||
|
isCmd(obj3, 'obj') && isDict(linDict) &&
|
||||||
isNum(obj = linDict.get('Linearized')) && obj > 0)) {
|
isNum(obj = linDict.get('Linearized')) && obj > 0)) {
|
||||||
return null; // No valid linearization dictionary found.
|
return null; // No valid linearization dictionary found.
|
||||||
} else if ((length = getInt('L')) !== stream.length) {
|
} else if ((length = getInt('L')) !== stream.length) {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createObjectURL, FormatError, info, isArray, isInt, isSpace, shadow, Util
|
createObjectURL, FormatError, info, isArray, isSpace, shadow, Util
|
||||||
} from '../shared/util';
|
} from '../shared/util';
|
||||||
import { Dict, isDict, isStream } from './primitives';
|
import { Dict, isDict, isStream } from './primitives';
|
||||||
import { Jbig2Image } from './jbig2';
|
import { Jbig2Image } from './jbig2';
|
||||||
@ -927,7 +927,7 @@ var JpegStream = (function JpegStreamClosure() {
|
|||||||
// Fetching the 'ColorTransform' entry, if it exists.
|
// Fetching the 'ColorTransform' entry, if it exists.
|
||||||
if (isDict(this.params)) {
|
if (isDict(this.params)) {
|
||||||
var colorTransform = this.params.get('ColorTransform');
|
var colorTransform = this.params.get('ColorTransform');
|
||||||
if (isInt(colorTransform)) {
|
if (Number.isInteger(colorTransform)) {
|
||||||
jpegImage.colorTransform = colorTransform;
|
jpegImage.colorTransform = colorTransform;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
/* globals requirejs, __non_webpack_require__ */
|
/* globals requirejs, __non_webpack_require__ */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
assert, createPromiseCapability, deprecated, getVerbosityLevel,
|
assert, createPromiseCapability, deprecated, getVerbosityLevel, info,
|
||||||
info, InvalidPDFException, isArrayBuffer, isInt, isSameOrigin,
|
InvalidPDFException, isArrayBuffer, isSameOrigin, loadJpegStream,
|
||||||
loadJpegStream, MessageHandler, MissingPDFException, NativeImageDecoding,
|
MessageHandler, MissingPDFException, NativeImageDecoding, PageViewport,
|
||||||
PageViewport, PasswordException, StatTimer, stringToBytes,
|
PasswordException, StatTimer, stringToBytes, UnexpectedResponseException,
|
||||||
UnexpectedResponseException, UnknownErrorException, Util, warn
|
UnknownErrorException, Util, warn
|
||||||
} from '../shared/util';
|
} from '../shared/util';
|
||||||
import {
|
import {
|
||||||
DOMCanvasFactory, DOMCMapReaderFactory, getDefaultSetting,
|
DOMCanvasFactory, DOMCMapReaderFactory, getDefaultSetting,
|
||||||
@ -1986,7 +1986,8 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getPage: function WorkerTransport_getPage(pageNumber, capability) {
|
getPage: function WorkerTransport_getPage(pageNumber, capability) {
|
||||||
if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
|
if (!Number.isInteger(pageNumber) ||
|
||||||
|
pageNumber <= 0 || pageNumber > this.numPages) {
|
||||||
return Promise.reject(new Error('Invalid page request'));
|
return Promise.reject(new Error('Invalid page request'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { assert, isInt, MissingPDFException, UnexpectedResponseException
|
import {
|
||||||
|
assert, MissingPDFException, UnexpectedResponseException
|
||||||
} from '../shared/util';
|
} from '../shared/util';
|
||||||
|
|
||||||
function validateRangeRequestCapabilities({ getResponseHeader, isHttp,
|
function validateRangeRequestCapabilities({ getResponseHeader, isHttp,
|
||||||
@ -35,17 +36,15 @@ function validateRangeRequestCapabilities({ getResponseHeader, isHttp,
|
|||||||
return returnValues;
|
return returnValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
let length = getResponseHeader('Content-Length');
|
let length = parseInt(getResponseHeader('Content-Length'), 10);
|
||||||
length = parseInt(length, 10);
|
if (!Number.isInteger(length)) {
|
||||||
if (!isInt(length)) {
|
|
||||||
return returnValues;
|
return returnValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
returnValues.suggestedLength = length;
|
returnValues.suggestedLength = length;
|
||||||
if (length <= 2 * rangeChunkSize) {
|
if (length <= 2 * rangeChunkSize) {
|
||||||
// The file size is smaller than the size of two chunks, so it does
|
// The file size is smaller than the size of two chunks, so it does not
|
||||||
// not make any sense to abort the request and retry with a range
|
// make any sense to abort the request and retry with a range request.
|
||||||
// request.
|
|
||||||
return returnValues;
|
return returnValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,7 +817,7 @@ var Util = (function UtilClosure() {
|
|||||||
* @return {string} The resulting Roman number.
|
* @return {string} The resulting Roman number.
|
||||||
*/
|
*/
|
||||||
Util.toRoman = function Util_toRoman(number, lowerCase) {
|
Util.toRoman = function Util_toRoman(number, lowerCase) {
|
||||||
assert(isInt(number) && number > 0,
|
assert(Number.isInteger(number) && number > 0,
|
||||||
'The number should be a positive integer.');
|
'The number should be a positive integer.');
|
||||||
var pos, romanBuf = [];
|
var pos, romanBuf = [];
|
||||||
// Thousands
|
// Thousands
|
||||||
@ -1075,10 +1075,6 @@ function isBool(v) {
|
|||||||
return typeof v === 'boolean';
|
return typeof v === 'boolean';
|
||||||
}
|
}
|
||||||
|
|
||||||
function isInt(v) {
|
|
||||||
return typeof v === 'number' && ((v | 0) === v);
|
|
||||||
}
|
|
||||||
|
|
||||||
function isNum(v) {
|
function isNum(v) {
|
||||||
return typeof v === 'number';
|
return typeof v === 'number';
|
||||||
}
|
}
|
||||||
@ -1703,7 +1699,6 @@ export {
|
|||||||
isArrayBuffer,
|
isArrayBuffer,
|
||||||
isBool,
|
isBool,
|
||||||
isEmptyObj,
|
isEmptyObj,
|
||||||
isInt,
|
|
||||||
isNum,
|
isNum,
|
||||||
isString,
|
isString,
|
||||||
isSpace,
|
isSpace,
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
import {
|
import {
|
||||||
PRIVATE_USE_OFFSET_END, PRIVATE_USE_OFFSET_START, ProblematicCharRanges
|
PRIVATE_USE_OFFSET_END, PRIVATE_USE_OFFSET_START, ProblematicCharRanges
|
||||||
} from '../../src/core/fonts';
|
} from '../../src/core/fonts';
|
||||||
import { isInt } from '../../src/shared/util';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to validate the entries in `ProblematicCharRanges`, and to ensure that
|
* Used to validate the entries in `ProblematicCharRanges`, and to ensure that
|
||||||
@ -41,7 +40,7 @@ var checkProblematicCharRanges = function checkProblematicCharRanges() {
|
|||||||
lower: ProblematicCharRanges[i],
|
lower: ProblematicCharRanges[i],
|
||||||
upper: ProblematicCharRanges[i + 1],
|
upper: ProblematicCharRanges[i + 1],
|
||||||
};
|
};
|
||||||
if (!isInt(limits.lower) || !isInt(limits.upper)) {
|
if (!Number.isInteger(limits.lower) || !Number.isInteger(limits.upper)) {
|
||||||
throw new Error('Range endpoints must be integers: ' +
|
throw new Error('Range endpoints must be integers: ' +
|
||||||
printRange(limits));
|
printRange(limits));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user