MCPcopy Index your code
hub / github.com/promptfoo/promptfoo / loadTransformModule

Function loadTransformModule

src/providers/transformUtils.ts:40–63  ·  view source on GitHub ↗
(
  transform: string | Function | undefined,
)

Source from the content-addressed store, hash-verified

38 * @returns The loaded function, or the original value if not a file:// reference
39 */
40export async function loadTransformModule(
41 transform: string | Function | undefined,
42): Promise<string | Function | undefined> {
43 if (!transform) {
44 return transform;
45 }
46 if (typeof transform === 'function') {
47 return transform;
48 }
49 if (typeof transform === 'string' && transform.startsWith('file://')) {
50 const { filename, functionName } = parseFileTransformReference(transform);
51 const requiredModule = await importModule(
52 path.resolve(cliState.basePath || '', filename),
53 functionName,
54 );
55 if (typeof requiredModule === 'function') {
56 return requiredModule;
57 }
58 throw new Error(
59 `Transform module malformed: ${filename} must export a function or have a default export as a function`,
60 );
61 }
62 return transform;
63}

Callers 3

constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90

Calls 3

importModuleFunction · 0.90
resolveMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…