import type { Config, Fn, MethodReturnType } from "./index.js"; const defaultConfig = {}; export default function normalizeArgs(method: Fn) { function normalized( func: Func, ): MethodReturnType; function normalized( func: Func, funcArgs: Parameters, ): MethodReturnType; function normalized( func: Func, config: Config, funcArgs: Parameters, ): MethodReturnType; function normalized( func: Func, config = defaultConfig, funcArgs = [] as unknown as Parameters, ): MethodReturnType { if (Array.isArray(config)) { funcArgs = config as Parameters; config = defaultConfig; } return method(func, config, funcArgs); } return normalized; }