mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Remove the isNum
helper function
The call-sites are replaced by direct `typeof`-checks instead, which removes unnecessary function calls. Note that in the `src/`-folder we already had more `typeof`-cases than `isNum`-calls. These changes were *mostly* done using regular expression search-and-replace, with two exceptions: - In `Font._charToGlyph` we no longer unconditionally update the `width`, since that seems completely unnecessary. - In `PDFDocument.documentInfo`, when parsing custom entries, we now do the `typeof`-check once.
This commit is contained in:
parent
edd024c9e7
commit
05edd91bdb
10 changed files with 30 additions and 51 deletions
|
@ -22,7 +22,6 @@ import {
|
|||
isArrayBuffer,
|
||||
isAscii,
|
||||
isBool,
|
||||
isNum,
|
||||
isSameOrigin,
|
||||
isString,
|
||||
string32,
|
||||
|
@ -91,23 +90,6 @@ describe("util", function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isNum", function () {
|
||||
it("handles numeric values", function () {
|
||||
expect(isNum(1)).toEqual(true);
|
||||
expect(isNum(0)).toEqual(true);
|
||||
expect(isNum(-1)).toEqual(true);
|
||||
expect(isNum(1000000000000000000)).toEqual(true);
|
||||
expect(isNum(12.34)).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles non-numeric values", function () {
|
||||
expect(isNum("true")).toEqual(false);
|
||||
expect(isNum(true)).toEqual(false);
|
||||
expect(isNum(null)).toEqual(false);
|
||||
expect(isNum(undefined)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isString", function () {
|
||||
it("handles string values", function () {
|
||||
expect(isString("foo")).toEqual(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue