mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Prefer instanceof Name
rather than calling isName()
with one argument
Unless you actually need to check that something is both a `Name` and also of the *correct* type, using `instanceof Name` directly should be a tiny bit more efficient since it avoids one function call and an unnecessary `undefined` check. This patch uses ESLint to enforce this, since we obviously still want to keep the `isName` helper function for where it makes sense.
This commit is contained in:
parent
4df82ad31e
commit
b282814e38
13 changed files with 85 additions and 73 deletions
|
@ -470,6 +470,8 @@ describe("primitives", function () {
|
|||
});
|
||||
|
||||
describe("isName", function () {
|
||||
/* eslint-disable no-restricted-syntax */
|
||||
|
||||
it("handles non-names", function () {
|
||||
const nonName = {};
|
||||
expect(isName(nonName)).toEqual(false);
|
||||
|
@ -493,6 +495,8 @@ describe("primitives", function () {
|
|||
expect(isName(emptyName, "")).toEqual(true);
|
||||
expect(isName(emptyName, "string")).toEqual(false);
|
||||
});
|
||||
|
||||
/* eslint-enable no-restricted-syntax */
|
||||
});
|
||||
|
||||
describe("isCmd", function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue