Skip to content

Commit

Permalink
accept any iterable when serializing; bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
knopp committed Sep 20, 2019
1 parent 42eda8b commit f85067e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.0.1] - TODO: Add release date.
## [0.0.5] - 2019-05-19

* TODO: Describe initial release.
* Changed return value from `List<int>` to `Uint8List`.

## [0.0.6] - 2019-09-20

* Accept any iterable when serializing, not just List
8 changes: 4 additions & 4 deletions lib/src/serializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Serializer {
if (d is double) return _writeDouble(d);
if (d is String) return _writeString(d);
if (d is Uint8List) return _writeBinary(d);
if (d is List) return _writeArray(d);
if (d is Iterable) return _writeIterable(d);
if (d is Map) return _writeMap(d);
if (_extEncoder != null && _writeExt(d)) {
return;
Expand Down Expand Up @@ -126,8 +126,8 @@ class Serializer {
_writer.writeBytes(buffer);
}

void _writeArray(List array) {
final length = array.length;
void _writeIterable(Iterable iterable) {
final length = iterable.length;

if (length <= 0xF) {
_writer.writeUint8(0x90 | length);
Expand All @@ -141,7 +141,7 @@ class Serializer {
throw FormatError("Array is too big to be serialized with msgpack");
}

for (final item in array) {
for (final item in iterable) {
encode(item);
}
}
Expand Down

0 comments on commit f85067e

Please sign in to comment.