UNPKG

@baseplate-dev/core-generators

Version:

Core generators for Baseplate

55 lines 2.08 kB
import type { TsCodeFragment, TsHoistedFragment, TsImportDeclaration } from '../renderers/typescript/index.js'; /** * Options for fragment comparison */ export interface CompareFragmentsOptions { /** * Whether to compare hoisted fragments (default: true) */ compareHoistedFragments?: boolean; } /** * Normalizes imports for comparison by sorting them in a deterministic order * This allows order-independent comparison of imports * * @param imports - Array of import declarations to normalize * @returns Normalized array of import declarations */ export declare function normalizeImports(imports: TsImportDeclaration[]): TsImportDeclaration[]; /** * Normalizes hoisted fragments for comparison by sorting them by key * * @param fragments - Array of hoisted fragments to normalize * @returns Normalized array of hoisted fragments */ export declare function normalizeHoistedFragments(fragments?: TsHoistedFragment[]): TsHoistedFragment[] | undefined; /** * Normalizes a code fragment for comparison * This includes trimming contents, sorting imports, and normalizing hoisted fragments * * @param fragment - The fragment to normalize * @param options - Options for normalization * @returns Normalized fragment */ export declare function normalizeFragment(fragment: TsCodeFragment, options?: CompareFragmentsOptions): TsCodeFragment; /** * Compares two TsCodeFragment objects for equality, ignoring import order * This is useful for programmatic checks outside of test assertions * * @param actual - The actual fragment * @param expected - The expected fragment * @param options - Comparison options * @returns True if fragments are equal * * @example * ```typescript * const actual = tsCodeFragment('foo()', ...); * const expected = tsCodeFragment('foo()', ...); * * if (areFragmentsEqual(actual, expected)) { * console.log('Fragments match!'); * } * ``` */ export declare function areFragmentsEqual(actual: TsCodeFragment, expected: TsCodeFragment, options?: CompareFragmentsOptions): boolean; //# sourceMappingURL=utils.d.ts.map