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