Rename map
to _map
inside of Dict
, to make it clearer that it should be regarded as a "private" property
This commit is contained in:
parent
3a20fd165f
commit
73234577e1
@ -60,7 +60,7 @@ var Dict = (function DictClosure() {
|
|||||||
// xref is optional
|
// xref is optional
|
||||||
function Dict(xref) {
|
function Dict(xref) {
|
||||||
// Map should only be used internally, use functions below to access.
|
// Map should only be used internally, use functions below to access.
|
||||||
this.map = Object.create(null);
|
this._map = Object.create(null);
|
||||||
this.xref = xref;
|
this.xref = xref;
|
||||||
this.objId = null;
|
this.objId = null;
|
||||||
this.suppressEncryption = false;
|
this.suppressEncryption = false;
|
||||||
@ -76,15 +76,15 @@ var Dict = (function DictClosure() {
|
|||||||
get: function Dict_get(key1, key2, key3) {
|
get: function Dict_get(key1, key2, key3) {
|
||||||
var value;
|
var value;
|
||||||
var xref = this.xref, suppressEncryption = this.suppressEncryption;
|
var xref = this.xref, suppressEncryption = this.suppressEncryption;
|
||||||
if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map ||
|
if (typeof (value = this._map[key1]) !== 'undefined' ||
|
||||||
typeof key2 === 'undefined') {
|
key1 in this._map || typeof key2 === 'undefined') {
|
||||||
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
|
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
|
||||||
}
|
}
|
||||||
if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map ||
|
if (typeof (value = this._map[key2]) !== 'undefined' ||
|
||||||
typeof key3 === 'undefined') {
|
key2 in this._map || typeof key3 === 'undefined') {
|
||||||
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
|
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
|
||||||
}
|
}
|
||||||
value = this.map[key3] || null;
|
value = this._map[key3] || null;
|
||||||
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
|
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -92,21 +92,21 @@ var Dict = (function DictClosure() {
|
|||||||
getAsync: function Dict_getAsync(key1, key2, key3) {
|
getAsync: function Dict_getAsync(key1, key2, key3) {
|
||||||
var value;
|
var value;
|
||||||
var xref = this.xref, suppressEncryption = this.suppressEncryption;
|
var xref = this.xref, suppressEncryption = this.suppressEncryption;
|
||||||
if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map ||
|
if (typeof (value = this._map[key1]) !== 'undefined' ||
|
||||||
typeof key2 === 'undefined') {
|
key1 in this._map || typeof key2 === 'undefined') {
|
||||||
if (xref) {
|
if (xref) {
|
||||||
return xref.fetchIfRefAsync(value, suppressEncryption);
|
return xref.fetchIfRefAsync(value, suppressEncryption);
|
||||||
}
|
}
|
||||||
return Promise.resolve(value);
|
return Promise.resolve(value);
|
||||||
}
|
}
|
||||||
if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map ||
|
if (typeof (value = this._map[key2]) !== 'undefined' ||
|
||||||
typeof key3 === 'undefined') {
|
key2 in this._map || typeof key3 === 'undefined') {
|
||||||
if (xref) {
|
if (xref) {
|
||||||
return xref.fetchIfRefAsync(value, suppressEncryption);
|
return xref.fetchIfRefAsync(value, suppressEncryption);
|
||||||
}
|
}
|
||||||
return Promise.resolve(value);
|
return Promise.resolve(value);
|
||||||
}
|
}
|
||||||
value = this.map[key3] || null;
|
value = this._map[key3] || null;
|
||||||
if (xref) {
|
if (xref) {
|
||||||
return xref.fetchIfRefAsync(value, suppressEncryption);
|
return xref.fetchIfRefAsync(value, suppressEncryption);
|
||||||
}
|
}
|
||||||
@ -132,23 +132,23 @@ var Dict = (function DictClosure() {
|
|||||||
|
|
||||||
// no dereferencing
|
// no dereferencing
|
||||||
getRaw: function Dict_getRaw(key) {
|
getRaw: function Dict_getRaw(key) {
|
||||||
return this.map[key];
|
return this._map[key];
|
||||||
},
|
},
|
||||||
|
|
||||||
getKeys: function Dict_getKeys() {
|
getKeys: function Dict_getKeys() {
|
||||||
return Object.keys(this.map);
|
return Object.keys(this._map);
|
||||||
},
|
},
|
||||||
|
|
||||||
set: function Dict_set(key, value) {
|
set: function Dict_set(key, value) {
|
||||||
this.map[key] = value;
|
this._map[key] = value;
|
||||||
},
|
},
|
||||||
|
|
||||||
has: function Dict_has(key) {
|
has: function Dict_has(key) {
|
||||||
return key in this.map;
|
return key in this._map;
|
||||||
},
|
},
|
||||||
|
|
||||||
forEach: function Dict_forEach(callback) {
|
forEach: function Dict_forEach(callback) {
|
||||||
for (var key in this.map) {
|
for (var key in this._map) {
|
||||||
callback(key, this.get(key));
|
callback(key, this.get(key));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -156,19 +156,19 @@ var Dict = (function DictClosure() {
|
|||||||
|
|
||||||
Dict.empty = new Dict(null);
|
Dict.empty = new Dict(null);
|
||||||
|
|
||||||
Dict.merge = function Dict_merge(xref, dictArray) {
|
Dict.merge = function(xref, dictArray) {
|
||||||
var mergedDict = new Dict(xref);
|
let mergedDict = new Dict(xref);
|
||||||
|
|
||||||
for (var i = 0, ii = dictArray.length; i < ii; i++) {
|
for (let i = 0, ii = dictArray.length; i < ii; i++) {
|
||||||
var dict = dictArray[i];
|
let dict = dictArray[i];
|
||||||
if (!isDict(dict)) {
|
if (!isDict(dict)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (var keyName in dict.map) {
|
for (let keyName in dict._map) {
|
||||||
if (mergedDict.map[keyName]) {
|
if (mergedDict._map[keyName] !== undefined) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mergedDict.map[keyName] = dict.map[keyName];
|
mergedDict._map[keyName] = dict._map[keyName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mergedDict;
|
return mergedDict;
|
||||||
|
@ -361,9 +361,9 @@ var Type2Parser = function type2Parser(aFilePath) {
|
|||||||
dump('privateData:' + privateDict);
|
dump('privateData:' + privateDict);
|
||||||
parseAsToken(privateDict, CFFDictPrivateDataMap);
|
parseAsToken(privateDict, CFFDictPrivateDataMap);
|
||||||
|
|
||||||
for (var p in font.map) {
|
font.forEach(function(key, value) {
|
||||||
dump(p + '::' + font.get(p));
|
dump(key + '::' + value);
|
||||||
}
|
});
|
||||||
|
|
||||||
// Read CharStrings Index
|
// Read CharStrings Index
|
||||||
var charStringsOffset = font.get('CharStrings');
|
var charStringsOffset = font.get('CharStrings');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user