Skip to content

Commit

Permalink
fixup! fixup! refactor(client-http,web,server): use a serializable an…
Browse files Browse the repository at this point in the history
…d more simple configuration object
  • Loading branch information
Billlynch committed Oct 23, 2023
1 parent 83e3731 commit 3d6b56d
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions packages/client-http/src/client/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ export namespace Configuration {
}

export namespace FlagValue {
function valueMatchesSchema(value: any, schema: FlagSchema): boolean {
if (value === null || schema === null) {
return false;
}

if (typeof schema !== 'object') {
return typeof value === schema;
}

return Object.keys(value).every(key => valueMatchesSchema(value[key], schema[key]));
}

export function matches<T>({ schema }: FlagValue<T>, value: any): value is T {
return valueMatchesSchema(value, schema);
}
Expand Down Expand Up @@ -73,6 +61,19 @@ export namespace Configuration {
}
}
}

function valueMatchesSchema(value: any, schema: Configuration.FlagSchema): boolean {
if (value === null || schema === null) {
return false;
}

if (typeof schema !== 'object') {
return typeof value === schema;
}

return Object.keys(value).every(key => valueMatchesSchema(value[key], schema[key]));
}

export interface Configuration {
flags: Readonly<{
[name: string]: Configuration.Flag;
Expand Down

0 comments on commit 3d6b56d

Please sign in to comment.