From 73234577e14040d4cdc999457ca7e04fcdf0a6e3 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 13 Jun 2017 10:25:33 +0200 Subject: [PATCH] Rename `map` to `_map` inside of `Dict`, to make it clearer that it should be regarded as a "private" property --- src/core/primitives.js | 46 +++++++++++++++++++-------------------- src/shared/fonts_utils.js | 6 ++--- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/core/primitives.js b/src/core/primitives.js index 00b8893ca..b709762d9 100644 --- a/src/core/primitives.js +++ b/src/core/primitives.js @@ -60,7 +60,7 @@ var Dict = (function DictClosure() { // xref is optional function Dict(xref) { // 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.objId = null; this.suppressEncryption = false; @@ -76,15 +76,15 @@ var Dict = (function DictClosure() { get: function Dict_get(key1, key2, key3) { var value; var xref = this.xref, suppressEncryption = this.suppressEncryption; - if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || - typeof key2 === 'undefined') { + if (typeof (value = this._map[key1]) !== 'undefined' || + key1 in this._map || typeof key2 === 'undefined') { return xref ? xref.fetchIfRef(value, suppressEncryption) : value; } - if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || - typeof key3 === 'undefined') { + if (typeof (value = this._map[key2]) !== 'undefined' || + key2 in this._map || typeof key3 === 'undefined') { return xref ? xref.fetchIfRef(value, suppressEncryption) : value; } - value = this.map[key3] || null; + value = this._map[key3] || null; return xref ? xref.fetchIfRef(value, suppressEncryption) : value; }, @@ -92,21 +92,21 @@ var Dict = (function DictClosure() { getAsync: function Dict_getAsync(key1, key2, key3) { var value; var xref = this.xref, suppressEncryption = this.suppressEncryption; - if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || - typeof key2 === 'undefined') { + if (typeof (value = this._map[key1]) !== 'undefined' || + key1 in this._map || typeof key2 === 'undefined') { if (xref) { return xref.fetchIfRefAsync(value, suppressEncryption); } return Promise.resolve(value); } - if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || - typeof key3 === 'undefined') { + if (typeof (value = this._map[key2]) !== 'undefined' || + key2 in this._map || typeof key3 === 'undefined') { if (xref) { return xref.fetchIfRefAsync(value, suppressEncryption); } return Promise.resolve(value); } - value = this.map[key3] || null; + value = this._map[key3] || null; if (xref) { return xref.fetchIfRefAsync(value, suppressEncryption); } @@ -132,23 +132,23 @@ var Dict = (function DictClosure() { // no dereferencing getRaw: function Dict_getRaw(key) { - return this.map[key]; + return this._map[key]; }, getKeys: function Dict_getKeys() { - return Object.keys(this.map); + return Object.keys(this._map); }, set: function Dict_set(key, value) { - this.map[key] = value; + this._map[key] = value; }, has: function Dict_has(key) { - return key in this.map; + return key in this._map; }, forEach: function Dict_forEach(callback) { - for (var key in this.map) { + for (var key in this._map) { callback(key, this.get(key)); } }, @@ -156,19 +156,19 @@ var Dict = (function DictClosure() { Dict.empty = new Dict(null); - Dict.merge = function Dict_merge(xref, dictArray) { - var mergedDict = new Dict(xref); + Dict.merge = function(xref, dictArray) { + let mergedDict = new Dict(xref); - for (var i = 0, ii = dictArray.length; i < ii; i++) { - var dict = dictArray[i]; + for (let i = 0, ii = dictArray.length; i < ii; i++) { + let dict = dictArray[i]; if (!isDict(dict)) { continue; } - for (var keyName in dict.map) { - if (mergedDict.map[keyName]) { + for (let keyName in dict._map) { + if (mergedDict._map[keyName] !== undefined) { continue; } - mergedDict.map[keyName] = dict.map[keyName]; + mergedDict._map[keyName] = dict._map[keyName]; } } return mergedDict; diff --git a/src/shared/fonts_utils.js b/src/shared/fonts_utils.js index 555b18e19..d9a24f662 100644 --- a/src/shared/fonts_utils.js +++ b/src/shared/fonts_utils.js @@ -361,9 +361,9 @@ var Type2Parser = function type2Parser(aFilePath) { dump('privateData:' + privateDict); parseAsToken(privateDict, CFFDictPrivateDataMap); - for (var p in font.map) { - dump(p + '::' + font.get(p)); - } + font.forEach(function(key, value) { + dump(key + '::' + value); + }); // Read CharStrings Index var charStringsOffset = font.get('CharStrings');