core: config: refactor (allow schemastery)

This commit is contained in:
undefined committed 2025-03-07 11:59:13 +08:00
1 parent f825fbe4f1
commit 31b4ed73f4
16 files changed
+373 -220

No files matched your search

+9 -3
View File
@@ -1,3 +1,5 @@
import { isNullable } from 'cosmokit';
export function buildProjection<T extends string | number = string>(fields: readonly T[]): Record<T, true> {
const o: Record<T, true> = Object.create(null);
for (const k of fields) o[k] = true;
@@ -17,9 +19,13 @@ export function ArgMethod(target: any, funcName: string, obj: any) {
}
export function unwrapExports(module: any) {
return (!module || typeof module !== 'object') ? module
: 'apply' in module && typeof module.apply === 'function' ? module
: 'default' in module ? module.default : module;
if (isNullable(module)) return module;
if (typeof module !== 'object') return module;
if ('apply' in module && typeof module.apply === 'function') return module;
// https://github.com/evanw/esbuild/issues/2623
// https://esbuild.github.io/content-types/#default-interop
if (!module.__esModule) return module;
return module.default ?? module;
}
export * from '@hydrooj/utils/lib/utils';