1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Convert the DOMCMapReaderFactory to an ES6 class

Given that we only create *one* instance of this class per `getDocument` call, this shouldn't matter performance wise.
This commit is contained in:
Jonas Jenwald 2017-05-05 17:55:02 +02:00
parent 15425d5b9b
commit 32baa6af7a
2 changed files with 47 additions and 53 deletions

View file

@ -16,20 +16,19 @@
import { CMapCompressionType } from '../../src/shared/util';
class NodeCMapReaderFactory {
constructor(params) {
this.baseUrl = params.baseUrl || null;
this.isCompressed = params.isCompressed || false;
constructor({ baseUrl = null, isCompressed = false, }) {
this.baseUrl = baseUrl;
this.isCompressed = isCompressed;
}
fetch(params) {
var name = params.name;
fetch({ name, }) {
if (!name) {
return Promise.reject(new Error('CMap name must be specified.'));
}
return new Promise((resolve, reject) => {
var url = this.baseUrl + name + (this.isCompressed ? '.bcmap' : '');
let url = this.baseUrl + name + (this.isCompressed ? '.bcmap' : '');
var fs = require('fs');
let fs = require('fs');
fs.readFile(url, (error, data) => {
if (error || !data) {
reject(new Error('Unable to load ' +