Files
est-frame/node_modules/search-insights/lib/_getFunctionalInterface.ts
2025-10-22 05:38:27 +00:00

18 lines
563 B
TypeScript
Executable File

import type AlgoliaAnalytics from "./insights";
import type { InsightsClient } from "./types";
import { isFunction } from "./utils";
export function getFunctionalInterface(
instance: AlgoliaAnalytics
): InsightsClient {
return (functionName, ...functionArguments) => {
if (functionName && isFunction((instance as any)[functionName])) {
// @ts-expect-error
instance[functionName](...functionArguments);
} else {
// eslint-disable-next-line no-console
console.warn(`The method \`${functionName}\` doesn't exist.`);
}
};
}