@accounter/server
Version:
Accounter GraphQL server
58 lines (57 loc) • 2.19 kB
TypeScript
/**
* Fixed-width formatting utilities
*/
/**
* Formats a field value with specified width and alignment
*
* @param value - The value to format
* @param width - Target field width
* @param align - Alignment ('left' or 'right')
* @param padChar - Character to use for padding (default: space)
* @returns Formatted fixed-width string
*/
export declare function formatField(value: string, width: number, align: 'left' | 'right', padChar?: string): string;
/**
* Encodes a value to fixed-width format with padding
*
* @param value - The value to encode
* @param width - Target width
* @param padChar - Padding character (default: space)
* @param align - Alignment ('left' or 'right')
* @returns Fixed-width encoded string
*/
export declare function encodeFixedWidth(value: string | number, width: number, padChar?: string, align?: 'left' | 'right'): string;
/**
* Helper function to format numeric fields with zero padding
*/
export declare function formatNumericField(value: string, width: number): string;
/**
* Joins an array of field values into a single record line with CRLF ending
* This is used by individual record encoders to create their output
*
* @param fields - Array of formatted field values
* @returns Single record line ending with CRLF
*/
export declare function joinFields(fields: string[]): string;
/**
* Joins an array of record lines that already have CRLF endings
*
* @param lines - Array of record lines to join (each line should already end with CRLF)
* @returns Joined string
*/
export declare function joinRecords(lines: string[]): string;
/**
* Joins an array of record lines and adds CRLF to each line
*
* @param lines - Array of record lines to join (without CRLF endings)
* @returns Joined string with CRLF line endings
*/
export declare function joinLinesWithCRLF(lines: string[]): string;
/**
* Creates a complete SHAAM format file by joining records
* This is the main function for assembling final file content
*
* @param records - Array of encoded record strings (each already ending with CRLF)
* @returns Complete file content ready for output
*/
export declare function assembleFile(records: string[]): string;