|
@@ -5,7 +5,8 @@ const $toggle = (flag: number, sequence = 0) => sequence ^ flag
|
|
|
|
|
|
const combine = (flags: number[]) => flags.reduce((flags, flag) => flags + flag, 0)
|
|
const combine = (flags: number[]) => flags.reduce((flags, flag) => flags + flag, 0)
|
|
|
|
|
|
-const createMultiFlagHandler = <T>(fn: (flag: number, flags: number) => T) =>
|
|
|
|
|
|
+type FlagHandler<T> = (flag: number, flags: number) => T
|
|
|
|
+const createMultiFlagHandler = <T extends number | boolean>(fn: FlagHandler<T>) =>
|
|
(flag: number | number[], sequence = 0): T =>
|
|
(flag: number | number[], sequence = 0): T =>
|
|
fn(Array.isArray(flag) ? combine(flag) : flag, sequence)
|
|
fn(Array.isArray(flag) ? combine(flag) : flag, sequence)
|
|
|
|
|