Replace value === (value | 0)
checks with Number.isInteger(value)
in the src/
folder
Rather than doing what (at first) may seem like a fairly obscure comparison, using `Number.isInteger` will clearly indicate the intent of the code.
This commit is contained in:
parent
c8b5ba277a
commit
8686baede5
@ -450,7 +450,7 @@ class AnnotationBorderStyle {
|
||||
* @param {integer} width - The width
|
||||
*/
|
||||
setWidth(width) {
|
||||
if (width === (width | 0)) {
|
||||
if (Number.isInteger(width)) {
|
||||
this.width = width;
|
||||
}
|
||||
}
|
||||
@ -537,7 +537,7 @@ class AnnotationBorderStyle {
|
||||
* @param {integer} radius - The horizontal corner radius
|
||||
*/
|
||||
setHorizontalCornerRadius(radius) {
|
||||
if (radius === (radius | 0)) {
|
||||
if (Number.isInteger(radius)) {
|
||||
this.horizontalCornerRadius = radius;
|
||||
}
|
||||
}
|
||||
@ -550,7 +550,7 @@ class AnnotationBorderStyle {
|
||||
* @param {integer} radius - The vertical corner radius
|
||||
*/
|
||||
setVerticalCornerRadius(radius) {
|
||||
if (radius === (radius | 0)) {
|
||||
if (Number.isInteger(radius)) {
|
||||
this.verticalCornerRadius = radius;
|
||||
}
|
||||
}
|
||||
|
@ -1032,7 +1032,7 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
|
||||
return null;
|
||||
}
|
||||
n = num1.number;
|
||||
if (n < 0 || (n | 0) !== n || stack.length < n) {
|
||||
if (n < 0 || !Number.isInteger(n) || stack.length < n) {
|
||||
return null;
|
||||
}
|
||||
ast1 = stack[stack.length - n - 1];
|
||||
@ -1082,7 +1082,8 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
|
||||
}
|
||||
j = num2.number;
|
||||
n = num1.number;
|
||||
if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
|
||||
if (n <= 0 || !Number.isInteger(n) || !Number.isInteger(j) ||
|
||||
stack.length < n) {
|
||||
// ... and integers
|
||||
return null;
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ var Type1CharString = (function Type1CharStringClosure() {
|
||||
var start = stackLength - howManyArgs;
|
||||
for (var i = start; i < stackLength; i++) {
|
||||
var value = this.stack[i];
|
||||
if (value === (value | 0)) { // int
|
||||
if (Number.isInteger(value)) {
|
||||
this.output.push(28, (value >> 8) & 0xff, value & 0xff);
|
||||
} else { // fixed point
|
||||
value = (65536 * value) | 0;
|
||||
|
@ -359,7 +359,7 @@ SVGGraphics = (function SVGGraphicsClosure() {
|
||||
* @returns {string}
|
||||
*/
|
||||
function pf(value) {
|
||||
if (value === (value | 0)) { // integer number
|
||||
if (Number.isInteger(value)) {
|
||||
return value.toString();
|
||||
}
|
||||
var s = value.toFixed(10);
|
||||
|
Loading…
Reference in New Issue
Block a user