Skip to content

Refactor Transport Selection Logic in SemaphoreViem Constructor #1005

@ultraviolet10

Description

@ultraviolet10

Describe the improvement you're thinking about

The current constructor logic for selecting the transport in SemaphoreViem is a bit redundant, with multiple checks and assignments for options.transport.
This can be simplified using a single ternary expression, making the code more concise and easier to follow.
This avoids mutating the options object and makes the intent clearer.

Describe alternatives you've considered

Keeping the current multi-step logic with separate if/else blocks.
Downside: This is harder to read, more error-prone, and mutates the options object unnecessarily.

Additional context

The refactor is a small but meaningful code quality improvement, reducing cognitive load for future contributors.
The new approach is more idiomatic and easier to maintain.
This change is backwards compatible and does not affect the public API.

Metadata

Metadata

Assignees

Labels

refactoring ♻️A code change that neither fixes a bug nor adds a feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions