mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Prefer instanceof Cmd
rather than calling isCmd()
with *one* argument
Unless you actually need to check that something is both a `Cmd` and also of the *correct* type, using `instanceof Cmd` 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 `isCmd` helper function for where it makes sense.
This commit is contained in:
parent
3635a9a333
commit
67b658e8d5
3 changed files with 10 additions and 2 deletions
|
@ -496,6 +496,8 @@ describe("primitives", function () {
|
|||
});
|
||||
|
||||
describe("isCmd", function () {
|
||||
/* eslint-disable no-restricted-syntax */
|
||||
|
||||
it("handles non-commands", function () {
|
||||
const nonCmd = {};
|
||||
expect(isCmd(nonCmd)).toEqual(false);
|
||||
|
@ -511,6 +513,8 @@ describe("primitives", function () {
|
|||
expect(isCmd(cmd, "BT")).toEqual(true);
|
||||
expect(isCmd(cmd, "ET")).toEqual(false);
|
||||
});
|
||||
|
||||
/* eslint-enable no-restricted-syntax */
|
||||
});
|
||||
|
||||
describe("isDict", function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue