Remove the remaining closure in the src/core/cmap.js file

With modern JavaScript we (usually) no longer need to keep old closures, which slightly reduces the size of the code.
This commit is contained in:
Jonas Jenwald 2023-04-21 11:55:55 +02:00
parent 244002502b
commit cabc98f310

View File

@ -444,7 +444,6 @@ class IdentityCMap extends CMap {
} }
} }
const CMapFactory = (function CMapFactoryClosure() {
function strToInt(str) { function strToInt(str) {
let a = 0; let a = 0;
for (let i = 0; i < str.length; i++) { for (let i = 0; i < str.length; i++) {
@ -703,12 +702,8 @@ const CMapFactory = (function CMapFactoryClosure() {
throw new Error(`Invalid CMap "compressionType" value: ${compressionType}`); throw new Error(`Invalid CMap "compressionType" value: ${compressionType}`);
} }
return { class CMapFactory {
async create(params) { static async create({ encoding, fetchBuiltInCMap, useCMap }) {
const encoding = params.encoding;
const fetchBuiltInCMap = params.fetchBuiltInCMap;
const useCMap = params.useCMap;
if (encoding instanceof Name) { if (encoding instanceof Name) {
return createBuiltInCMap(encoding.name, fetchBuiltInCMap); return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
} else if (encoding instanceof BaseStream) { } else if (encoding instanceof BaseStream) {
@ -725,8 +720,7 @@ const CMapFactory = (function CMapFactoryClosure() {
return parsedCMap; return parsedCMap;
} }
throw new Error("Encoding required."); throw new Error("Encoding required.");
}, }
}; }
})();
export { CMap, CMapFactory, IdentityCMap }; export { CMap, CMapFactory, IdentityCMap };