# more 4.5.0

More Dart — Literally. Collecting, iterating, caching, mathematics, matching, ordering, and formatting easily.




## Installing
```
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'more:4.5.0'
```
Published: 2024-12-25T06:46:29.070497Z
Expected archive SHA-256: d3908d710f78ee5470d2ae9d7599a11aeb00a17909cc36cbd0f23a0b659ca375

Available in cache; verification: upstream_checksum
## Direct dependencies
- characters: ^1.3.0
- clock: ^1.1.0
- collection: ^1.19.0
- meta: ^1.16.0

## Package README (untrusted upstream documentation)
More Dart — Literally
=====================

[![Pub Package](https://img.shields.io/pub/v/more.svg)](https://pub.dev/packages/more)
[![Build Status](https://github.com/renggli/dart-more/actions/workflows/dart.yml/badge.svg?branch=main)](https://github.com/renggli/dart-more/actions/workflows/dart.yml)
[![Code Coverage](https://codecov.io/gh/renggli/dart-more/branch/main/graph/badge.svg?token=b0fvRMeMBR)](https://codecov.io/gh/renggli/dart-more)
[![GitHub Issues](https://img.shields.io/github/issues/renggli/dart-more.svg)](https://github.com/renggli/dart-more/issues)
[![GitHub Forks](https://img.shields.io/github/forks/renggli/dart-more.svg)](https://github.com/renggli/dart-more/network)
[![GitHub Stars](https://img.shields.io/github/stars/renggli/dart-more.svg)](https://github.com/renggli/dart-more/stargazers)
[![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/renggli/dart-more/main/LICENSE)

A collection of extensively tested extensions that make Dart a better place:

| Library                                                                                          | Description                                                        |
|--------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------|
| [async](https://pub.dev/documentation/more/latest/async/async-library.html)                      | Extensions to `Stream`.                                            | 
| [cache](https://pub.dev/documentation/more/latest/cache/cache-library.html)                      | Caching strategies and their expiry policy.                        |
| [char_matcher](https://pub.dev/documentation/more/latest/char_matcher/char_matcher-library.html) |  Character classes, their composition, and operations on strings.  |
| [collection](https://pub.dev/documentation/more/latest/collection/collection-library.html)       | Extensions to `Iterable` and new collection types.                 |
| [comparator](https://pub.dev/documentation/more/latest/comparator/comparator-library.html)       | Common comparators, and extensions to perform advanced operations. | 
| [diff](https://pub.dev/documentation/more/latest/comparator/diff-library.html)                   | Tools for comparing lists.                                         | 
| [feature](https://pub.dev/documentation/more/latest/feature/feature-library.html)                | Information about the runtime environment.                         |
| [functional](https://pub.dev/documentation/more/latest/functional/functional-library.html)       | Types and features known from functional programming.              |
| [graph](https://pub.dev/documentation/more/latest/graph/graph-library.html)                      | Graph-theory objects and algorithms.                               |
| [interval](https://pub.dev/documentation/more/latest/interval/interval-library.html)             | Continuous interval data type over a comparable type.              |
| [math](https://pub.dev/documentation/more/latest/math/math-library.html)                         | Common mathematical functions.                                     |
| [number](https://pub.dev/documentation/more/latest/number/number-library.html)                   | Number types: fraction, complex, quaternion.                       |
| [printer](https://pub.dev/documentation/more/latest/printer/printer-library.html)                | Fluent interface to configure sophisticated formatter.             |
| [temporal](https://pub.dev/documentation/more/latest/temporal/temporal-library.html)             | Extensions to `DateTime` and `Duration` types.                     | 
| [tuple](https://pub.dev/documentation/more/latest/tuple/tuple-library.html)                      | Tuple extension methods on generic records.                        |

And there are more to come ...

This library is open source, stable and well tested. Development happens on [GitHub](https://github.com/renggli/dart-more). Feel free to report issues or create a pull-request there. General questions are best asked on [StackOverflow](https://stackoverflow.com/questions/tagged/more+dart).

The package is hosted on [dart packages](https://pub.dev/packages/more). Up-to-date [class documentation](https://pub.dev/documentation/more/) is created with every release.


Misc
----

### Installation

Follow the installation instructions on [dart packages](https://pub.dev/packages/more/install).

Import the all-including parent package:

```dart
import 'package:more/more.dart';
```

Or one or more of the specific packages into your Dart code:

```dart
import 'package:more/async.dart';
import 'package:more/cache.dart';
import 'package:more/char_matcher.dart';
import 'package:more/collection.dart';
import 'package:more/comparator.dart';
import 'package:more/diff.dart';
import 'package:more/feature.dart';
import 'package:more/functional.dart';
import 'package:more/graph.dart';
import 'package:more/interval.dart';
import 'package:more/math.dart';
import 'package:more/number.dart';
import 'package:more/printer.dart';
import 'package:more/temporal.dart';
import 'package:more/tuple.dart';
```

### Contributing

The goal of the library is to provide a loose collection of carefully curated utilities that are not provided by the Dart standard library. All features must be well tested. New features must have significant advantages over alternatives, such as code reduction, readability improvement, speed increase, memory reduction, or improved accuracy. In case of doubt, consider filing a feature request before filing a pull request.

### History

This library started in April 2013 as I was working through the puzzles of [Project Euler](https://projecteuler.net/) and encountered some missing features in Dart. Over time the code grew and became _more_ useful in many other places, so I created this reusable library.

Some parts of this library are inspired by similar APIs in [Google Guava](https://github.com/google/guava) (Google core libraries for Java) and [Apache Commons](https://commons.apache.org/) (a repository of reusable Java components).

### License

The MIT License, see [LICENSE](https://github.com/renggli/dart-more/raw/main/LICENSE).

## Changelog
# Changelog

## 4.5.0
- Add `occurences` helper to `Iterable`and `SortedList`.
- More customization for number grouping in all numeric formatters.
- Split date-time formatters into configurable constructors for date and times.
- Deprecate some obscure and introduce more readable naming in `Multiset` and `Multimap`.
- Add the possibility to convert a lambda returning a `Comparable` to a `Comparator` with `delegateComparator`.
- Various improvements to graph search, strongly connected components, and find cliques algorithms.
- Various optimization, such as the decoding of unicode data.

## 4.4.0
- Add [Bidirectional Character Types](https://www.unicode.org/reports/tr9/#Table_Bidirectional_Character_Types) to `UnicodeCharMatcher` (thanks to https://github.com/amake).
- Remove no longer necessary JavaScript specific code.
- Optimize function types.

## 4.3.0
- Dart 3.4 requirement.
- Make `IntegerRange` and `DoubleRange` const constructable.
- Numerous improvements to the Graph library:
  - Add `Graph.where(edgePredicate)` for filtering by edge.
  - Add Prim's minimum spanning tree.
- Simplify the `Interval` implementation to only support closed intervals.
- Add a `Fenwick` and `Interval` trees.
- Minor bug-fixes.

## 4.2.0
- Improved `Iterable.index` to more common argument names, and support `step`.
- Add `also` scope operator, which significantly improves the possibility to write one-liners.
- Numerous improvements to the Graph library:
  - Various performance critical fixes, better use of priority queues.
  - Easy export to [GraphViz](https://graphviz.org/) with `Graph.toDot()`.
  - Add support for filtered vertex views with `Graph.where({Predicate<V> vertexPrediate})`.
  - Add support to copy graphs with `Graph.copy({bool empty})`.
  - Improve `toString` of `Graph`, `Edge` and `Path` classes.
  - Add the Stoer-Wagner min-cut algorithm.
- Numerous smaller improvements:
  - Add support for patterns in `String.removeSuffix`; and add `String.partition` and `String.lastPartition`.
  - Add support to compute `Iterable.minMax` in one pass, and `Iterable.gcd` and `Iterable.lcm`.
- Removed `Heap`: `PriorityQueue` from the Dart standard library provides the same functionality.
- Made the `SortedList` implement `PriorityQueue`.

## 4.1.0
- Add a port of Python's difflib.
- `CharMatcher` now works on all unicode code-points, correctly and efficiently matching unicode characters beyond UTF-16 bytes:
  - Add support for all [Unicode General Categories](https://www.unicode.org/reports/tr44/#General_Category_Values) and [Unicode Properties](https://www.unicode.org/reports/tr44/#Properties).
  - Add support for _Character Class Subtraction_ to `CharMatcher.pattern`.
  - For consistency `CharMatcher.whitespace()` is only matching ASCII whitespaces, to get the Unicode variant use `UnicodeCharMatcher.whiteSpace()`.
  - Add `CharMatcher.punctuation()` for ASCII punctuation characters.
- Various improvements to graph library:
  - Add support for unmodifiable graphs.
  - Add support to compute the max-flow.
  - Rename `GraphBuilder` with `GraphFactory`.
  - Replace `Graph.getEdges` with `Graph.getEdge`, add `Graph.putEdge`.
- Make object printer syntax to look like tuples, no need to have these weird curly braces anymore.
- Add `double.nextUp`, `double.nextDown`, `double.nextTowards(double)`, and `double.ulp`.
- Add growable flag to `SortedList` constructors.
- Add Farey sequence to `Fraction`.
- Improve documentation across many parts of the library.

## 4.0.0
* Dart 3.0 requirement.
* Removed deprecated code.
* Reimplement `Tuple` on top of records:
  * Replace types like `Tuple2<String, int>` with `(String, int)`.
  * Replace constructors like `Tuple2('hello', 42)` with `('hello', 42)`.
* Add `Iterable.pairwise` over the successive overlapping pairs.
* Add `Iterable.deepFlatten` over arbitrarily nested iterables.
* Add `product` and `zip` extensions on tuples of iterables.
* Add partial function evaluation, and currying extensions.

## 3.10.0
* Add a growable `BitList`, make it behave more like `List<bool>`.
* Optimize  `BitList` operations: `fill`, `count`, and `indices`.
* Change return type of generic `throwFunction` to `Never`.
* Add graph algorithms and data structures.
* Add `Map.withDefault` providing a default value for non-existing keys.
* Add support to generate permutations with a specified length, as well as extensions to generate the previous and next permutation.

## 3.9.0
* Various extension to work with bits.
* Add iterator over `BitList.indices` that are true or false.
* Add experimental `RTree` implementation.
* Various optimizations and improvements to mathematical functions.
* Generalize the prime sieve implementation and add support for more efficient primality check and factorization.
* More efficient implementation of `repeat` for a single element.
* Make `Iterable.groupBy` and `Iterable.indexed` return instances of `MapEntry` for easier interoperability with `Map`.
* Fix various edge cases with `Range` iterables.
* Fix `Iterable.combinations` for empty iterables.
* Add `List` extensions `takeTo`, `skipTo`, `takeLast`, `takeLastTo`, `skipLast`, and `skipLastTo`.
* Add `Iterable` extension `count` and `powerSet`.
* Deprecate `Iterable.cycle` in favor of `Iterable.repeat`.
* Deprecated `naturalComparator` in favor of `naturalCompare` and `naturalComparable<T>`.
* Deprecate the iterable package, and integrate the extensions into the collection package.

## 3.8.0
* Add `String` extensions `take`, `takeTo`, `skip`, `skipTo`, `takeLast`, `takeLastTo`, `skipLast`, and `skipLastTo`.
* Create a new `temporal` package unifying all `DateTime` and `Duration` related extensions:
  * Moved `DateTime.periodical` and `DateTime.truncate` to the new page, deprecated the old code.
  * Add various convenience accessors to `DateTime`: `isLeapYear`, `daysInYear`, `daysInMonth`, `weeksInYear`, `quarter`, `weekYear`, `weekNumber`, `dayOfYear`, and `hour12`.
  * Add ability to convert `Duration` objects to one or more (fractional) `TimeUnit`s.
* Countless improvements and extensions to the `printer` package:
  * Add `DateTimePrinter` to print date and time objects.
  * Add `OrdinalNumberPrinter` to print ordinal numbers: 1st, 2nd, 3rd, 4th, ...
  * Add `Printer.switcher` to use different printers based on conditions.
  * Add `Printer.where` to condition the printing on the printed object.
  * Add `Printer` support for `take`, `skip`, `takeLast` and `skipLast`.
  * Add `Printer` support for `truncateRight`, `truncateLeft`, and `truncateCenter` to also operate on word and sentence boundaries. Include the ellipsis in the width constraint.
  * Deprecated `Printer.map`, and replace with more common and intention revealing `Printer.onResultOf`.
* Implement the functionality of `Ordering` as static extensions methods on `Comparator` functions:
  * Add `Comparator.binarySearchLower` and `Comparator.binarySearchUpper` to return a lower/upper insertion index.
  * Add `Comparator.largest` and `Comparator.smallest` to return the top/bottom-k elements.
  * Deprecate the `Ordering` class and package.
* Create `Interval` to encapsulate bounded/unbounded and open/closed intervals across arbitrary `Comparable` objects.
  * Add the ability to measure the length of `Interval<int>.toIntLength()` and `Interval<num>.toDoubleLength()`.
  * Add ability to convert `Interval<DateTime>` to a `Duration`.
* Added `SortedList` collection type.
* Add `CompareOperators` mixin to provide operators given a `compareTo` method.

## 3.7.0
* Add `closeTo` extension to all numbers.
* Make `Fraction` support non-finite numbers.

## 3.6.0
* Dart 2.17 requirement.
* Add a max-heap collection type.
* Add predicates for the ordering type.
* Add interval data structure with open, closed, and infinite endpoints.

## 3.5.0
* Dart 2.16 requirement.
* Avoid dynamic calls.
* Better print strings across the library.

## 3.4.0
* Remove deprecated `hashAll` and `hash1`, `hash2`, `hash3`, ... methods.
* Add `ObjectPrinter.addValue` for more dynamic object printing.
* Add `ToStringPrinter` mixin for simpler use of `ObjectPrinter`.
* Add `Stream.window` along the existing `Iterable.window` extension (thanks to https://github.com/pihentagy).
* Various cleanups and better test coverage.

## 3.3.0
* Dart 2.14 requirement.
* Added `indent`/`dedent` and `wrap`/`unwrap` to `String`.
* Deprecated `hashAll` and `hash1`, `hash2`, `hash3`, ... methods, since this is now supported through the core library on `Object`.

## 3.2.0

* Make `Printer` significantly faster by reusing a single `StringBuffer` instance where possible.
* Make `Printer` strongly typed, which unfortunately comes with some required API changes:
  * Number printers do no longer support `BigInt`.
  * Number printers are directly instantiated, instead of using a factory on Printer.
* Improved the `Printer` library in various ways:
  * Renamed `undefined` to the more intention revealing `ifNull`.
  * Added `ifEmpty` to print something specific for empty `Iterables`.
  * Added `map` and `cast` printers for more flexible printing.
  * Add initial version of the `ObjectPrinter`.

## 3.1.0

* Dart 2.13 requirement.
* Add `Optional` and `Either` type.
* Add `TypeMap` that maps Dart types to an instance.
* Add various kinds of function types and function factories: 
    callback function types, 
    constant functions, 
    empty functions, 
    identity functions, 
    mapping function types, 
    predicate function types, and 
    throwing functions. 
* Add `String.convertFirstCharacters()` and `String.convertLastCharacters()`.
* Add `String.toUpperCaseFirstCharacter()` and `String.toLowerCaseFirstCharacter()`.

## 3.0.0

* Dart 2.12 requirement and null-safety.
* Use `package:clock` and `package:fake_async` across the board.
* Add `BigIntRange` and optimize iteration of `IntegerRange`.
* Optimize the implementation of `ExpiryCache`.
* Fix `maxAge` of the `Stream.buffer` operator.
* Add `Fraction.sign` and `Complex.sign`.
* Add `IterablePrinter` to print lists.
* Relax the type constraints on `Ordering.natural`.
* `CharMatcher` is now a `Pattern`.
* Introduce `package:more/feature.dart` to provide information about the runtime environment.
* Add `Trie` (prefix tree) collection type.
* Add `Ordering.percentile`. 
* Add `Iterable.toMap`, `Iterable.atRandom`, `Iterable.min`, `Iterable.max` and `Iterable.percentile`.
* Optimize `Range` object creation and error reporting, and add `Iterable.indices`.
* Add converters `toBiMap`, `toListMultimap`, and `toSetMultimap`.
* Add `String.removePrefix` and `String.removeSuffix`.
* Add `List.rotate` and `Queue.rotate`.

## 2.8.0

* Dart 2.9 compatibility and requirement (in preparation of null-safety).
* Remove `Iterable.concat()` in favor of `Iterable.flatten()`.
* Split `Iterable.zip()` into `Interable.zip()`, `Iterable.zipPartial()` and `Iterable.zipPartialWith()`.
* Fix a bug in `Ordering.nullsFirst` and `Ordering.nullsLast`.
* Fix a race condition in cache value resolution.
* Fix a rounding bug of numeric formats with precision 0.
* Add human number printer (1 kilo, 1 mega, ...).
* Add a map function to `Tuple` classes.

## 2.7.0

* Add `separatedBy`, `flatMap` and `flatten` function on `Iterable`.
* Cleanup `printer` package and improve documentation.

## 2.6.0

* Add `repeat` function on `Iterable`.
* Improved documentation.

## 2.5.0

* Printer package correctly trims, pads and separates unicode strings now.
* Updated class documentation regarding UTF-16 representation vs unicode strings. 

## 2.4.0

* Add in-place logical operators to `BitList`.
* Optimize `CharMatcher` with lookup tables.
* Improved documentation.

## 2.3.0

* Add `ListMultimap` and `SetMultimap`.
* Mark `CharMatcher`, `Cache` and `Ordering` as immutable.
* Improve documentation, which still included pre Dart 2.0 examples.
* Add extension methods to convert `Comparator` to `Ordering`.

## 2.2.0

* Made `truncateToPeriod` and `periodical` extension methods of `DateTime`.
* Add extension methods to convert 
  * a `Map<K, V>` to a `BiMap<K, V>`, 
  * an `Iterable<bool>` to a `BitList`, and
  * an `Iterable<T>` to a `Multiset<T>`.

## 2.1.0

* Cleanup `Tuple` class to be more readable and better typed.

## 2.0.0

* Dart 2.7 compatibility and requirement.
* Cleaned up deprecated code.
* Iterables
    * Converted most helpers to extension methods.
    * Removed `fold` and `fib`, as they are not generally useful.
    * Moved `digits` to `package:more/math`.
* Collections
    * Add extension method to `int` and `double` to create ranges, i.e. `0.to(20)`.
    * Move the string lists to `String.toList()` extension method.
* Math
    * Move all numerical operators to `num`, `ìnt` and/or `BigInt` (new).

## 1.18.0

* Dart 2.4 compatibility and requirement.
* Add a tuple data type.

## 1.17.0

* Dart 2.3 compatibility and requirement.
* Various code improvements and optimizations.

## 1.16.0

* Dart 2.2 compatibility and requirement.

## 1.15.0

* Deprecated `package:more/int_math` package, and moved all not-deprecated code to `package:more/math.dart`.
* Add 'polyfills' for hyperbolic functions to the math package.
* Add functionality for combining hash codes.

## 1.14.0

* Quaternion numbers.

## 1.13.0

* Rename `Range.stop` to `Range.end` to be consistent with Dart naming conventions.
* Rename `partition` to `chunked` to be more consistent with Dart nomenclature.
* Add the `zip` iterable.

## 1.12.0

* Add the number package.
  * Move `Fraction` class into this package.
  * Add support for `Complex` numbers. 
* Add the `groupBy` iterable.

## 1.11.0

* Add the printer package.

## 1.10.0

* Drop Dart 1.0 compatibility.

## 1.9.0

* Dart 2.0 strong-mode compatibility required the following breaking changes:
  * Replace callers of `range()` with either `IntegerRange()` or `DoubleRange()`.
  * Removed padding argument from `partition()`. To migrate replace broken
    calls-sites with `partitionWithPadding()`.

## 1.8.1

* Removed empty(), emptyIterator(), emptyIterable() since these are part of the core library now.
* Add periodic iterable tools (monthly, weekly, daily, hourly, ...).

## 1.8.0

* Ordering.reversed, Ordering.nullsFirst, Ordering.nullsLast, and Ordering.lexicographical
  are now properties for consistency with the Iterable protocol.
* Various optimization and improvements on the Range class.

## 1.7.2

* Cleanup after micro library migration.
* Move to the latest Dart provided mixins.

## 1.7.1

* Cleanup after micro library migration.
* Address linter warnings.
* Better test coverage.

## 1.7.0

* Migrate to micro libraries.
* Add caching library.

## 1.6.0

* Use generic method syntax.

## 1.5.3

* Fix pubspec SDK constraints.

## 1.5.2

* Fix linter warnings.
* Improve documentation.

## 1.5.1

* Strong compiler compliant.

## 1.5.0

* Fix various typos and linter issues.
* Reformat documentation.

## 1.4.0

* Migrate to Travis.






 
