Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add strict equality operator to TS files src/* #754

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/GLDraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export namespace GLDraw {
if (Math.abs(vertex.z) < 1e-5)
vertex.z = 0;

if (cap == CAP.FLAT) {
if (cap === CAP.FLAT) {
n = new Vector3(0, Math.cos(thetaStart + v * thetaLength), 0);
n.normalize();
}
Expand Down Expand Up @@ -302,9 +302,9 @@ export namespace GLDraw {
let getcap = function(c: CAP|string): CAP {
if(typeof c === "string") {
let s = <string>c;
if(s.toLowerCase() == 'flat') {
if(s.toLowerCase() === 'flat') {
return CAP.FLAT;
} else if(s.toLowerCase() == 'round') {
} else if(s.toLowerCase() === 'round') {
return CAP.ROUND;
} else {
return CAP.NONE;
Expand Down
96 changes: 48 additions & 48 deletions src/GLModel.ts

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions src/GLShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ export class GLShape {
}

var color = customSpec.color;
if (typeof (color) == 'undefined') {
if (color === undefined) {
color = shape.color;
}
color = CC.color(color);
Expand All @@ -604,7 +604,7 @@ export class GLShape {
* @returns {undefined}
*/
static updateFromStyle(shape: GLShape, stylespec: ShapeSpec) {
if (typeof (stylespec.color) != 'undefined') {
if (stylespec.color !== undefined) {
shape.color = stylespec.color || new Color();
if (!(stylespec.color instanceof Color))
shape.color = CC.color(stylespec.color);
Expand All @@ -615,11 +615,11 @@ export class GLShape {
//opacity is the preferred nomenclature, support alpha for backwards compat
shape.opacity = stylespec.alpha ? clamp(stylespec.alpha, 0.0,
1.0) : 1.0;
if (typeof (stylespec.opacity) != 'undefined') {
if (stylespec.opacity !== undefined) {
shape.opacity = clamp(stylespec.opacity, 0.0, 1.0);
}
shape.side = (stylespec.side !== undefined) ? stylespec.side : DoubleSide;
shape.linewidth = typeof (stylespec.linewidth) == 'undefined' ? 1 : stylespec.linewidth;
shape.linewidth = stylespec.linewidth === undefined ? 1 : stylespec.linewidth;
// Click handling
shape.clickable = stylespec.clickable ? true : false;
shape.callback = makeFunction(stylespec.callback);
Expand Down Expand Up @@ -783,19 +783,19 @@ export class GLShape {

//dimensions may be scalar or vector quantities
var w: XYZ;
if (typeof (dim.w) == "number") {
if (typeof (dim.w) === "number") {
w = { x: dim.w, y: 0, z: 0 };
} else {
w = dim.w;
}
var h: XYZ;
if (typeof (dim.h) == "number") {
if (typeof (dim.h) === "number") {
h = { x: 0, y: dim.h, z: 0 };
} else {
h = dim.h;
}
var d: XYZ;
if (typeof (dim.d) == "number") {
if (typeof (dim.d) === "number") {
d = { x: 0, y: 0, z: dim.d };
} else {
d = dim.d;
Expand Down Expand Up @@ -924,7 +924,7 @@ export class GLShape {
} else {
end = new Vector3(cylinderSpec.end.x,
cylinderSpec.end.y || 0, cylinderSpec.end.z || 0);
if (typeof (end.x) == 'undefined') end.x = 3; //show something even if undefined
if (end.x === undefined) end.x = 3; //show something even if undefined
}
var radius = cylinderSpec.radius || 0.1;
var color = CC.color(cylinderSpec.color);
Expand Down Expand Up @@ -964,7 +964,7 @@ export class GLShape {
else {
end = new Vector3(cylinderSpec.end.x,
cylinderSpec.end.y || 0, cylinderSpec.end.z || 0);
if (typeof (end.x) == 'undefined') end.x = 3; //show something even if undefined
if (end.x === undefined) end.x = 3; //show something even if undefined
}

var radius = cylinderSpec.radius || 0.1;
Expand Down Expand Up @@ -1009,8 +1009,8 @@ export class GLShape {

curveSpec.points = curveSpec.points || [];
curveSpec.smooth = curveSpec.smooth || 10;
if (typeof (curveSpec.fromCap) == "undefined") curveSpec.fromCap = 2;
if (typeof (curveSpec.toCap) == "undefined") curveSpec.toCap = 2;
if (curveSpec.fromCap === undefined) curveSpec.fromCap = 2;
if (curveSpec.toCap === undefined) curveSpec.toCap = 2;

//subdivide into smoothed spline points
var points = subdivide_spline(curveSpec.points, curveSpec.smooth);
Expand Down Expand Up @@ -1103,7 +1103,7 @@ export class GLShape {
} else {
end = new Vector3(lineSpec.end.x,
lineSpec.end.y || 0, lineSpec.end.z || 0);
if (typeof (end.x) == 'undefined') end.x = 3; //show something even if undefined
if (end.x === undefined) end.x = 3; //show something even if undefined
}

var geoGroup = this.geo.updateGeoGroup(2);
Expand Down Expand Up @@ -1178,7 +1178,7 @@ export class GLShape {
} else {
arrowSpec.end = new Vector3(arrowSpec.end.x,
arrowSpec.end.y || 0, arrowSpec.end.z || 0);
if (typeof (arrowSpec.end.x) == 'undefined') arrowSpec.end.x = 3; //show something even if undefined
if (arrowSpec.end?.x === undefined) arrowSpec.end.x = 3; //show something even if undefined
}

arrowSpec.radius = arrowSpec.radius || 0.1;
Expand Down Expand Up @@ -1390,7 +1390,7 @@ export class GLShape {
var len2 = total.distanceTo(maxv);
this.boundingSphere.center = total;
this.boundingSphere.radius = Math.max(len1, len2);
if (typeof callback == "function")
if (typeof callback === "function")
callback();
};

Expand Down Expand Up @@ -1434,7 +1434,7 @@ export class GLShape {
this.geo.setUpWireframe();
}

if (typeof (this.color) != 'undefined')
if (this.color !== undefined)
GLShape.updateColor(this.geo, this.color);

this.shapeObj = new Object3D();
Expand Down
Loading
Loading