1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Remove the isStream helper function

At this point all the various Stream-classes extends an abstract base-class, hence this helper function is no longer necessary and only adds unnecessary indirection in the code.
This commit is contained in:
Jonas Jenwald 2022-02-17 13:45:42 +01:00
parent d9a3a24353
commit 1a31855977
15 changed files with 51 additions and 80 deletions

View file

@ -42,7 +42,6 @@ import {
isDict,
isName,
isRef,
isStream,
Name,
Ref,
RefSet,
@ -340,7 +339,7 @@ class PartialEvaluator {
continue;
}
}
if (!isStream(xObject)) {
if (!(xObject instanceof BaseStream)) {
continue;
}
if (xObject.dict.objId) {
@ -1420,7 +1419,7 @@ class PartialEvaluator {
const pattern = this.xref.fetchIfRef(rawPattern);
if (pattern) {
const dict = isStream(pattern) ? pattern.dict : pattern;
const dict = pattern instanceof BaseStream ? pattern.dict : pattern;
const typeNum = dict.get("PatternType");
if (typeNum === PatternType.TILING) {
@ -1664,7 +1663,7 @@ class PartialEvaluator {
xobj = xref.fetch(xobj);
}
if (!isStream(xobj)) {
if (!(xobj instanceof BaseStream)) {
throw new FormatError("XObject should be a stream");
}
@ -2986,7 +2985,7 @@ class PartialEvaluator {
xobj = xref.fetch(xobj);
}
if (!isStream(xobj)) {
if (!(xobj instanceof BaseStream)) {
throw new FormatError("XObject should be a stream");
}
@ -3509,7 +3508,7 @@ class PartialEvaluator {
}
return new ToUnicodeMap(cmap.getMap());
});
} else if (isStream(cmapObj)) {
} else if (cmapObj instanceof BaseStream) {
return CMapFactory.create({
encoding: cmapObj,
fetchBuiltInCMap: this._fetchBuiltInCMapBound,
@ -3813,7 +3812,7 @@ class PartialEvaluator {
hash.update(`${firstChar}-${lastChar}`); // Fixes issue10665_reduced.pdf
toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
if (isStream(toUnicode)) {
if (toUnicode instanceof BaseStream) {
const stream = toUnicode.str || toUnicode;
const uint8array = stream.buffer
? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength)