dart_kollection 0.3.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 26

Kollection #

Pub

Deprecated #

Please migrate to kt.dart

This package has been renamed to kt.dart. All code can be found here.

Upgrade #

pubspec.yaml

dependencies:
-  dart_kollection: ^0.3.0
+  kt_dart: ^0.5.0

your_source.dart

- import 'package:dart_kollection/dart_kollection.dart';
+ import 'package:kt_dart/kt.dart';

License #

Copyright 2018 Pascal Welsch

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

0.4.0 (unreleased) #

diff v0.3.0...master

0.3.0 #

diff v0.2.0...v0.3.0

Summary #

This release of Kollection fully covers the project with unit tests, from 52% to 99% 🎉. By doing that bugs where discovered and fixed.

Because Dart doesn't support non-nullable types yet, this update manually checks all method arguments at runtime. Passing null in any method will throw ArgumentError unless documented otherwise.

Behavior changes #

  • #36 All method arguments are now validated for nullability. If a argument isn't documented as "nullable" the method will throw ArgumentError (when asserts are enabled)
  • #51, #46 KIterable<T>.associateWithTo, Kiterable<T>.filterTo, KIterable<T>.filterIndexedTo, KIterable<T>.filterNotTo, KIterable<T>.filterNotNullTo , KIterable<T>.groupByTo ,KMap<T>.mapKeysTo ,KMap<T>.mapValuesTo, KIterable.toCollection did not compile when called directly due to dart-lang/sdk/issues/35518. The type of destination of those methods has been changed to a dynamic type (i.e. KMutableList<T> -> KMutableList<dynamic>). Those methods will now be checked at runtime. This has one advantage: It allows to pass in contravariant types.
final KIterable<int> iterable = listOf([4, 25, -12, 10]);
final result = mutableListOf<num>(); // covariant!
final filtered = iterable.filterIndexedTo(result, (i, it) => it < 10);
expect(identical(result, filtered), isTrue);
expect(result, listOf([4, -12]));
  • #56 KMutableEntry.setValue now throws UnimplementedError because of bug #55. It anyways never worked.
  • #58 KSet doesn't allow mutation of its elements with via set getter. It is now really immutable.

API changes #

Bug fixes #

Documentation changes #

  • #57 Document hashSetOf and linkedSetOf
  • #19 KIterable.any document return value when called without predicate
  • #51 Document expected type of now dynamically typed KIterable<T>.associateWithTo, Kiterable<T>.filterTo, KIterable<T>.filterIndexedTo, KIterable<T>.filterNotTo, KIterable<T>.filterNotNullTo , KIterable<T>.groupByTo ,KMap<T>.mapKeysTo ,KMap<T>.mapValuesTo, KIterable.toCollection

Other changes #

0.2.0 #

diff v0.1.0...v0.2.0

Behavior change #

  • #6 Breaking: KMutableIterator.remove now throws UnimplementedError because of bug #5

API changes #

  • #1 Add Set<T> get set returning the internal dart set
  • #1 Add Map<K, V> get map returning the intenral dart set
  • #7 Add KMap.toMap and KMap.toMutableMap
  • #8 Add KMap.isNotEmpty
  • 3e3228e Add KMap.toString()
  • #9 Add Map.plus, Map.minus and operator +(KMap<K, V> map), operator -(K key)
  • #12 Remove const constructors from collection interfaces
  • #13 Remove default implementations from collection interfaces

Documentation changes #

  • #15 Add documentation for compareBy and compareByDescending

Other changes #

  • #2 Travis CI #2
  • #3, #4 Code coverage
  • #10 Test KMutableList.fill
  • #11 Test KPair, KTriple
  • #14 Test Exceptions
  • #15 Test Comparators naturalOrder(), reverseOrder()
  • #15 Test reverse(Comparator) util function
  • 6dd0d85 Reformatted with dartfmt (80 chars)

0.1.0 #

Initial release for

  • KList/KMutableList
  • KSet/KMutableSet
  • KMap/KMutableMap

with tons of extensions waiting for you to use them!

example/main.dart

import 'package:dart_kollection/dart_kollection.dart';

void main() {
  /**
   * Lists
   */
  final mapped = listOf(1, 2, 3, 4).map((it) => ">$it<");
  print(mapped); // [>1<, >2<, >3<, >4<]

  final flatMapped = listOf(1, 2, 3, 4).flatMap((it) => listOf(it * 2, it * 3));
  print(flatMapped); // [2, 3, 4, 6, 6, 9, 8, 12]

  final filtered = flatMapped.filter((it) => it % 3 == 0);
  print(filtered); // [3, 6, 6, 9, 12]

  final distinct = listFrom([1, 2, 3, 1, 2, 3]).distinct();
  print(distinct); //[1, 2, 3]

  /**
   * Better equals
   */
  final kListEquals = listOf(12, 9, 6, 3) == listOf(12, 9, 6, 3);
  print(kListEquals); // true

  final dartListEquals = [12, 9, 6, 3] == [12, 9, 6, 3];
  print(dartListEquals); // false

  final kMapEquals = mapFrom({1: "Bulbasaur", 2: "Ivysaur"}) ==
      mapFrom({1: "Bulbasaur", 2: "Ivysaur"});
  print(kMapEquals); // true

  final dartMapEquals =
      {1: "Bulbasaur", 2: "Ivysaur"} == {1: "Bulbasaur", 2: "Ivysaur"};
  print(dartMapEquals); // false

  /**
   * Sets
   */
  print(setOf(1, 2, 3, 1, 2, 3)); // [1, 2, 3]

  /**
   * Maps
   */
  final pokemon = mutableMapFrom({
    1: "Bulbasaur",
    2: "Ivysaur",
  });
  pokemon[1] = "Ditto";
  print(pokemon); // {1=Ditto, 2=Ivysaur}

  /**
   * Tons of useful operators which *should* be part of the dart std lib
   */
  final numbers = listOf(1, 2, 3, 4);
  print(numbers.sum()); // 10

  final numbers5 = listOf(1, 2, 3, 4).sortedDescending();
  print(numbers5); // [4, 3, 2, 1]

  final beatles = setOf("John", "Paul", "George", "Ringo");
  print(beatles); // [John, Paul, George, Ringo]
  print(beatles.joinToString(
      separator: "/",
      transform: (it) => it.toUpperCase())); // JOHN/PAUL/GEORGE/RINGO

  final grouped = beatles.groupBy((it) => it.length);
  print(grouped); // {4=[John, Paul], 6=[George], 5=[Ringo]}
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_kollection: ^0.3.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dart_kollection/dart_kollection.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
10
Health:
Code health derived from static analysis. [more]
2
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
26
Learn more about scoring.

We analyzed this package on Oct 24, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:dart_kollection/dart_kollection.dart.

Health suggestions

Fix lib/src/extension/iterable_extension_mixin.dart. (-66.13 points)

Analysis of lib/src/extension/iterable_extension_mixin.dart reported 216 hints, including:

line 9 col 39: 'KIterable' is deprecated and shouldn't be used.

line 16 col 17: 'KCollection' is deprecated and shouldn't be used.

line 16 col 41: 'KCollection' is deprecated and shouldn't be used.

line 28 col 19: 'KCollection' is deprecated and shouldn't be used.

line 28 col 49: 'KCollection' is deprecated and shouldn't be used.

Fix lib/src/k_iterable.dart. (-64.57 points)

Analysis of lib/src/k_iterable.dart reported 207 hints, including:

line 3 col 1: Prefer using /// for doc comments.

line 11 col 3: Prefer using /// for doc comments.

line 16 col 3: Prefer using /// for doc comments.

line 23 col 3: Prefer using /// for doc comments.

line 28 col 3: Prefer using /// for doc comments.

Fix lib/src/k_map.dart. (-23.33 points)

Analysis of lib/src/k_map.dart reported 53 hints, including:

line 5 col 1: Prefer using /// for doc comments.

line 28 col 3: Prefer using /// for doc comments.

line 34 col 3: Prefer using /// for doc comments.

line 39 col 3: Prefer using /// for doc comments.

line 44 col 3: Prefer using /// for doc comments.

Fix additional 37 files with analysis or formatting issues. (-151.76 points)

Additional issues in the following files:

  • lib/src/extension/map_extensions_mixin.dart (34 hints)
  • lib/src/k_list.dart (33 hints)
  • lib/src/extension/list_extension_mixin.dart (20 hints)
  • lib/src/k_map_mutable.dart (20 hints)
  • lib/src/collections.dart (19 hints)
  • lib/src/collection/list_mutable.dart (14 hints)
  • lib/src/k_list_mutable.dart (14 hints)
  • lib/src/collection/set_mutable.dart (13 hints)
  • lib/src/collection/list.dart (12 hints)
  • lib/src/collection/list_empty.dart (12 hints)
  • lib/src/collection/map_mutable.dart (11 hints)
  • lib/src/collection/map.dart (10 hints)
  • lib/src/k_collection.dart (10 hints)
  • lib/src/collection/map_empty.dart (8 hints)
  • lib/src/collection/set.dart (8 hints)
  • lib/src/k_iterator.dart (8 hints)
  • lib/src/collection/iterator.dart (7 hints)
  • lib/src/k_collection_mutable.dart (7 hints)
  • lib/src/k_iterator_mutable.dart (7 hints)
  • lib/src/collection/iterable.dart (6 hints)
  • lib/src/collection/set_empty.dart (6 hints)
  • lib/src/comparisons.dart (5 hints)
  • lib/src/extension/map_mutable_extensions_mixin.dart (5 hints)
  • lib/src/k_iterable_mutable.dart (4 hints)
  • lib/src/util/annotations.dart (4 hints)
  • lib/src/extension/list_mutable_extension_mixin.dart (3 hints)
  • lib/src/extension/collection_extension_mixin.dart (2 hints)
  • lib/src/extension/iterable_mutable_extension_mixin.dart (2 hints)
  • lib/src/k_set.dart (2 hints)
  • lib/src/tuples.dart (2 hints)
  • lib/src/collection/map_hash.dart (1 hint)
  • lib/src/collection/map_linked.dart (1 hint)
  • lib/src/collection/set_hash.dart (1 hint)
  • lib/src/collection/set_hash_linked.dart (1 hint)
  • lib/src/extension/collection_mutable_extension_mixin.dart (1 hint)
  • lib/src/k_set_mutable.dart (1 hint)
  • lib/src/util/arguments.dart (1 hint)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.0.0