From 490a3b205ffef27d9865d6018381a4168119e69f Mon Sep 17 00:00:00 2001 From: Pascal Welsch Date: Sun, 1 Mar 2020 18:52:47 +0100 Subject: [PATCH] Prepare 0.7.0 release --- CHANGELOG.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43dece8f..3e7522a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,59 @@ +## 0.7.0 + +The library has be upgrade to use [`Static Extension Methods`](https://github.com/dart-lang/language/issues/41). + +### Interop + +This update also includes extensions for Dart collections which allow easy interoperability between dart and kt.dart collections using the `.kt` and `.dart` getters. + +```dart + // New: Converting dart collections to KtDart collections (mutable views) + final KtMutableList ktList = ["hey"].kt; + final KtMutableSet ktSet = {"hey"}.kt; + final KtMutableMap ktMap = {"hey": 1}.kt; + + // Converting KtDart collections to dart collections + final List dartList = KtList.of("hey").dart; + final Set dartSet = KtSet.of("hey").dart; + final Map dartMap = KtMap.from({"hey": 1}).dart; +``` + +Note: `["Hello", "World"].kt` returns a `KtMutableList` and mutations are reflected on the original dart list. It is not a copy! Because it doesn't copy it is very cheap and only syntax sugar. + +To convert dart collections to their immutable kt.dart counterparts use: `.toImmutableList()`, `.toImmutableSet()`, `.toImmutableMap()` + +```dart + // New: Make dart collections immutable + final KtList list = ["hey"].toImmutableList(); + final KtSet set = {"hey"}.toImmutableSet(); + final KtMap map = {"hey": 1}.toImmutableMap(); +``` + +### Possible breaking changes + +- Relax `sortBy`/`sortByDescending`, `maxBy`/`minBy` typing to work better with ints and doubles [#116](https://github.com/passsy/kt.dart/pull/116) +```dart +// Was: int doesn't not implement Comparable but Comparable +// minBy therefore required some help to figure out the correct type () +users.minBy((it) => it.age); + +// Now: minBy doesn't require the Comparable (num) to have the same same as the value (int). +users.minBy((it) => it.age); +``` +- Remove unnecessary generic `R` from `KtIterable.zipWithNext` [#118](https://github.com/passsy/kt.dart/pull/118) + +### New Extensions +- `KtPair` and `KtTriple` now have a new `toList()` function to convert the values to a `KtList` +- `KtList?.orEmpty()` returns an empty list when the list is `null` +- `KtSet?.orEmpty()` returns an empty set when the set is `null` +- `KtMap?.orEmpty()` returns an empty map when the map is `null` +- `KtMap.ifEmpty(() -> defaultValue)` returns the default value when the map is empty +- `KtIterable>.flatten()` flattens the nested collections to `KtIterable` +- `KtIterable>.unzip(): KtPair, KtList>` unzips list of pairs to list of their first and second values +- `KtIterable>.min()` returns the smallest element of any comparable iterable +- `KtIterable>.max()` returns the largest element of any comparable iterable + + ## 0.7.0-dev.4 - New extension `Iterable.toImmutableList(): KtList`