/** * Represents detected indentation style. * * - `"\t"` - Tab character * - `number` - Number of spaces (e.g., 2, 4) */ export type IndentationStyle = "\t" | number; /** * Default indentation style used when detection fails or no indentation is found. * * @alpha */ export declare const DEFAULT_INDENTATION: IndentationStyle; /** * Detect the indentation style used in a file. * * Analyzes the file content to determine whether tabs or spaces are used * for indentation. This is useful when writing files to preserve * the existing formatting style. * * @param filePath - Path to the file * @param defaultIndentation - Indentation to use if detection fails (default: tab) * @returns The detected indentation (tab character or number of spaces) * * @example * ```typescript * const indent = await detectIndentation("/path/to/package.json"); * // Returns "\t" for tabs, or a number like 2 or 4 for spaces * * // With custom default * const indent = await detectIndentation("/path/to/file.yaml", 2); * ``` * * @alpha */ export declare function detectIndentation(filePath: string, defaultIndentation?: IndentationStyle): Promise; /** * Detect the indentation style used in text content. * * Analyzes the content string to determine whether tabs or spaces are used * for indentation. This is a pure function useful for testing and for * cases where the content is already in memory. * * The detection algorithm: * 1. Splits content into lines * 2. Finds the first line that starts with whitespace * 3. If it starts with a tab, returns tab * 4. If it starts with spaces, returns the count of leading spaces * 5. If no indented lines found, returns the default * * @param content - The file content as a string * @param defaultIndentation - Indentation to use if no indented lines found (default: tab) * @returns The detected indentation (tab character or number of spaces) * * @example * ```typescript * // JSON with 2-space indentation * const json = '{\n "name": "test"\n}'; * detectIndentationFromContent(json); // Returns 2 * * // YAML with tab indentation * const yaml = 'root:\n\tchild: value'; * detectIndentationFromContent(yaml); // Returns "\t" * * // No indentation found - uses default * detectIndentationFromContent('no indent'); // Returns "\t" * detectIndentationFromContent('no indent', 4); // Returns 4 * ``` * * @alpha */ export declare function detectIndentationFromContent(content: string, defaultIndentation?: IndentationStyle): IndentationStyle; //# sourceMappingURL=indentation.d.ts.map