Skip to content

Commit afb2e92

Browse files
committed
Release 2.0.0-preview with new options and tabular format
Update CLI and type definitions to support sections, tabular arrays, and related options. Change default delimiter to pipe. Update documentation and examples for new features.
1 parent b47cdb1 commit afb2e92

File tree

4 files changed

+53
-25
lines changed

4 files changed

+53
-25
lines changed

nodejs-compressor/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [2.0.0] - 2025-01-13
8+
## [2.0.0-preview] - 2025-01-14
99

1010
### 🚀 Major Release - ASON 2.0
1111

nodejs-compressor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ason-format/ason",
3-
"version": "1.1.4",
3+
"version": "2.0.0-preview",
44
"description": "ASON (Aliased Serialization Object Notation) - Token-optimized JSON compression for LLMs. Reduces tokens by 20-60% while maintaining perfect round-trip fidelity.",
55
"main": "./dist/index.cjs",
66
"module": "./dist/index.js",

nodejs-compressor/src/cli.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ function parseArgs(args) {
1515
output: null,
1616
encode: false,
1717
decode: false,
18-
delimiter: ',',
18+
delimiter: '|',
1919
indent: 1,
2020
stats: false,
2121
useReferences: true,
22-
useDictionary: true
22+
useSections: true,
23+
useTabular: true
2324
};
2425

2526
for (let i = 0; i < args.length; i++) {
@@ -39,8 +40,10 @@ function parseArgs(args) {
3940
options.stats = true;
4041
} else if (arg === '--no-references') {
4142
options.useReferences = false;
42-
} else if (arg === '--no-dictionary') {
43-
options.useDictionary = false;
43+
} else if (arg === '--no-sections') {
44+
options.useSections = false;
45+
} else if (arg === '--no-tabular') {
46+
options.useTabular = false;
4447
} else if (arg === '-h' || arg === '--help') {
4548
showHelp();
4649
process.exit(0);
@@ -66,11 +69,12 @@ OPTIONS:
6669
-o, --output <file> Output file path (prints to stdout if omitted)
6770
-e, --encode Force encode mode (JSON → ASON)
6871
-d, --decode Force decode mode (ASON → JSON)
69-
--delimiter <char> Delimiter for arrays: ',' (comma), '\\t' (tab), '|' (pipe)
72+
--delimiter <char> Delimiter for tabular arrays: '|' (pipe), ',' (comma), '\\t' (tab)
7073
--indent <number> Indentation size (default: 1)
7174
--stats Show token count estimates and savings
72-
--no-references Disable object reference detection
73-
--no-dictionary Disable value dictionary
75+
--no-references Disable reference detection ($var)
76+
--no-sections Disable section organization (@section)
77+
--no-tabular Disable tabular array format (key:[N]{fields})
7478
-h, --help Show this help message
7579
7680
EXAMPLES:
@@ -194,7 +198,8 @@ try {
194198
indent: options.indent,
195199
delimiter: options.delimiter,
196200
useReferences: options.useReferences,
197-
useDictionary: options.useDictionary
201+
useSections: options.useSections,
202+
useTabular: options.useTabular
198203
});
199204

200205
if (mode === 'encode') {

nodejs-compressor/src/index.d.ts

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)