Skip to content

Commit

Permalink
fix: remove defaults from isEnabled and getVariant
Browse files Browse the repository at this point in the history
  • Loading branch information
nunogois committed Mar 7, 2025
1 parent 6d24ce9 commit dab0c08
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions javascript-engine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class UnleashEngine {
this.strategies.mapFeatures(state)
}

public isEnabled(toggleName: string, context: Context): boolean {
public isEnabled(toggleName: string, context: Context): boolean | undefined {
const customStrategyPayload = this.strategies.getCustomStrategyPayload(
toggleName,
context
Expand All @@ -54,10 +54,10 @@ export class UnleashEngine {
customStrategyPayload
)

return readResponse<boolean>(response) || false
return readResponse<boolean>(response)
}

public getVariant(toggleName: string, context: Context): Variant {
public getVariant(toggleName: string, context: Context): Variant | undefined {
const customStrategyPayload = this.strategies.getCustomStrategyPayload(
toggleName,
context
Expand All @@ -69,12 +69,7 @@ export class UnleashEngine {
customStrategyPayload
)

return (
readResponse<Variant>(response) || {
...DISABLED_VARIANT,
featureEnabled: this.isEnabled(toggleName, context)
}
)
return readResponse<Variant>(response)
}

public getMetrics(): MetricsBucket | undefined {
Expand Down

0 comments on commit dab0c08

Please sign in to comment.