676 }
677 this.lastGCodeByte = filePosition;
678 this.processLine(line, lineNumber, filePosition, renderLine);
679 } else if (this.slicer && this.slicer.isTypeComment(line)) { 680 this.isSupport = this.slicer.isSupport();
681 if (this.colorMode === ColorMode.Feature) {
682 this.currentColor = this.slicer.getFeatureColor();
670 if (this.slicer) {
671 this.slicer.isTypeComment(line);
672 }
673 let renderLine = !this.perimeterOnly || (this.slicer && this.slicer.isPerimeter()); 674 if (this.firstGCodeByte === 0 && line.length > 0) {
675 this.firstGCodeByte = filePosition;
676 }
71 return;
72 }
73 if (this.debug) return;
74 if (this.bedMesh && this.bedMesh.isDisposed()) { 75 this.bedMesh = null;
76 }
77 if (this.bedMesh) return this.bedMesh;
The optional chaining operator can be used to perform null checks before accessing a property, or calling a function.
Using &&
for this purpose is no longer required.
function getUsernameFromId(id: number): string | undefined {
const user = db.getUser(id)
return user && user.name
}
someFunc && someFunc()
// ^~~~ not necessary
maybeArray && maybeArray[index]
// ^~~~ not necessary
function getUsernameFromId(id: number): string | undefined {
const user = db.getUser(id)
return user?.name
}
someFunc?.()
maybeArray?.[index]