Merge pull request #11038 from Snuffleupagus/getStats-objects

[api-minor] Fix completely broken `getStats` method by returning stats in Objects, rather than in Arrays (PR 11029 follow-up)
This commit is contained in:
Tim van der Meij 2019-08-02 22:08:37 +02:00 committed by GitHub
commit 6c05a7653d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View File

@ -1046,8 +1046,8 @@ var XRef = (function XRefClosure() {
// prepare the XRef cache
this.cache = [];
this.stats = {
streamTypes: [],
fontTypes: [],
streamTypes: Object.create(null),
fontTypes: Object.create(null),
};
}

View File

@ -205,10 +205,10 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
/**
* @typedef {Object} PDFDocumentStats
* @property {Array} streamTypes - Used stream types in the document (an item
* @property {Object} streamTypes - Used stream types in the document (an item
* is set to true if specific stream ID was used in the document).
* @property {Array} fontTypes - Used font type in the document (an item is set
* to true if specific font ID was used in the document).
* @property {Object} fontTypes - Used font types in the document (an item
* is set to true if specific font ID was used in the document).
*/
/**

View File

@ -926,7 +926,7 @@ describe('api', function() {
it('gets document stats', function(done) {
var promise = doc.getStats();
promise.then(function (stats) {
expect(stats).toEqual({ streamTypes: [], fontTypes: [], });
expect(stats).toEqual({ streamTypes: {}, fontTypes: {}, });
done();
}).catch(done.fail);
});
@ -1293,9 +1293,9 @@ describe('api', function() {
var promise = page.getOperatorList().then(function () {
return pdfDocument.getStats();
});
var expectedStreamTypes = [];
var expectedStreamTypes = {};
expectedStreamTypes[StreamType.FLATE] = true;
var expectedFontTypes = [];
var expectedFontTypes = {};
expectedFontTypes[FontType.TYPE1] = true;
expectedFontTypes[FontType.CIDFONTTYPE2] = true;