Skip to content

Commit

Permalink
style: prefer default arg syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
YoRyan committed Jul 24, 2024
1 parent 9060951 commit 88a642d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/lib/frp-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ export class FrpEngine extends FrpVehicle {
* @returns A transformer that maps bell triggers to the final bell state
* control value.
*/
mapAutoBellStream(useVirtual?: boolean): (eventStream: frp.Stream<any>) => frp.Stream<number> {
useVirtual ??= false;
mapAutoBellStream(useVirtual: boolean = false): (eventStream: frp.Stream<any>) => frp.Stream<number> {
return eventStream => {
const turnOn$ = frp.compose(
eventStream,
Expand Down
7 changes: 4 additions & 3 deletions src/lib/power-supply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,10 @@ export function createElectrificationDeltaStream(e: FrpEngine): frp.Stream<Elect
* HEP.
* @returns A stream that indicates HEP is available.
*/
export function createHepStream(e: FrpEngine, hepOn?: frp.Behavior<boolean>): frp.Stream<boolean> {
hepOn ??= () => (e.rv.GetControlValue("Startup") as number) > 0;

export function createHepStream(
e: FrpEngine,
hepOn: frp.Behavior<boolean> = () => (e.rv.GetControlValue("Startup") as number) > 0
): frp.Stream<boolean> {
const startupS = 10;
const player$ = frp.compose(
e.createPlayerWithKeyUpdateStream(),
Expand Down
8 changes: 5 additions & 3 deletions src/lib/special-fx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,11 @@ export function createBrakeLightStreamForWagon(v: FrpVehicle): frp.Stream<boolea
* @param playerLow A behavior that indicates the player selected low-platform
* doors.
*/
export function setLowPlatformDoorsForEngine(eng: FrpEngine, aiLow: boolean, playerLow?: frp.Behavior<boolean>) {
playerLow ??= () => (eng.rv.GetControlValue("Reverser") as number) === 0;

export function setLowPlatformDoorsForEngine(
eng: FrpEngine,
aiLow: boolean,
playerLow: frp.Behavior<boolean> = () => (eng.rv.GetControlValue("Reverser") as number) === 0
) {
// Send consist messages.
const playerSend$ = frp.compose(eng.createPlayerWithKeyUpdateStream(), mapBehavior(playerLow));
const send$ = frp.compose(
Expand Down
4 changes: 1 addition & 3 deletions src/lib/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ export class ScrollingMenu {
* @param items A list of player-friendly labels for the menu.
* @param initSelection The initial selection. Defaults to the first item.
*/
constructor(title: string, items: string[], initSelection?: number) {
initSelection ??= 0;

constructor(title: string, items: string[], initSelection: number = 0) {
this.title = title;
this.items = items;
this.nItems = items.length;
Expand Down

0 comments on commit 88a642d

Please sign in to comment.