Skip to content

Conversation

@badpirogrammer2
Copy link

No description provided.

- Understood how the existing synchronous API works with complete data in memory
- Designed streaming API interface
- Created `encodeStream()` and `decodeStream()` functions that return Transform streams
- Added stream-related types
 - Extended options interfaces with streaming-specific configurations
- Implemented encodeStream() function
- Processes streams of JSON values into TOON format strings
- Implemented decodeStream() function
- Processes streams of TOON strings into JSON values
- Updated main index.ts exports
- Exported streaming functions and types
- Added tests for streaming functionality
- Comprehensive test suite covering encoding, decoding, and round-trip scenarios
- Updated CLI to support streaming operations
- Added `--stream` flag with streaming implementations for both encode and decode operations
- Complex nested objects with arrays and primitives
- Key folding and path expansion options
- All TOON formatting features (tabular arrays, inline arrays, etc.)
- Proper handling of strings, numbers, booleans (null excluded from streams due to Node.js limitations)

 Implementation Quality
- Memory efficient: Processes data incrementally without loading entire datasets
- Backpressure handling: Proper Node.js stream flow control
- Error handling: Graceful handling of malformed input
- Type safety: Full TypeScript support with proper type definitions
- API consistency: Follows existing TOON library patterns and conventions
…token efficiency for very large datasets and CLI also
- **Data Archives**: Storage where size matters more than readability
- **API Communication**: Machine-to-machine data transfer
- **Large Datasets**: Anything over 1MB where compression helps
- **Streaming**: High-throughput data pipelines

**Do NOT use for:**
- Human-readable files
- Web API responses (JSON/TOON text expected)
- Small datasets (<10KB)
- Debugging scenarios (binary not inspectable)
@He-Pin
Copy link

He-Pin commented Nov 20, 2025

what about vs. cbor

@badpirogrammer2
Copy link
Author

badpirogrammer2 commented Nov 20, 2025

@He-Pin TOON's binary format is designed specifically for its token-efficient text format and maintains round-trip compatibility with TOON data, rather than conforming to CBOR standards.

for others,
CBOR is a standard binary serialization format defined in RFC 8949 that uses major/minor type encoding with 5-bit major types and additional information bytes. TOON's binary format is a custom implementation with different type identifiers and encoding rules, so here implemented a single-byte type.

CBOR uses encoded major types (e.g., null is 0xf6, boolean false is 0xf4)
while
TOON uses single-byte type IDs (e.g., null is 0x00, false is 0x01)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants