Rebasely Beta: data may be purged

justintypescript-ultra-strict Public

Text · 19 lines · 555 B · at eb4a6ea

import { type Result } from "@tsus/runtime";export type Rule = { attribute: string; op: "eq" | "in" | "gte"; value: unknown };export type Flag = {  key: string;  enabled: boolean;  rules: Rule[];  rolloutPercent: number;  defaultValue: boolean;};export type User = { id: string; attributes: Record<string, unknown> };export type FlagError = { kind: "invalid_rollout" } | { kind: "invalid_rule"; index: number };export const evaluateFlag = (flag: Flag, user: User, hash: (s: string) => number): Result<boolean, FlagError> => {  // TODO};