MCPcopy Index your code
hub / github.com/AnswerOverflow/AnswerOverflow / dictToBitfield

Function dictToBitfield

packages/core/src/utils/bitfieldUtils.ts:38–50  ·  view source on GitHub ↗
(dict: FlagDict, flags: T)

Source from the content-addressed store, hash-verified

36}
37
38export function dictToBitfield<
39 T extends readonly string[],
40 FlagDict extends Record<T[number], boolean>,
41>(dict: FlagDict, flags: T) {
42 const bitfield = new BitField(toBitfield(...flags));
43 const enabledFlags: string[] = [];
44 for (const key in dict) {
45 if (dict[key]) {
46 enabledFlags.push(key);
47 }
48 }
49 return bitfield.resolve(enabledFlags) as number; // TODO: Possibly a bug? Needs to be revisited if bitfields ever exceed the size of a number
50}
51
52export function mergeFlags(
53 getOldFlags: () => Record<string, boolean>,

Calls 1

toBitfieldFunction · 0.85

Tested by

no test coverage detected