mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-03 04:47:21 +02:00
Merge pull request #20795 from Snuffleupagus/Dict-more-iterators
Change the `Dict.prototype.{getKeys, getRawValues}` methods to return iterators
This commit is contained in:
commit
4d0709c174
@ -3398,7 +3398,7 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
|
|||||||
? this.data.fieldValue
|
? this.data.fieldValue
|
||||||
: "Yes";
|
: "Yes";
|
||||||
|
|
||||||
const exportValues = this._decodeFormValue(normalAppearance.getKeys());
|
const exportValues = this._decodeFormValue([...normalAppearance.getKeys()]);
|
||||||
if (exportValues.length === 0) {
|
if (exportValues.length === 0) {
|
||||||
exportValues.push("Off", yes);
|
exportValues.push("Off", yes);
|
||||||
} else if (exportValues.length === 1) {
|
} else if (exportValues.length === 1) {
|
||||||
|
|||||||
@ -180,12 +180,12 @@ class Dict {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getKeys() {
|
getKeys() {
|
||||||
return [...this._map.keys()];
|
return this._map.keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
// No dereferencing.
|
// No dereferencing.
|
||||||
getRawValues() {
|
getRawValues() {
|
||||||
return [...this._map.values()];
|
return this._map.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
getRawEntries() {
|
getRawEntries() {
|
||||||
|
|||||||
@ -276,7 +276,7 @@ describe("primitives", function () {
|
|||||||
|
|
||||||
it("should get all key names", function () {
|
it("should get all key names", function () {
|
||||||
const expectedKeys = ["FontFile", "FontFile2", "FontFile3"];
|
const expectedKeys = ["FontFile", "FontFile2", "FontFile3"];
|
||||||
const keys = dictWithManyKeys.getKeys();
|
const keys = [...dictWithManyKeys.getKeys()];
|
||||||
|
|
||||||
expect(keys.sort()).toEqual(expectedKeys);
|
expect(keys.sort()).toEqual(expectedKeys);
|
||||||
});
|
});
|
||||||
@ -284,7 +284,7 @@ describe("primitives", function () {
|
|||||||
it("should get all raw values", function () {
|
it("should get all raw values", function () {
|
||||||
// Test direct objects:
|
// Test direct objects:
|
||||||
const expectedRawValues1 = [testFontFile, testFontFile2, testFontFile3];
|
const expectedRawValues1 = [testFontFile, testFontFile2, testFontFile3];
|
||||||
const rawValues1 = dictWithManyKeys.getRawValues();
|
const rawValues1 = [...dictWithManyKeys.getRawValues()];
|
||||||
|
|
||||||
expect(rawValues1.sort()).toEqual(expectedRawValues1);
|
expect(rawValues1.sort()).toEqual(expectedRawValues1);
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ describe("primitives", function () {
|
|||||||
dict.set("Contents", contentsRef);
|
dict.set("Contents", contentsRef);
|
||||||
|
|
||||||
const expectedRawValues2 = [contentsRef, resourcesRef, typeName];
|
const expectedRawValues2 = [contentsRef, resourcesRef, typeName];
|
||||||
const rawValues2 = dict.getRawValues();
|
const rawValues2 = [...dict.getRawValues()];
|
||||||
|
|
||||||
expect(rawValues2.sort()).toEqual(expectedRawValues2);
|
expect(rawValues2.sort()).toEqual(expectedRawValues2);
|
||||||
});
|
});
|
||||||
@ -337,7 +337,7 @@ describe("primitives", function () {
|
|||||||
xref: null,
|
xref: null,
|
||||||
dictArray: [dictWithManyKeys, dictWithSizeKey, fontFileDict],
|
dictArray: [dictWithManyKeys, dictWithSizeKey, fontFileDict],
|
||||||
});
|
});
|
||||||
const mergedKeys = mergedDict.getKeys();
|
const mergedKeys = [...mergedDict.getKeys()];
|
||||||
|
|
||||||
expect(mergedKeys.sort()).toEqual(expectedKeys);
|
expect(mergedKeys.sort()).toEqual(expectedKeys);
|
||||||
expect(mergedDict.get("FontFile")).toEqual(testFontFile);
|
expect(mergedDict.get("FontFile")).toEqual(testFontFile);
|
||||||
@ -374,14 +374,14 @@ describe("primitives", function () {
|
|||||||
expect(mergedFontDict instanceof Dict).toEqual(true);
|
expect(mergedFontDict instanceof Dict).toEqual(true);
|
||||||
expect(mergedSubFontDict instanceof Dict).toEqual(true);
|
expect(mergedSubFontDict instanceof Dict).toEqual(true);
|
||||||
|
|
||||||
const mergedFontDictKeys = mergedFontDict.getKeys();
|
const mergedFontDictKeys = [...mergedFontDict.getKeys()];
|
||||||
const mergedSubFontDictKeys = mergedSubFontDict.getKeys();
|
const mergedSubFontDictKeys = [...mergedSubFontDict.getKeys()];
|
||||||
|
|
||||||
expect(mergedFontDictKeys).toEqual(["F1"]);
|
expect(mergedFontDictKeys).toEqual(["F1"]);
|
||||||
expect(mergedSubFontDictKeys).toEqual(["F1", "F2", "F3"]);
|
expect(mergedSubFontDictKeys).toEqual(["F1", "F2", "F3"]);
|
||||||
|
|
||||||
const mergedFontDictValues = mergedFontDict.getRawValues();
|
const mergedFontDictValues = [...mergedFontDict.getRawValues()];
|
||||||
const mergedSubFontDictValues = mergedSubFontDict.getRawValues();
|
const mergedSubFontDictValues = [...mergedSubFontDict.getRawValues()];
|
||||||
|
|
||||||
expect(mergedFontDictValues).toEqual(["Local font one"]);
|
expect(mergedFontDictValues).toEqual(["Local font one"]);
|
||||||
expect(mergedSubFontDictValues).toEqual([
|
expect(mergedSubFontDictValues).toEqual([
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user