This commit is contained in:
17
node_modules/search-insights/lib/_getFunctionalInterface.ts
generated
vendored
Normal file
17
node_modules/search-insights/lib/_getFunctionalInterface.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
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[functionName])) {
|
||||
// @ts-expect-error
|
||||
return instance[functionName](...functionArguments);
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`The method \`${functionName}\` doesn't exist.`);
|
||||
return undefined;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user