hypertune
Version:
[Hypertune](https://www.hypertune.com/) is the most flexible platform for feature flags, A/B testing, analytics and app configuration. Built with full end-to-end type-safety, Git-style version control and local, synchronous, in-memory flag evaluation. Opt
78 lines (56 loc) • 1.56 kB
text/typescript
/* eslint-disable max-classes-per-file */
import Node from "./Node";
export class VoidNode extends Node {
typeName = "Void" as const;
get(options = {}): void {
const value = this.getValue({ fallback: "fallback" });
if (value === true) {
return;
}
this.logUnexpectedValueError(value);
}
}
export class BooleanNode extends Node {
typeName = "Boolean" as const;
get({ fallback }: { fallback: boolean }): boolean {
const value = this.getValue({ fallback });
if (typeof value === "boolean") {
return value;
}
this.logUnexpectedValueError(value);
return fallback;
}
}
export class IntNode extends Node {
typeName = "Int" as const;
get({ fallback }: { fallback: number }): number {
const value = this.getValue({ fallback });
if (typeof value === "number" && Number.isInteger(value)) {
return value;
}
this.logUnexpectedValueError(value);
return fallback;
}
}
export class FloatNode extends Node {
typeName = "Float" as const;
get({ fallback }: { fallback: number }): number {
const value = this.getValue({ fallback });
if (typeof value === "number") {
return value;
}
this.logUnexpectedValueError(value);
return fallback;
}
}
export class StringNode extends Node {
typeName = "String" as const;
get({ fallback }: { fallback: string }): string {
const value = this.getValue({ fallback });
if (typeof value === "string") {
return value;
}
this.logUnexpectedValueError(value);
return fallback;
}
}