mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Add a parameter to the isName
function that enables checking not just that something is a Name
, but also that the actual name
properties matches
This is similar to the existing `isCmd` and `isDict` functions, which already support similar kind of checks. With the updated `isName` function, we'll be able to simplify many callsites from: `isName(someVariable) && someVariable.name === 'someName'` to: `isName(someVariable, 'someName')`.
This commit is contained in:
parent
94089960c0
commit
af636aae96
2 changed files with 10 additions and 10 deletions
|
@ -267,8 +267,8 @@ var RefSetCache = (function RefSetCacheClosure() {
|
|||
return RefSetCache;
|
||||
})();
|
||||
|
||||
function isName(v) {
|
||||
return v instanceof Name;
|
||||
function isName(v, name) {
|
||||
return v instanceof Name && (name === undefined || v.name === name);
|
||||
}
|
||||
|
||||
function isCmd(v, cmd) {
|
||||
|
@ -276,14 +276,8 @@ function isCmd(v, cmd) {
|
|||
}
|
||||
|
||||
function isDict(v, type) {
|
||||
if (!(v instanceof Dict)) {
|
||||
return false;
|
||||
}
|
||||
if (!type) {
|
||||
return true;
|
||||
}
|
||||
var dictType = v.get('Type');
|
||||
return isName(dictType) && dictType.name === type;
|
||||
return v instanceof Dict &&
|
||||
(type === undefined || isName(v.get('Type'), type));
|
||||
}
|
||||
|
||||
function isRef(v) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue