feat: setup redux store for settings

This commit is contained in:
鲁树人
2023-06-03 14:09:11 +01:00
parent 953f0d524d
commit b136bac9b6
9 changed files with 150 additions and 14 deletions

View File

@@ -23,3 +23,23 @@ export function withGroupedLogs<R = unknown>(label: string, fn: () => R): R {
);
}
}
const noop = (..._args: unknown[]) => {
// noop
};
const dummyLogger = {
log: noop,
info: noop,
warn: noop,
debug: noop,
trace: noop,
};
export function getLogger() {
if (import.meta.env.ENABLE_PERF_LOG === '1') {
return window.console;
} else {
return dummyLogger;
}
}

7
src/util/objects.ts Normal file
View File

@@ -0,0 +1,7 @@
export function* enumObject<T>(obj: Record<string, T> | null | void): Generator<[string, T]> {
if (obj && typeof obj === 'object') {
for (const key in obj) {
yield [key, obj[key]];
}
}
}