Skip to content

feat: unnest transform#78

Open
close2 wants to merge 1 commit intomasterfrom
CL/v8
Open

feat: unnest transform#78
close2 wants to merge 1 commit intomasterfrom
CL/v8

Conversation

@close2
Copy link
Owner

@close2 close2 commented Mar 17, 2026

fixes #77

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #77 by changing the library’s stream transformation model so CSV decoding/encoding streams emit one row per event, eliminating the extra List<List<...>> nesting that appeared when using Stream.transform(...).toList() after upgrading to v7.

Changes:

  • Refactors CsvDecoder and CsvEncoder to be StreamTransformerBase implementations (row-per-event) while keeping batch convert(...)-style APIs.
  • Introduces Csv as the primary API (with deprecated CsvCodec typedef) and adds asCodec() as a dart:convert Codec adapter for .fuse() use cases.
  • Updates tests, examples, benchmarks, docs, changelog, and bumps package version to 8.0.0.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/src/csv_decoder.dart Refactors decoding to emit one row per stream event while preserving batch decode via convert().
lib/src/csv_encoder.dart Refactors encoding to accept one row per stream event and preserves batch encode via convert().
lib/src/csv_codec.dart Replaces CsvCodec class with Csv, adds encode/decode helpers and introduces asCodec() adapter.
lib/csv.dart Updates top-level csv/excel instances to use Csv.
test/csv_test.dart Updates chunked conversion tests to assert flat row emission and new encoder input types.
test/small_chunk_test.dart Updates expectations to match row-per-event decoding (no manual flattening).
test/parse_headers_test.dart Updates to construct Csv(parseHeaders: true) and keeps header parsing behavior tests.
test/split_escape_test.dart Updates chunked decoding sink setup to collect row events directly.
test/split_crlf_test.dart Same as above for CRLF chunking scenarios.
test/multi_char_delim_test.dart Same as above for multi-character delimiter chunking scenarios.
example/csv_fuse_example.dart Updates .fuse() example to use csv.asCodec() as the supported path.
benchmark/benchmark_csv.dart Updates benchmark streams to use per-row events and uses asCodec() for fuse benchmarking.
README.md Documents v8 upgrade, stream row-per-event behavior, and explains the Codec/asCodec() tradeoff.
CHANGELOG.md Adds v8.0.0 entry describing the fix and breaking changes.
pubspec.yaml Bumps version to 8.0.0 and updates package description.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +176 to +179
Sink<String> startChunkedConversion(Sink<List<List<dynamic>>> sink) {
// Wrap the batch sink so individual rows are collected into batches.
return _decoder.startChunkedConversion(_BatchingSink(sink));
}
Comment on lines +138 to +142
/// // Fuse with another codec
/// final fused = csv.asCodec().decoder.fuse(someConverter);
/// ```
Codec<List<List<dynamic>>, String> asCodec() => _CsvCodecAdapter(this);
}
- `CsvCodec` has been renamed to `Csv`. A deprecated `CsvCodec` typedef is
available for migration.
- `Csv` no longer extends `dart:convert`'s `Codec` class. If you need a `Codec`
(e.g., for `.fuse()`), use [`asCodec()`](#the-codec-problem--ascodec).
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.

openRead returns one more layer of []

2 participants