@@ -19,8 +19,8 @@ export interface SmartCompressorOptions {
1919 indent ?: number ;
2020
2121 /**
22- * Delimiter for CSV arrays
23- * @default ', '
22+ * Delimiter for tabular arrays
23+ * @default '| '
2424 */
2525 delimiter ?: string ;
2626
@@ -31,10 +31,34 @@ export interface SmartCompressorOptions {
3131 useReferences ?: boolean ;
3232
3333 /**
34- * Enable inline-first value dictionary
34+ * Enable section organization for objects
3535 * @default true
3636 */
37- useDictionary ?: boolean ;
37+ useSections ?: boolean ;
38+
39+ /**
40+ * Enable tabular array format for uniform arrays
41+ * @default true
42+ */
43+ useTabular ?: boolean ;
44+
45+ /**
46+ * Minimum fields required to create a section
47+ * @default 3
48+ */
49+ minFieldsForSection ?: number ;
50+
51+ /**
52+ * Minimum rows required for tabular format
53+ * @default 2
54+ */
55+ minRowsForTabular ?: number ;
56+
57+ /**
58+ * Minimum occurrences required to create a reference
59+ * @default 2
60+ */
61+ minReferenceOccurrences ?: number ;
3862}
3963
4064/**
@@ -94,10 +118,10 @@ export class SmartCompressor {
94118 /**
95119 * Compresses JSON data into ASON format.
96120 *
97- * Performs a three -pass compression:
98- * 1. Detect repeated array structures (3+ occurrences )
99- * 2. Detect repeated objects (2+ occurrences )
100- * 3. Detect frequent string values (2+ occurrences )
121+ * Performs multi -pass compression:
122+ * 1. Detect repeated values (references → $var )
123+ * 2. Detect object organization (sections → @section )
124+ * 3. Detect uniform arrays (tabular → key:[N]{fields} )
101125 *
102126 * @param data - Any JSON-serializable data
103127 * @returns ASON-formatted string
@@ -111,7 +135,7 @@ export class SmartCompressor {
111135 * ]
112136 * };
113137 * const compressed = compressor.compress(data);
114- * // Output: users:[2]@ id,name,email\n1, Alice, alice@example.com\n2, Bob, bob@example.com
138+ * // Output: users:[2]{ id,name,email} \n1| Alice| alice@example.com\n2| Bob| bob@example.com
115139 * ```
116140 */
117141 compress ( data : any ) : string ;
@@ -120,20 +144,19 @@ export class SmartCompressor {
120144 * Decompresses ASON format back to original JSON structure.
121145 *
122146 * Parses the ASON format including:
123- * - $def: section for structure/object/value definitions
124- * - $data: section for actual data
125- * - Uniform array notation ([N]@keys)
126- * - Object aliases (&obj0)
127- * - Value dictionary references (#0)
147+ * - Tabular arrays (key:[N]{fields})
148+ * - Sections (@section)
149+ * - References ($var)
128150 * - Path flattening (a.b.c)
151+ * - Non-tabular arrays (- prefix)
129152 *
130153 * @param text - ASON formatted string
131154 * @returns Original JSON data structure
132155 * @throws {Error } If parsing fails due to malformed input
133156 *
134157 * @example
135158 * ```typescript
136- * const ason = "users:[2]@ id,name\n1, Alice\n2, Bob";
159+ * const ason = "users:[2]{ id,name} \n1| Alice\n2| Bob";
137160 * const original = compressor.decompress(ason);
138161 * // Returns: {users: [{id: 1, name: "Alice"}, {id: 2, name: "Bob"}] }
139162 * ```
0 commit comments