/** * TONL Encoder - Converts JSON data to TONL format */ import type { TONLValue, TONLDelimiter } from "./types.js"; /** * Encode a JavaScript value to TONL format. * * Converts JavaScript objects, arrays, and primitives to the * Token-Optimized Notation Language format. TONL provides * 32-45% token reduction compared to JSON for LLM contexts. * * @param input - The value to encode (object, array, or primitive) * @param opts - Encoding options * @param opts.delimiter - Field delimiter: "," | "|" | "\t" | ";" (default: ",") * @param opts.includeTypes - Add type hints to headers (default: false) * @param opts.version - TONL version string (default: "1.0") * @param opts.indent - Spaces per indentation level (default: 2) * @param opts.singleLinePrimitiveLists - Encode primitive arrays on single line (default: true) * @param opts.prettyDelimiters - Add spaces around delimiters (default: false) * @param opts.compactTables - Use compact table format when possible (default: false) * @param opts.schemaFirst - Output schema before data (default: false) * @returns TONL formatted string with version header * @throws {Error} When circular reference detected in input * @throws {Error} When maximum nesting depth (500) exceeded * * @example * ```typescript * // Basic encoding * const tonl = encodeTONL({ name: 'Alice', age: 30 }); * // Output: * // #version 1.0 * // root: * // name: Alice * // age: 30 * * // With custom delimiter for data containing commas * const tonl = encodeTONL(data, { delimiter: '|' }); * * // With type hints for schema validation * const tonl = encodeTONL(data, { includeTypes: true }); * ``` * * @since 1.0.0 * @see decodeTONL - For decoding TONL back to JavaScript * @see encodeSmart - For automatic delimiter selection */ export declare function encodeTONL(input: TONLValue, opts?: { delimiter?: TONLDelimiter; includeTypes?: boolean; version?: string; indent?: number; singleLinePrimitiveLists?: boolean; prettyDelimiters?: boolean; compactTables?: boolean; schemaFirst?: boolean; }): string; //# sourceMappingURL=encode.d.ts.map