Skip to content

Instantly share code, notes, and snippets.

@RhysSullivan
Created November 2, 2023 05:50
Show Gist options
  • Save RhysSullivan/ce3ac16f0998b82234a25757ca1024ba to your computer and use it in GitHub Desktop.
Save RhysSullivan/ce3ac16f0998b82234a25757ca1024ba to your computer and use it in GitHub Desktop.
function makeBitfieldType<T extends readonly string[]>(values: T) {
return customType<{
data: Record<T[number], boolean>;
}>({
dataType() {
return `int`;
},
// @ts-ignore
fromDriver(value: number) {
return bitfieldToDict(value, values);
},
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment