Skip to content

Commit

Permalink
Removes some bind() calls from fetchAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
yurydelendik committed Aug 6, 2014
1 parent 46a9a35 commit cc180d7
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/core/obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ var Catalog = (function CatalogClosure() {
}
nodesToVisit.push(obj);
next();
}.bind(this), capability.reject.bind(capability));
}, capability.reject);
return;
}

Expand Down Expand Up @@ -1287,21 +1287,22 @@ var XRef = (function XRefClosure() {
},

fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
return new Promise(function (resolve, reject) {
var tryFetch = function () {
try {
resolve(this.fetch(ref, suppressEncryption));
} catch (e) {
if (e instanceof MissingDataException) {
this.stream.manager.requestRange(e.begin, e.end, tryFetch);
return;
}
reject(e);
}
}.bind(this);
tryFetch();
}.bind(this));
},
var streamManager = this.stream.manager;
var xref = this;
return new Promise(function tryFetch(resolve, reject) {
try {
resolve(xref.fetch(ref, suppressEncryption));
} catch (e) {
if (e instanceof MissingDataException) {
streamManager.requestRange(e.begin, e.end, function () {
tryFetch(resolve, reject);
});
return;
}
reject(e);
}
});
},

getCatalogObj: function XRef_getCatalogObj() {
return this.root;
Expand Down

0 comments on commit cc180d7

Please sign in to comment.