diff --git a/analysis_options.yaml b/analysis_options.yaml index 34672f4..5e537a3 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -17,6 +17,7 @@ linter: - comment_references - directives_ordering - invalid_case_patterns + - missing_code_block_language_in_doc_comment - no_self_assignments - no_wildcard_variable_uses - omit_local_variable_types @@ -33,6 +34,7 @@ linter: - unnecessary_await_in_return - unnecessary_breaks - unnecessary_lambdas + - unnecessary_library_name - unnecessary_null_aware_operator_on_extension_on_nullable - unnecessary_null_checks - unnecessary_parenthesis diff --git a/bin/generate_tuple.dart b/bin/generate_tuple.dart index 2d3ecba..8c012b6 100644 --- a/bin/generate_tuple.dart +++ b/bin/generate_tuple.dart @@ -47,7 +47,7 @@ Future generateExport() async { generateWarning(out); out.writeln('/// Tuple extension methods on generic records.'); - out.writeln('library tuple;'); + out.writeln('library;'); out.writeln(); out.writeln('export \'src/tuple/tuple.dart\';'); for (var i = 0; i < max; i++) { diff --git a/bin/generate_types.dart b/bin/generate_types.dart index 5cf0e48..1b0e620 100644 --- a/bin/generate_types.dart +++ b/bin/generate_types.dart @@ -14,7 +14,7 @@ Future generateCallback() async { generateWarning(out); out.writeln('/// Function types for generic callbacks.'); - out.writeln('library callback;'); + out.writeln('library;'); out.writeln(); for (var i = 0; i < max; i++) { @@ -35,7 +35,7 @@ Future generateMapping() async { generateWarning(out); out.writeln('/// Function type for generic mapping functions.'); - out.writeln('library mapping;'); + out.writeln('library;'); out.writeln(); for (var i = 0; i < max; i++) { @@ -56,7 +56,7 @@ Future generatePredicate() async { generateWarning(out); out.writeln('/// Function type for generic predicate functions.'); - out.writeln('library predicate;'); + out.writeln('library;'); out.writeln(); for (var i = 0; i < max; i++) { @@ -77,7 +77,7 @@ Future generateEmpty() async { generateWarning(out); out.writeln('/// Generic empty functions returning nothing.'); - out.writeln('library empty;'); + out.writeln('library;'); out.writeln(); for (var i = 0; i < max; i++) { @@ -98,7 +98,7 @@ Future generateIdentity() async { generateWarning(out); out.writeln('/// Generic identity functions.'); - out.writeln('library identity;'); + out.writeln('library;'); out.writeln(); out.writeln('/// Generic identity function with 1 positional argument.'); @@ -115,7 +115,7 @@ Future generateConstant() async { generateWarning(out); out.writeln('/// The constant functions.'); - out.writeln('library constant;'); + out.writeln('library;'); out.writeln(); out.writeln("import 'mapping.dart';"); @@ -141,7 +141,7 @@ Future generateThrowing() async { generateWarning(out); out.writeln('/// The throwing functions.'); - out.writeln('library throwing;'); + out.writeln('library;'); out.writeln(); out.writeln("import 'mapping.dart';"); @@ -169,7 +169,7 @@ Future generatePartial() async { out.writeln('/// Binds positional arguments and returns a new function:'); out.writeln('/// https://en.wikipedia.org/wiki/Partial_application'); - out.writeln('library partial;'); + out.writeln('library;'); out.writeln(); out.writeln("import 'mapping.dart';"); @@ -211,7 +211,7 @@ Future generateCurry() async { 'sequence of functions '); out.writeln('/// taking a single argument: ' 'https://en.wikipedia.org/wiki/Currying'); - out.writeln('library curry;'); + out.writeln('library;'); out.writeln(); out.writeln("import 'mapping.dart';"); diff --git a/lib/async.dart b/lib/async.dart index ec15c11..05bf150 100644 --- a/lib/async.dart +++ b/lib/async.dart @@ -1,5 +1,5 @@ /// Helpers to make async code better. -library async; +library; export 'src/async/buffer.dart' show BufferExtension; export 'src/async/flat_map.dart' show FlatMapStreamExtension; diff --git a/lib/cache.dart b/lib/cache.dart index 7f4625a..3eb0eeb 100644 --- a/lib/cache.dart +++ b/lib/cache.dart @@ -1,5 +1,5 @@ /// Collection of different caching strategies and their expiry policy. -library cache; +library; export 'src/cache/cache.dart'; export 'src/cache/delegate.dart'; diff --git a/lib/char_matcher.dart b/lib/char_matcher.dart index 9666ab6..92b7440 100644 --- a/lib/char_matcher.dart +++ b/lib/char_matcher.dart @@ -1,6 +1,6 @@ /// A first-class model of character classes, their composition and operations /// on strings. -library char_matcher; +library; export 'src/char_matcher/char_matcher.dart'; export 'src/char_matcher/unicode/unicode.dart'; diff --git a/lib/collection.dart b/lib/collection.dart index 4aa8480..7070420 100644 --- a/lib/collection.dart +++ b/lib/collection.dart @@ -1,6 +1,6 @@ /// A collection of iterable extensions and new collection types: bi-map, /// bit-list, multi-set, set and list multi-map, range, and string. -library collection; +library; export 'src/collection/bimap.dart' show BiMap, BiMapOnIterableExtension, BiMapOnMapExtension; diff --git a/lib/comparator.dart b/lib/comparator.dart index 669de41..dc352d9 100644 --- a/lib/comparator.dart +++ b/lib/comparator.dart @@ -1,6 +1,6 @@ /// Provides default [Comparator] constructors, and various static extension /// methods to modify and perform common operations on [Comparator] functions. -library comparator; +library; export 'src/comparator/compare_operators.dart'; export 'src/comparator/constructors/explicit.dart'; diff --git a/lib/diff.dart b/lib/diff.dart index c069d97..94d798d 100644 --- a/lib/diff.dart +++ b/lib/diff.dart @@ -1,6 +1,6 @@ /// Port of Python's difflib library to Dart providing tools for comparing /// lists. -library diff; +library; export 'src/diff/close_matches.dart'; export 'src/diff/differ.dart'; diff --git a/lib/feature.dart b/lib/feature.dart index 3658238..416bd1f 100644 --- a/lib/feature.dart +++ b/lib/feature.dart @@ -1,5 +1,5 @@ /// Information about the runtime environment. -library feature; +library; import 'dart:math'; diff --git a/lib/functional.dart b/lib/functional.dart index 65f719e..37dbb3c 100644 --- a/lib/functional.dart +++ b/lib/functional.dart @@ -1,5 +1,5 @@ /// A collection of functional programming structures. -library functional; +library; export 'src/functional/either.dart' show Either; export 'src/functional/optional.dart' show Optional; diff --git a/lib/graph.dart b/lib/graph.dart index ff2b46c..b9c2b03 100644 --- a/lib/graph.dart +++ b/lib/graph.dart @@ -1,5 +1,5 @@ /// Graph-theory objects and algorithms. -library graph; +library; export 'src/graph/algorithms.dart' show AlgorithmsGraphExtension; export 'src/graph/algorithms/a_star_search.dart' show AStarSearchIterable; diff --git a/lib/interval.dart b/lib/interval.dart index ce3bf9e..ad64d0b 100644 --- a/lib/interval.dart +++ b/lib/interval.dart @@ -1,5 +1,5 @@ /// Provides a continuous interval. -library interval; +library; export 'src/interval/interval.dart' show Interval; export 'src/interval/tree.dart' show IntervalTree; diff --git a/lib/math.dart b/lib/math.dart index e0be3e4..f056ddc 100644 --- a/lib/math.dart +++ b/lib/math.dart @@ -1,5 +1,5 @@ /// A collection of common mathematical functions. -library math; +library; export 'src/math/binomial.dart' show BinomialBigIntExtension, BinomialIntegerExtension; diff --git a/lib/more.dart b/lib/more.dart index 3d74ce8..f3ccccb 100644 --- a/lib/more.dart +++ b/lib/more.dart @@ -1,5 +1,5 @@ /// More Dart — Literally. -library more; +library; export 'package:more/async.dart'; export 'package:more/cache.dart'; diff --git a/lib/number.dart b/lib/number.dart index 002748b..382b477 100644 --- a/lib/number.dart +++ b/lib/number.dart @@ -1,5 +1,5 @@ /// Support for fractional and complex arithmetic. -library number; +library; export 'src/number/bigint.dart' show BigIntExtension; export 'src/number/complex.dart' show Complex; diff --git a/lib/printer.dart b/lib/printer.dart index 95cd526..2c4ccff 100644 --- a/lib/printer.dart +++ b/lib/printer.dart @@ -1,6 +1,6 @@ /// Provides a first-class model to convert object to strings using composition /// and highly configurable formatting primitives. -library printer; +library; export 'src/printer/builder.dart' show BuilderPrinterExtension; export 'src/printer/empty.dart' show EmptyPrinterExtension; diff --git a/lib/src/char_matcher/char_matcher.dart b/lib/src/char_matcher/char_matcher.dart index 3262143..6988e38 100644 --- a/lib/src/char_matcher/char_matcher.dart +++ b/lib/src/char_matcher/char_matcher.dart @@ -28,16 +28,19 @@ import 'unicode/unicode.dart'; /// inclusion of a character can be determined by calling the char matcher with /// the code-unit as the function argument, for example: /// -/// CharMatcher.whitespace().match(' '.runes.first); // true -/// CharMatcher.digit().match('a'.runes.first); // false +/// ```dart +/// CharMatcher.whitespace().match(' '.runes.first); // true +/// CharMatcher.digit().match('a'.runes.first); // false +/// ``` /// /// A large collection of helper methods let you perform string operations on /// the occurrences of the specified class of characters: trimming, collapsing, /// replacing, removing, retaining, etc. For example: /// -/// String withoutWhitespace = CharMatcher.whitespace().removeFrom(string); -/// String onlyDigits = CharMatcher.digit().retainFrom(string); -/// +/// ```dart +/// String withoutWhitespace = CharMatcher.whitespace().removeFrom(string); +/// String onlyDigits = CharMatcher.digit().retainFrom(string); +/// ``` @immutable abstract class CharMatcher with ToStringPrinter implements Pattern { /// A matcher that accepts any character. diff --git a/lib/src/char_matcher/unicode/category.dart b/lib/src/char_matcher/unicode/category.dart index 2d4059a..21e01c7 100644 --- a/lib/src/char_matcher/unicode/category.dart +++ b/lib/src/char_matcher/unicode/category.dart @@ -100,11 +100,11 @@ const data = [ 32, -4, 1, -2, 256, 64, -2, 256, -3, 1, -3, 256, 1, -3, 256, 64, -2, 1, 32, -6, 1, 256, -14, 1, -10, 512, -3, 2048, -6, 134217728, 33554432, 134217728, -5, 1, 64, -3, 256, 64, -8, 32, 1, -3, 32, 1, -23, 32, 1, -16, 32, -2, 1, 64, - 32, -3, 64, -4, 256, 1, -3, 64, 1, -4, 64, -7, 1, -2, 64, 1, -3, 32, 1, -2, + 32, -3, 64, -4, 256, 1, -3, 64, 1, -4, 64, -7, 1, -2, 64, 1, -3, 32, -2, 1, 32, -2, 1, -2, 32, -2, 64, -2, 1, -10, 512, -7, 1, 8388608, -7, 2048, 134217728, 32, 64, -2, 256, 8388608, -8, 32, 1, -3, 32, 1, -23, 32, 1, -10, 32, 1, -5, 32, -2, 1, 64, 32, 256, 64, -5, 256, 1, 64, -2, 256, 1, -2, 256, - -2, 64, -7, 1, -2, 256, -5, 1, -3, 32, 1, -2, 32, -2, 64, -2, 1, -10, 512, 1, + -2, 64, -7, 1, -2, 256, -6, 1, -2, 32, 1, -2, 32, -2, 64, -2, 1, -10, 512, 1, -2, 32, 256, -12, 1, -2, 64, -2, 256, -9, 32, 1, -3, 32, 1, -41, 32, -2, 64, 32, -3, 256, -4, 64, 1, -3, 256, 1, -3, 256, 64, 32, 134217728, -4, 1, -3, 32, 256, -7, 2048, -3, 32, -2, 64, -2, 1, -10, 512, -9, 2048, 134217728, -6, 32, diff --git a/lib/src/char_matcher/unicode/property.dart b/lib/src/char_matcher/unicode/property.dart index 98bb993..ca1514f 100644 --- a/lib/src/char_matcher/unicode/property.dart +++ b/lib/src/char_matcher/unicode/property.dart @@ -53,12 +53,12 @@ const data1 = [ 0, -7, 1024, -2, 0, -2, 4096, -4, 1024, -2, 4096, -2, 1024, 0, -3, 4096, 1024, -18, 0, -3, 2147483712, -8, 64, 0, 64, -4, 0, 1024, -30, 0, -16, 5120, -11, 4096, -91, 0, -11, 5120, -58, 0, -11, 4096, -2, 0, 64, 2147483712, 8192, -27, - 0, -2, 1024, -2, 4096, 0, -9, 1024, 0, -3, 1024, 0, -4, 1024, -3, 0, -7, 64, - 2147483712, 64, 2147483712, -3, 64, -2, 2147483712, -31, 0, 64, -56, 0, 1024, - -8, 4096, -41, 0, -10, 4096, 0, -12, 1024, -3, 0, -7, 5120, -6, 4096, -15, - 5120, -5, 1024, -54, 0, -2, 1024, 4096, 0, -15, 1024, 4096, -2, 1024, 0, -4, - 4096, -3, 1024, -10, 0, -2, 1024, -2, 2147483712, -11, 0, 4096, -15, 0, -3, - 1024, -56, 0, 4096, 0, 132096, -6, 1024, -2, 0, -2, 1024, -2, 0, -2, 1024, + 0, -2, 1024, -2, 4096, 0, -9, 1024, 0, -3, 1024, 0, -4, 1024, -3, 0, -6, 64, + 0, 2147483712, 64, 2147483712, -3, 64, -2, 2147483712, -31, 0, 64, -56, 0, + 1024, -8, 4096, -41, 0, -10, 4096, 0, -12, 1024, -3, 0, -7, 5120, -6, 4096, + -15, 5120, -5, 1024, -54, 0, -2, 1024, 4096, 0, -15, 1024, 4096, -2, 1024, 0, + -4, 4096, -3, 1024, -10, 0, -2, 1024, -2, 2147483712, -11, 0, 4096, -15, 0, + -3, 1024, -56, 0, 4096, 0, 132096, -6, 1024, -2, 0, -2, 1024, -2, 0, -2, 1024, 4096, -9, 0, 132096, -10, 0, -2, 1024, -29, 0, -3, 1024, -56, 0, 4096, 0, -5, 1024, -4, 0, -2, 1024, -2, 0, -2, 1024, 4096, -3, 0, 1024, -30, 0, 1024, 9216, -3, 0, 1024, -11, 0, -3, 1024, -56, 0, 4096, 0, -8, 1024, 0, -3, 1024, 0, -2, @@ -91,49 +91,50 @@ const data1 = [ -2, 2147483712, -111, 0, -3, 67108864, -2, 0, 67108864, -31, 0, 268435456, -60, 0, -5, 1024, -57, 0, -10, 1024, 0, 4096, -20, 1024, -8, 4096, -2, 0, 4096, -39, 0, 8192, -4, 2147483712, -4, 0, -15, 4096, -2, 1024, -11, 4096, -3, - 1024, -49, 0, -5, 1024, -47, 0, 4096, 132096, -14, 1024, 135168, -21, 0, -2, - 2147483712, 0, 64, -2, 2147483712, -11, 0, -9, 4096, -9, 0, -2, 2147483712, 0, - -3, 1024, -30, 0, -9, 1024, 135168, 4096, -2, 1024, -56, 0, 4096, -11, 1024, - -2, 135168, -48, 0, -18, 1024, 13312, 4096, -3, 0, -2, 2147483712, -3, 64, - -56, 0, -3, 4096, 12288, -2, 4096, -2, 2147483712, -80, 0, -25, 4096, -4, 0, - 4096, -6, 0, 4096, -2, 0, -3, 4096, -50, 0, -54, 20480, 33574912, -8, 20480, - -13, 0, 16384, -29, 0, 33554432, -4, 0, -9, 16384, 33570816, -3, 16384, - 33570816, -23, 16384, -4, 0, -12, 4096, -3, 0, -34, 1024, -11, 4096, -45, 0, - 33554432, -157, 0, 33554432, -241, 0, 4096, 0, -3, 4096, -11, 0, -3, 4096, - -13, 0, -3, 4096, -13, 0, -3, 4096, -13, 0, -2, 4096, 0, -11, 1, 0, 268566532, - 268435460, -2, 2, -2, 24, -4, 8, 128, 0, -8, 32, -8, 0, -2, 1, -5, 2, 1, -2, - 0, -3, 128, -4, 0, -2, 32, 0, -2, 2147483712, -2, 0, 128, -6, 0, -3, - 2147483712, -9, 0, 8, -11, 0, 1, 0, -4, 128, 8388608, -4, 2, -6, 16777216, - 536870912, 33570816, -2, 0, -7, 536870912, 536870920, 536870912, -2, - 536871040, 16384, -11, 536870912, 536870920, 536870912, -2, 536871040, 0, -13, - 16384, -51, 0, -13, 128, -4, 0, 128, -3, 0, -2, 128, -4, 0, -5, 128, -18, 0, - 128, -4, 0, 128, -2, 0, -10, 128, 0, 128, -2, 0, 134217728, -5, 128, -6, 0, - 128, -3, 0, -2, 128, -2, 0, -2, 128, 134217728, -3, 128, 0, -6, 128, -3, 0, - -4, 128, -5, 0, -3, 128, -2, 33554560, -22, 0, -16, 32768, -16, 16384, -21, 0, - -5, 128, -2, 0, -4, 128, 0, -2, 128, 0, -2, 128, 0, 128, 0, -5, 128, -2, 0, - -2, 128, -4, 0, -2, 128, -4, 0, -18, 128, -2, 0, -2, 128, 0, 128, 0, -7, 128, - 0, 128, -6, 0, -2, 128, -28, 0, 1610612736, -4, 0, 1610612736, -10, 0, 8, -11, - 0, 1610612736, -233, 0, -4, 128, -29, 0, -2, 16777216, -137, 0, -2, 128, 0, - 128, -24, 0, 128, -17, 0, 128, -211, 0, -26, 33792, -26, 17408, -182, 0, -2, - 128, -12, 0, -9, 128, -5, 0, -5, 128, -5, 0, -2, 128, -2, 0, -2, 128, -3, 0, - -5, 128, -14, 0, 128, 0, 128, -2, 0, -6, 128, -24, 0, -2, 128, -57, 0, 128, 0, - 128, -29, 0, -4, 128, -9, 0, -2, 128, -342, 0, -2, 128, -31, 0, -10, 128, - -403, 0, -22, 128, -63, 0, -4, 128, -32, 0, -2, 128, -638, 0, 33570816, 16384, - -113, 0, -3, 4096, -238, 0, -32, 1024, -23, 0, 24, -2, 0, 8, -19, 0, - 2147483712, 4096, -10, 0, -2, 8, 2147483712, -3, 0, 8, 64, 32, -9, 0, 64, 0, - -2, 64, -3, 0, -2, 2147483712, -8, 0, 8, -34, 0, -26, 2097152, 0, -89, - 2097152, -12, 0, -214, 2097152, -26, 0, -2, 262144, -2, 524288, -10, 262144, - -2, 1048576, 1, 64, 2147483712, -2, 0, 8192, -2, 2048, -4, 0, -4, 32, -12, 0, - 8, -3, 32, 0, -9, 2048, -4, 4096, -2, 135168, 8, -5, 8192, -2, 0, -3, 2048, - -94, 0, -2, 4096, -2, 134221824, -2, 8192, 0, 8, -90, 0, 268435472, 12288, -2, - 8192, -101, 0, 8388608, -138, 0, 262144, -528, 0, -6592, 4196352, -64, 0, - -20992, 4196352, -21, 0, 8192, -1256, 0, 64, 2147483712, -268, 0, 8192, 64, - -2, 2147483712, -95, 0, 4096, -4, 0, -8, 1024, -2, 4096, 0, 4096, -28, 0, -2, - 20480, -2, 1024, -80, 0, -2, 4096, 0, 2147483712, -3, 64, 2147483712, -8, 0, - -34, 4096, -78, 0, 16384, -23, 0, -3, 4096, -103, 0, -3, 16384, -3, 0, -2, - 20480, -8, 0, 1024, -3, 0, 4096, -4, 0, 1024, -23, 0, -5, 1024, -4, 0, 4096, - -73, 0, -2, 2147483712, -8, 0, -2, 1024, -50, 0, -16, 1024, 4096, 1024, -8, 0, - -2, 2147483712, -16, 0, -18, 4096, -13, 0, 1024, -38, 0, -5, 1024, -4, 4096, + 1024, -49, 0, -5, 1024, -47, 0, 4096, 132096, -14, 1024, 135168, -9, 0, -2, + 2147483712, -10, 0, -2, 2147483712, 0, 64, -2, 2147483712, -11, 0, -9, 4096, + -9, 0, -3, 2147483712, -3, 1024, -30, 0, -9, 1024, 135168, 4096, -2, 1024, + -56, 0, 4096, -11, 1024, -2, 135168, -48, 0, -18, 1024, 13312, 4096, -3, 0, + -2, 2147483712, -3, 64, -56, 0, -3, 4096, 12288, -2, 4096, -2, 2147483712, + -80, 0, -25, 4096, -4, 0, 4096, -6, 0, 4096, -2, 0, -3, 4096, -50, 0, -54, + 20480, 33574912, -8, 20480, -13, 0, 16384, -29, 0, 33554432, -4, 0, -9, 16384, + 33570816, -3, 16384, 33570816, -23, 16384, -4, 0, -12, 4096, -3, 0, -34, 1024, + -11, 4096, -45, 0, 33554432, -157, 0, 33554432, -241, 0, 4096, 0, -3, 4096, + -11, 0, -3, 4096, -13, 0, -3, 4096, -13, 0, -3, 4096, -13, 0, -2, 4096, 0, + -11, 1, 0, 268566532, 268435460, -2, 2, -2, 24, -4, 8, 128, 0, -8, 32, -4, 0, + 2147483712, -3, 0, -2, 1, -5, 2, 1, -2, 0, -3, 128, -4, 0, -2, 32, 0, -2, + 2147483712, -2, 0, 128, -6, 0, -3, 2147483712, -9, 0, 8, -11, 0, 1, 0, -4, + 128, 8388608, -4, 2, -6, 16777216, 536870912, 33570816, -2, 0, -7, 536870912, + 536870920, 536870912, -2, 536871040, 16384, -11, 536870912, 536870920, + 536870912, -2, 536871040, 0, -13, 16384, -51, 0, -13, 128, -4, 0, 128, -3, 0, + -2, 128, -4, 0, -5, 128, -18, 0, 128, -4, 0, 128, -2, 0, -10, 128, 0, 128, -2, + 0, 134217728, -5, 128, -6, 0, 128, -3, 0, -2, 128, -2, 0, -2, 128, 134217728, + -3, 128, 0, -6, 128, -3, 0, -4, 128, -5, 0, -3, 128, -2, 33554560, -22, 0, + -16, 32768, -16, 16384, -21, 0, -5, 128, -2, 0, -4, 128, 0, -2, 128, 0, -2, + 128, 0, 128, 0, -5, 128, -2, 0, -2, 128, -4, 0, -2, 128, -4, 0, -18, 128, -2, + 0, -2, 128, 0, 128, 0, -7, 128, 0, 128, -6, 0, -2, 128, -28, 0, 1610612736, + -4, 0, 1610612736, -10, 0, 8, -11, 0, 1610612736, -233, 0, -4, 128, -29, 0, + -2, 16777216, -137, 0, -2, 128, 0, 128, -24, 0, 128, -17, 0, 128, -211, 0, + -26, 33792, -26, 17408, -182, 0, -2, 128, -12, 0, -9, 128, -5, 0, -5, 128, -5, + 0, -2, 128, -2, 0, -2, 128, -3, 0, -5, 128, -14, 0, 128, 0, 128, -2, 0, -6, + 128, -24, 0, -2, 128, -57, 0, 128, 0, 128, -29, 0, -4, 128, -9, 0, -2, 128, + -342, 0, -2, 128, -31, 0, -10, 128, -403, 0, -22, 128, -63, 0, -4, 128, -32, + 0, -2, 128, -638, 0, 33570816, 16384, -113, 0, -3, 4096, -7, 0, -3, + 2147483712, -228, 0, -32, 1024, -23, 0, 24, -2, 0, 8, -19, 0, 2147483712, + 4096, -10, 0, -2, 8, 2147483712, -3, 0, 8, 64, 32, -9, 0, 64, 0, -2, 64, -3, + 0, -2, 2147483712, -8, 0, 8, -34, 0, -26, 2097152, 0, -89, 2097152, -12, 0, + -214, 2097152, -26, 0, -2, 262144, -2, 524288, -10, 262144, -2, 1048576, 1, + 64, 2147483712, -2, 0, 8192, -2, 2048, -4, 0, -4, 32, -12, 0, 8, -3, 32, 0, + -9, 2048, -4, 4096, -2, 135168, 8, -5, 8192, -2, 0, -3, 2048, -94, 0, -2, + 4096, -2, 134221824, -2, 8192, 0, 8, -90, 0, 268435472, 12288, -2, 8192, -101, + 0, 8388608, -138, 0, 262144, -528, 0, -6592, 4196352, -64, 0, -20992, 4196352, + -21, 0, 8192, -1256, 0, 64, 2147483712, -268, 0, 8192, 64, -2, 2147483712, + -95, 0, 4096, -4, 0, -8, 1024, -2, 4096, 0, 4096, -28, 0, -2, 20480, -2, 1024, + -80, 0, -2, 4096, 0, 2147483712, -3, 64, 2147483712, -8, 0, -34, 4096, -78, 0, + 16384, -23, 0, -3, 4096, -103, 0, -3, 16384, -3, 0, -2, 20480, -8, 0, 1024, + -3, 0, 4096, -4, 0, 1024, -23, 0, -5, 1024, -4, 0, 4096, -73, 0, -2, + 2147483712, -8, 0, -2, 1024, -50, 0, -16, 1024, 4096, 1024, -8, 0, -2, + 2147483712, -16, 0, -18, 4096, -13, 0, 1024, -38, 0, -5, 1024, -4, 4096, 2147483712, -23, 0, -12, 1024, 135168, -44, 0, -4, 1024, -47, 0, 4096, -12, 1024, 135168, -6, 0, 64, -2, 2147483712, -5, 0, 8192, -21, 0, 5120, 8192, -66, 0, -14, 1024, -12, 0, 1024, -8, 0, -2, 1024, -15, 0, -3, 2147483712, -16, 0, @@ -143,31 +144,32 @@ const data1 = [ 0, 20480, -2, 4096, -119, 0, -8, 1024, 2147483712, -2, 4096, -19730, 0, -270, 2048, -2, 4196352, 2048, 4196352, 2048, -2, 4196352, -10, 2048, 4196352, 2048, 4196352, 2048, -2, 4196352, -2, 2048, -3, 4196352, -68, 2048, -2, 0, -106, - 2048, -68, 0, 5120, -689, 0, -32, 65536, -48, 0, -16, 4096, 0, -2, 8, -14, 0, - -4, 32, -11, 0, -2, 64, 2147483712, 0, -2, 64, -2, 2147483712, 8, -8, 0, 128, - 0, 152, -4, 0, 128, -152, 0, 2147483712, 32, -4, 0, 32, -4, 0, 64, 24, - 2147483712, 0, -10, 256, -2, 64, -3, 0, 2147483712, 0, -6, 256, -21, 0, 128, - 0, 4224, 0, 4096, -6, 256, -26, 0, 2147483712, -2, 32, 64, 268435472, -10, 0, - 12288, -45, 0, -2, 135168, 8388608, -66, 0, 4096, -12, 0, -9, 8388608, -5, 0, - -2, 65536, -736, 0, 4096, -149, 0, -5, 1024, -36, 0, 64, -48, 0, 64, -943, 0, - 20480, -2, 12288, -3, 20480, 0, -42, 20480, 0, -9, 20480, -156, 0, 64, -199, - 0, 64, -225, 0, -3, 1024, 0, -2, 1024, -5, 0, -4, 1024, -40, 0, -3, 4096, -4, - 0, 4096, -22, 0, -2, 2147483712, -141, 0, -2, 4096, -9, 0, -6, 64, -68, 0, -6, - 64, -89, 0, -4, 64, -389, 0, -2, 4096, -4, 5120, -38, 0, 12288, -26, 0, 5120, - 12288, -3, 4096, 8, 8192, -315, 0, -2, 1024, 8, -78, 0, 1024, -3, 4096, -70, - 0, -11, 4096, -4, 0, -5, 2147483712, -40, 0, -4, 4096, -4, 2147483712, -118, - 0, -3, 1024, -53, 0, -14, 1024, 4096, -2, 2147483712, -5, 64, -34, 0, 4096, - -2, 0, -2, 1024, -11, 0, -3, 1024, -45, 0, -9, 1024, -2, 4096, -3, 0, -4, - 2147483712, 1024, -61, 0, -3, 1024, -36, 0, -12, 1024, -2, 4096, -12, 0, -3, - 2147483712, 0, -2, 1024, -44, 0, 4096, -12, 0, -3, 1024, -48, 0, -13, 1024, - 135168, -4, 0, -2, 2147483712, -3, 0, -3, 4096, 2147483712, -2, 1024, -14, 0, - -2, 2147483712, -76, 0, -9, 1024, 135168, 4096, 9216, -2, 2147483712, 64, -2, - 2147483712, 0, 1024, -2, 0, 1024, -103, 0, 2147483712, -53, 0, -10, 1024, -2, - 4096, -21, 0, -4, 1024, -55, 0, -2, 4096, 0, 132096, -6, 1024, -2, 0, -2, - 1024, -2, 0, -2, 1024, 135168, -9, 0, 132096, -5, 0, 8192, -4, 0, -2, 1024, - -2, 0, -7, 4096, -3, 0, -5, 4096, -67, 0, 132096, -8, 1024, 0, 132096, -2, 0, - 132096, 0, -3, 132096, 1024, 0, -2, 1024, 4096, 135168, 4096, 0, -2, 12288, - -13, 0, -2, 4096, -82, 0, -13, 1024, 4096, -3, 1024, 4096, -4, 0, -2, + 2048, -68, 0, 5120, -689, 0, -32, 65536, -34, 0, 2147483712, -2, 0, -2, + 2147483712, -9, 0, -16, 4096, 0, -2, 8, -14, 0, -4, 32, -11, 0, -2, 64, + 2147483712, 0, -2, 64, -2, 2147483712, 8, -8, 0, 128, 0, 152, -4, 0, 128, + -152, 0, 2147483712, 32, -4, 0, 32, -4, 0, 64, 24, 2147483712, 0, -10, 256, + -2, 64, -3, 0, 2147483712, 0, -6, 256, -21, 0, 128, 0, 4224, 0, 4096, -6, 256, + -26, 0, 2147483712, -2, 32, 64, 268435472, -10, 0, 12288, -45, 0, -2, 135168, + 8388608, -66, 0, 4096, -12, 0, -9, 8388608, -5, 0, -2, 65536, -736, 0, 4096, + -149, 0, -5, 1024, -36, 0, 64, -48, 0, 64, -943, 0, 20480, -2, 12288, -3, + 20480, 0, -42, 20480, 0, -9, 20480, -156, 0, 64, -199, 0, 64, -225, 0, -3, + 1024, 0, -2, 1024, -5, 0, -4, 1024, -40, 0, -3, 4096, -4, 0, 4096, -22, 0, -2, + 2147483712, -141, 0, -2, 4096, -9, 0, -6, 64, -68, 0, -6, 64, -89, 0, -4, 64, + -389, 0, -2, 4096, -4, 5120, -38, 0, 12288, -26, 0, 5120, 12288, -3, 4096, 8, + 8192, -315, 0, -2, 1024, 8, -78, 0, 1024, -3, 4096, -70, 0, -11, 4096, -4, 0, + -5, 2147483712, -40, 0, -4, 4096, -4, 2147483712, -118, 0, -3, 1024, -53, 0, + -14, 1024, 4096, -2, 2147483712, -5, 64, -34, 0, 4096, -2, 0, -2, 1024, -11, + 0, -3, 1024, -45, 0, -9, 1024, -2, 4096, -3, 0, -4, 2147483712, 1024, -61, 0, + -3, 1024, -36, 0, -12, 1024, -2, 4096, -12, 0, -3, 2147483712, 0, -2, 1024, + -44, 0, 4096, -12, 0, -3, 1024, -48, 0, -13, 1024, 135168, -4, 0, -2, + 2147483712, -3, 0, -3, 4096, 2147483712, -2, 1024, -14, 0, -2, 2147483712, + -76, 0, -9, 1024, 135168, 4096, 9216, -2, 2147483712, 64, -2, 2147483712, 0, + 1024, -2, 0, 1024, -103, 0, 2147483712, -53, 0, -10, 1024, -2, 4096, -21, 0, + -4, 1024, -55, 0, -2, 4096, 0, 132096, -6, 1024, -2, 0, -2, 1024, -2, 0, -2, + 1024, 135168, -9, 0, 132096, -5, 0, 8192, -4, 0, -2, 1024, -2, 0, -7, 4096, + -3, 0, -5, 4096, -67, 0, 132096, -8, 1024, 0, 132096, -2, 0, 132096, 0, -3, + 132096, 1024, 0, -2, 1024, 4096, 135168, 4096, 0, -2, 12288, -2, 2147483712, + -11, 0, -2, 4096, -82, 0, -13, 1024, 4096, -3, 1024, 4096, -4, 0, -2, 2147483712, 64, -12, 0, -2, 64, -84, 0, 132096, -12, 1024, 132096, -4, 1024, -2, 4096, -235, 0, 132096, -6, 1024, -2, 0, -7, 1024, -2, 4096, 0, -2, 2147483712, -2, 64, -3, 8192, -15, 2147483712, -4, 0, -2, 1024, -82, 0, -15, @@ -185,41 +187,41 @@ const data1 = [ 135168, 4096, -2, 2147483712, -21, 0, 4096, -1301, 0, -5, 64, -4050, 0, -15, 4096, -11464, 0, -17, 1024, 4096, -2366, 0, -2, 2147483712, -128, 0, -5, 4096, 2147483712, -58, 0, -7, 4096, -2, 2147483712, 64, -8, 0, -2, 8192, 2147483712, - -550, 0, -2, 4096, -298, 0, 64, 2147483712, -182, 0, 1024, 0, -55, 1024, -7, - 0, -4, 5120, -13, 4096, -64, 0, -2, 8192, 0, 8192, 2048, -11, 0, -2, 136192, - -14, 0, -6136, 2048, -8, 0, -1238, 2048, -42, 0, -9, 2048, -8935, 0, -4, 4096, - 0, -7, 4096, 0, -2, 4096, -369, 0, -396, 2048, -2466, 0, 1024, 2147483712, - -4704, 0, -46, 4096, -2, 0, -23, 4096, -542, 0, -2, 131072, -3, 4096, -3, 0, - -6, 135168, -8, 0, -8, 4096, -2, 0, -7, 4096, -30, 0, -4, 4096, -594, 0, -34, - 128, -2, 33554560, -49, 128, 0, -2, 33554560, -50, 128, -2, 33554560, -17, - 128, 0, -2, 128, -2, 0, 128, -2, 0, -2, 128, -2, 0, -4, 128, 0, -12, 128, 0, - 128, 0, 128, -2, 33554560, -4, 128, 0, -45, 128, -2, 33554560, -18, 128, 0, - -4, 128, -2, 0, -8, 128, 0, -7, 128, 0, -8, 128, -2, 33554560, -18, 128, 0, - -4, 128, 0, -5, 128, 0, 128, -3, 0, -7, 128, 0, -8, 128, -2, 33554560, -50, + -550, 0, -2, 4096, 0, -2, 2147483712, -295, 0, 64, 2147483712, -182, 0, 1024, + 0, -55, 1024, -7, 0, -4, 5120, -13, 4096, -64, 0, -2, 8192, 0, 8192, 2048, + -11, 0, -2, 136192, -14, 0, -6136, 2048, -8, 0, -1238, 2048, -41, 0, -10, + 2048, -8935, 0, -4, 4096, 0, -7, 4096, 0, -2, 4096, -369, 0, -396, 2048, + -2466, 0, 1024, 2147483712, -4704, 0, -46, 4096, -2, 0, -23, 4096, -542, 0, + -2, 131072, -3, 4096, -3, 0, -6, 135168, -8, 0, -8, 4096, -2, 0, -7, 4096, + -30, 0, -4, 4096, -594, 0, -34, 128, -2, 33554560, -49, 128, 0, -2, 33554560, + -50, 128, -2, 33554560, -17, 128, 0, -2, 128, -2, 0, 128, -2, 0, -2, 128, -2, + 0, -4, 128, 0, -12, 128, 0, 128, 0, 128, -2, 33554560, -4, 128, 0, -45, 128, + -2, 33554560, -18, 128, 0, -4, 128, -2, 0, -8, 128, 0, -7, 128, 0, -8, 128, + -2, 33554560, -18, 128, 0, -4, 128, 0, -5, 128, 0, 128, -3, 0, -7, 128, 0, -8, 128, -2, 33554560, -50, 128, -2, 33554560, -50, 128, -2, 33554560, -50, 128, - -2, 33554560, -50, 128, -2, 33554560, -50, 128, -2, 33554560, -18, 128, -2, 0, - -25, 128, 1610612736, -25, 128, 1610612736, -31, 128, 1610612736, -25, 128, + -2, 33554560, -50, 128, -2, 33554560, -50, 128, -2, 33554560, -50, 128, -2, + 33554560, -18, 128, -2, 0, -25, 128, 1610612736, -25, 128, 1610612736, -31, + 128, 1610612736, -25, 128, 1610612736, -31, 128, 1610612736, -25, 128, 1610612736, -31, 128, 1610612736, -25, 128, 1610612736, -31, 128, 1610612736, - -25, 128, 1610612736, -31, 128, 1610612736, -25, 128, 1610612736, -8, 128, -2, - 0, -50, 128, -647, 0, 64, 2147483712, -2, 64, -1167, 0, 33554432, -229, 0, -7, - 1024, 0, -17, 1024, -2, 0, -7, 1024, 0, -2, 1024, 0, -5, 1024, -5, 0, -28, - 20480, -2, 33574912, -26, 20480, 33574912, -5, 20480, -33, 0, 1024, -160, 0, - -7, 4096, -5, 0, -2, 8192, -368, 0, 4096, -61, 0, -4, 4096, -766, 0, 4096, - 12288, -736, 0, -7, 4096, -109, 0, -3, 12288, 1024, -3, 4096, -1205, 0, -4, - 128, 0, -27, 128, 0, -2, 128, 0, 128, -2, 0, 128, 0, -10, 128, 0, -4, 128, 0, - 128, 0, 128, -6, 0, 128, -4, 0, 128, 0, 128, 0, 128, 0, -3, 128, 0, -2, 128, - 0, 128, -2, 0, 128, 0, 128, 0, 128, 0, 128, 0, 128, 0, -2, 128, 0, 128, -2, 0, - -4, 128, 0, -7, 128, 0, -4, 128, 0, -4, 128, 0, 128, 0, -10, 128, 0, -17, 128, - -5, 0, -3, 128, 0, -5, 128, 0, -17, 128, -628, 0, -26, 33792, -6, 0, -26, - 33792, -6, 0, -26, 33792, -3700, 0, -2, 65536, -42720, 4196352, -32, 0, -4154, - 4196352, -6, 0, -222, 4196352, -2, 0, -5762, 4196352, -14, 0, -7473, 4196352, - -15, 0, -622, 4196352, -2466, 0, -542, 2048, -1504, 0, -2, 65536, -4939, - 4196352, -5, 0, -4192, 4196352, -56398, 0, -2, 65536, -65534, 0, -2, 65536, + -25, 128, 1610612736, -8, 128, -2, 0, -50, 128, -647, 0, 64, 2147483712, -2, + 64, -1167, 0, 33554432, -229, 0, -7, 1024, 0, -17, 1024, -2, 0, -7, 1024, 0, + -2, 1024, 0, -5, 1024, -5, 0, -28, 20480, -2, 33574912, -26, 20480, 33574912, + -5, 20480, -33, 0, 1024, -160, 0, -7, 4096, -5, 0, -2, 8192, -368, 0, 4096, + -61, 0, -4, 4096, -766, 0, 4096, 12288, -736, 0, -7, 4096, -109, 0, -3, 12288, + 1024, -3, 4096, -1205, 0, -4, 128, 0, -27, 128, 0, -2, 128, 0, 128, -2, 0, + 128, 0, -10, 128, 0, -4, 128, 0, 128, 0, 128, -6, 0, 128, -4, 0, 128, 0, 128, + 0, 128, 0, -3, 128, 0, -2, 128, 0, 128, -2, 0, 128, 0, 128, 0, 128, 0, 128, 0, + 128, 0, -2, 128, 0, 128, -2, 0, -4, 128, 0, -7, 128, 0, -4, 128, 0, -4, 128, + 0, 128, 0, -10, 128, 0, -17, 128, -5, 0, -3, 128, 0, -5, 128, 0, -17, 128, + -628, 0, -26, 33792, -6, 0, -26, 33792, -6, 0, -26, 33792, -3700, 0, -2, + 65536, -42720, 4196352, -32, 0, -4154, 4196352, -6, 0, -222, 4196352, -2, 0, + -5762, 4196352, -14, 0, -7473, 4196352, -15, 0, -622, 4196352, -2466, 0, -542, + 2048, -1504, 0, -2, 65536, -4939, 4196352, -5, 0, -4192, 4196352, -56398, 0, + -2, 65536, -65534, 0, -2, 65536, -65534, 0, -2, 65536, -65534, 0, -2, 65536, -65534, 0, -2, 65536, -65534, 0, -2, 65536, -65534, 0, -2, 65536, -65534, 0, -2, 65536, -65534, 0, -2, 65536, -65534, 0, -2, 65536, -65534, 0, -2, 65536, - -65534, 0, -2, 65536, -65534, 0, -2, 65536, 8388608, 16777216, -30, 8388608, - -96, 131072, -128, 8388608, -240, 0, -3600, 8388608, -61438, 0, -2, 65536, - -65534, 0, -2, 65536, -65534, 0, -2, 65536 // + 8388608, 16777216, -30, 8388608, -96, 131072, -128, 8388608, -240, 0, -3600, + 8388608, -61438, 0, -2, 65536, -65534, 0, -2, 65536, -65534, 0, -2, 65536 // ]; const variationSelector = 0x1; @@ -227,14 +229,16 @@ const patternWhiteSpace = 0x2; const patternSyntax = 0x4; const prependedConcatenationMark = 0x8; const regionalIndicator = 0x10; +const modifierCombiningMark = 0x20; const data2 = [ -9, 0, -5, 2, -18, 0, 2, -15, 4, -10, 0, -7, 4, -26, 0, -4, 4, 0, 4, -26, 0, -4, 4, -6, 0, 2, -27, 0, -7, 4, 0, 4, 0, -2, 4, 0, 4, 0, -2, 4, -4, 0, 4, -4, - 0, 4, -3, 0, 4, -23, 0, 4, -31, 0, 4, -1288, 0, -6, 8, -215, 0, 8, -49, 0, 8, - -384, 0, -2, 8, -80, 0, 8, -3880, 0, -3, 1, 0, 1, -2046, 0, -2, 2, -24, 4, -2, - 2, -6, 0, -15, 4, -2, 0, -19, 4, 0, -10, 4, -305, 0, -720, 4, -160, 0, -630, - 4, -30, 0, -1132, 4, -512, 0, -128, 4, -385, 0, -3, 4, -4, 0, -25, 4, -15, 0, - 4, -52493, 0, -2, 4, -192, 0, -16, 1, -53, 0, -2, 4, -4726, 0, 8, -15, 0, 8, - -57624, 0, -26, 16, -790272, 0, -240, 1, -196112, 0 // + 0, 4, -3, 0, 4, -23, 0, 4, -31, 0, 4, -1288, 0, -6, 8, -78, 0, -2, 32, -2, 0, + 32, -131, 0, 32, 8, -5, 0, 32, -3, 0, -2, 32, -38, 0, 8, -384, 0, -2, 8, -56, + 0, -2, 32, 0, -3, 32, -3, 0, 32, -14, 0, 8, -16, 0, 32, -3863, 0, -3, 1, 0, 1, + -2046, 0, -2, 2, -24, 4, -2, 2, -6, 0, -15, 4, -2, 0, -19, 4, 0, -10, 4, -305, + 0, -720, 4, -160, 0, -630, 4, -30, 0, -1132, 4, -512, 0, -128, 4, -385, 0, -3, + 4, -4, 0, -25, 4, -15, 0, 4, -52493, 0, -2, 4, -192, 0, -16, 1, -53, 0, -2, 4, + -4726, 0, 8, -15, 0, 8, -57624, 0, -26, 16, -790272, 0, -240, 1, -196112, 0 // ]; diff --git a/lib/src/collection/iterable/chunked.dart b/lib/src/collection/iterable/chunked.dart index afdbf41..8312e39 100644 --- a/lib/src/collection/iterable/chunked.dart +++ b/lib/src/collection/iterable/chunked.dart @@ -2,10 +2,12 @@ extension ChunkedIterableExtension on Iterable { /// Divides this [Iterable] into sub-lists of a given `size`. The final list /// might be smaller or equal to the desired size. /// - /// The following expression yields `[1, 2]`, `[3, 4]`, and `[5]`: - /// - /// [1, 2, 3, 4, 5].chunked(2); + /// For example: /// + /// ```dart + /// final input = [1, 2, 3, 4, 5]; + /// print(input.chunked(2)); // [[1, 2], [3, 4], [5]] + /// ``` Iterable> chunked(int size) sync* { final iterator = this.iterator; while (iterator.moveNext()) { @@ -20,10 +22,12 @@ extension ChunkedIterableExtension on Iterable { /// Divides this [Iterable] into sub-lists of a given `size`. The final list /// is expanded with the provided `padding`, or `null`. /// - /// The following expression yields `[1, 2]`, `[3, 4]`, and `[5, -1]`: - /// - /// [1, 2, 3, 4, 5].chunkedWithPadding(2, -1); + /// For example: /// + /// ```dart + /// final input = [1, 2, 3, 4, 5]; + /// print(input.chunkedWithPadding(2, -1)); // [[1, 2], [3, 4], [5, -1]] + /// ``` Iterable> chunkedWithPadding(int size, E padding) sync* { final iterator = this.iterator; while (iterator.moveNext()) { diff --git a/lib/src/collection/iterable/combinations.dart b/lib/src/collection/iterable/combinations.dart index 255423c..3cc7a8a 100644 --- a/lib/src/collection/iterable/combinations.dart +++ b/lib/src/collection/iterable/combinations.dart @@ -6,21 +6,28 @@ extension CombinationsIterableExtension on Iterable { /// If [repetitions] is set to `true` the iterable allows individual elements /// to be repeated more than once. The number of items returned is: /// - /// (elements.length + count - 1)! / count! / (elements.length - 1)! + /// ```dart + /// (elements.length + count - 1)! / count! / (elements.length - 1)! + /// ``` /// /// The following expression iterates over xx, xy, xz, yy, yz, and zz: /// - /// ['x', 'y', 'z'].combinations(2, repetitions: true); + /// ```dart + /// ['x', 'y', 'z'].combinations(2, repetitions: true); + /// ``` /// /// If [repetitions] is set to `false` the iterable generates all the /// sub-sequences of length [count]. The number of items returned is: /// - /// elements.length! / count! / (elements.length - count)! + /// ```dart + /// elements.length! / count! / (elements.length - count)! + /// ``` /// /// The following expression iterates over xy, xz, yz: /// - /// ['x', 'y', 'z'].combinations(2, repetitions: false); - /// + /// ```dart + /// ['x', 'y', 'z'].combinations(2, repetitions: false); + /// ``` Iterable> combinations(int count, {bool repetitions = false}) { RangeError.checkNotNegative(count, 'count'); final list = toList(growable: false); diff --git a/lib/src/collection/iterable/count.dart b/lib/src/collection/iterable/count.dart index 850938c..0bd5c20 100644 --- a/lib/src/collection/iterable/count.dart +++ b/lib/src/collection/iterable/count.dart @@ -3,7 +3,8 @@ extension CountIterableExtension on Iterable { /// /// The following expression yields 2, because there are 2 odd numbers: /// - /// [1, 2, 3].count((element) => element.isOdd); - /// + /// ```dart + /// [1, 2, 3].count((element) => element.isOdd); + /// ``` int count(bool Function(E element) predicate) => where(predicate).length; } diff --git a/lib/src/collection/iterable/flatten.dart b/lib/src/collection/iterable/flatten.dart index 02b8d28..ea3aa46 100644 --- a/lib/src/collection/iterable/flatten.dart +++ b/lib/src/collection/iterable/flatten.dart @@ -3,9 +3,10 @@ extension FlattenIterableExtension on Iterable> { /// /// For example: /// - /// final input = [[1, 2], [3, 4]]; - /// print(input.flatten()); // [1, 2, 3, 4] - /// + /// ```dart + /// final input = [[1, 2], [3, 4]]; + /// print(input.flatten()); // [1, 2, 3, 4] + /// ``` Iterable flatten() => expand((values) => values); } @@ -15,9 +16,10 @@ extension DeepFlattenIterableExtension on Iterable { /// /// For example: /// - /// final input = [1, 2, [3, 4, [5, 6]]]; - /// print(input.deepFlatten()); // [1, 2, 3, 4, 5, 6] - /// + /// ```dart + /// final input = [1, 2, [3, 4, [5, 6]]]; + /// print(input.deepFlatten()); // [1, 2, 3, 4, 5, 6] + /// ``` Iterable deepFlatten() sync* { for (final value in this) { if (value is E) { diff --git a/lib/src/collection/iterable/group.dart b/lib/src/collection/iterable/group.dart index 6d62bd6..f878f55 100644 --- a/lib/src/collection/iterable/group.dart +++ b/lib/src/collection/iterable/group.dart @@ -5,16 +5,12 @@ extension GroupIterableExtension on Iterable { /// specified, the value itself is used as the key. Generally, the iterable /// should be sorted on the same key function. /// - /// For example, the expression - /// - /// ['a', 'a', 'a', 'b', 'b', 'c'].groupBy() - /// .map((group) => '${group.key}: ${group.values}' - /// .join(', ') - /// - /// returns - /// - /// 'a: aaa, b: bb, c: c' + /// For example: /// + /// ```dart + /// final input = ['a', 'a', 'a', 'b', 'b', 'c']; + /// print(input.groupBy()); // [a: [a, a, a], b: [b, b], c: [c]] + /// ``` Iterable> groupBy([K Function(V element)? key]) sync* { final iterator = this.iterator; if (iterator.moveNext()) { diff --git a/lib/src/collection/iterable/indexed.dart b/lib/src/collection/iterable/indexed.dart index 622fc88..ac45275 100644 --- a/lib/src/collection/iterable/indexed.dart +++ b/lib/src/collection/iterable/indexed.dart @@ -4,16 +4,13 @@ extension IndexedIterableExtension on Iterable { /// By default the index is zero based, but an arbitrary [offset] can be /// provided. /// - /// For example, the expression - /// - /// ['a', 'b'].indexed(start: 1) - /// .map((each) => '${each.index}: ${each.value}') - /// .join(', '); - /// - /// returns - /// - /// '1: a, 2: b' + /// For example, the following expression returns `'1: a, 2: b'`: /// + /// ```dart + /// ['a', 'b'].indexed(start: 1) + /// .map((each) => '${each.index}: ${each.value}') + /// .join(', '); + /// ``` Iterable> indexed({ int start = 0, int step = 1, diff --git a/lib/src/collection/iterable/iterate.dart b/lib/src/collection/iterable/iterate.dart index 13ea519..af98a8c 100644 --- a/lib/src/collection/iterable/iterate.dart +++ b/lib/src/collection/iterable/iterate.dart @@ -5,14 +5,12 @@ import 'mixins/infinite.dart'; /// Returns a lazy infinite list of repeated applications of [callback] to the /// initial [value]. /// -/// For example, the expression -/// -/// iterate(0, (n) => n + 1); -/// -/// results in the infinite iterable of all natural numbers: -/// -/// [0, 1, 2, 3, 4, ...] +/// For example, the following expression results in an infinite iterable of all +/// natural numbers `[0, 1, 2, 3, 4, ...]`: /// +/// ```dart +/// iterate(0, (n) => n + 1); +/// ``` Iterable iterate(E value, E Function(E element) callback) => IterateIterable(value, callback); diff --git a/lib/src/collection/iterable/operators.dart b/lib/src/collection/iterable/operators.dart index 30ad08f..60b6f1d 100644 --- a/lib/src/collection/iterable/operators.dart +++ b/lib/src/collection/iterable/operators.dart @@ -7,12 +7,11 @@ extension OperatorsIterableExtension on Iterable { /// Throws a [StateError] if the iterable is empty, unless an [orElse] /// function is provided. /// - /// For example - /// - /// [3, 1, 2].min() - /// - /// returns `1`. + /// For example: /// + /// ```dart + /// print([3, 1, 2].min()); // 1 + /// ``` E min({Comparator? comparator, E Function()? orElse}) => (comparator ?? naturalCompare).minOf(this, orElse: orElse); @@ -22,12 +21,11 @@ extension OperatorsIterableExtension on Iterable { /// Throws a [StateError] if the iterable is empty, unless an [orElse] /// function is provided. /// - /// For example - /// - /// [3, 1, 2].max() - /// - /// returns `3`. + /// For example: /// + /// ```dart + /// print([3, 1, 2].max()); // 3 + /// ``` E max({Comparator? comparator, E Function()? orElse}) => (comparator ?? naturalCompare).maxOf(this, orElse: orElse); @@ -37,12 +35,11 @@ extension OperatorsIterableExtension on Iterable { /// Throws a [StateError] if the iterable is empty, unless an [orElse] /// function is provided. /// - /// For example - /// - /// [3, 1, 2].minMax() - /// - /// returns `(min: 1, max: 3)`. + /// For example: /// + /// ```dart + /// print([3, 1, 2].minMax()); // (min: 1, max: 3) + /// ``` ({E min, E max}) minMax( {Comparator? comparator, ({E min, E max}) Function()? orElse}) => (comparator ?? naturalCompare).minMaxOf(this, orElse: orElse); @@ -51,12 +48,11 @@ extension OperatorsIterableExtension on Iterable { /// elements need to be [Comparable], unless a custom [comparator] is /// provided. /// - /// For example - /// - /// [3, 1, 2].smallest(2) - /// - /// returns `[1, 2]`. + /// For example: /// + /// ```dart + /// print([3, 1, 2].smallest(2)); // [1, 2] + /// ``` List smallest(int count, {Comparator? comparator}) => (comparator ?? naturalCompare).smallest(this, count); @@ -64,12 +60,11 @@ extension OperatorsIterableExtension on Iterable { /// elements need to be [Comparable], unless a custom [comparator] is /// provided. /// - /// For example - /// - /// [3, 1, 2].largest(2) - /// - /// returns `[3, 2]`. + /// For example: /// + /// ```dart + /// print([3, 1, 2].largest(2)); // [3, 2] + /// ``` List largest(int count, {Comparator? comparator}) => (comparator ?? naturalCompare).largest(this, count); } diff --git a/lib/src/collection/iterable/pairwise.dart b/lib/src/collection/iterable/pairwise.dart index 023c4a6..18e16c3 100644 --- a/lib/src/collection/iterable/pairwise.dart +++ b/lib/src/collection/iterable/pairwise.dart @@ -1,14 +1,12 @@ extension PairwiseIterableExtension on Iterable { /// An iterable over the successive overlapping pairs of this iterable. /// - /// For example, the expression - /// - /// [1, 2, 3, 4].pairwise() - /// - /// results in the following output: - /// - /// [(1, 2), (2, 3), (3, 4)] + /// For example: /// + /// ```dart + /// final input = [1, 2, 3, 4]; + /// print(input.pairwise()); // [(1, 2), (2, 3), (3, 4)] + /// ``` Iterable<(E, E)> pairwise() sync* { final iterator = this.iterator; if (!iterator.moveNext()) return; diff --git a/lib/src/collection/iterable/partition.dart b/lib/src/collection/iterable/partition.dart index 67a7b5d..e756d6d 100644 --- a/lib/src/collection/iterable/partition.dart +++ b/lib/src/collection/iterable/partition.dart @@ -2,14 +2,13 @@ extension PartitionIterableExtension on Iterable { /// Splits this iterable into two lists: the `truthy` list where the [test] predicate /// is `true` and the `falsey` list where the [test] predicate is `false`. /// - /// For example, the expression - /// - /// [1, 2, 3, 4].partition((each) => each.isEven); - /// - /// results in the following output: - /// - /// (truthy: [2, 4], falsey: [1, 3]) + /// For example: /// + /// ```dart + /// final input = [1, 2, 3, 4]; + /// final output = partition((each) => each.isEven); + /// print(output); // (truthy: [2, 4], falsey: [1, 3]) + /// ``` ({List truthy, List falsey}) partition(bool Function(E element) test) { final truthy = [], falsey = []; for (final element in this) { diff --git a/lib/src/collection/iterable/permutations.dart b/lib/src/collection/iterable/permutations.dart index aa13fd7..05388f8 100644 --- a/lib/src/collection/iterable/permutations.dart +++ b/lib/src/collection/iterable/permutations.dart @@ -11,13 +11,16 @@ extension PermutationIterableExtension on Iterable { /// The following expression iterates over `xyz`, `xzy`, `yxz`, `yzx`, `zxy`, /// and `zyx:` /// - /// ['x', 'y', 'z'].permutations(); + /// ```dart + /// ['x', 'y', 'z'].permutations(); + /// ``` /// /// The following expression iterates over the permutations of length 2, these /// are: `xy`, `xz`, `yx`, `yz`, `zx`, and `zy`: /// - /// ['x', 'y', 'z'].permutations(2); - /// + /// ```dart + /// ['x', 'y', 'z'].permutations(2); + /// ``` Iterable> permutations([int? count]) { final elements = toList(growable: false); count ??= elements.length; diff --git a/lib/src/collection/iterable/power_set.dart b/lib/src/collection/iterable/power_set.dart index 4574449..8354bf5 100644 --- a/lib/src/collection/iterable/power_set.dart +++ b/lib/src/collection/iterable/power_set.dart @@ -10,17 +10,18 @@ extension PowerSetIterableExtension on Iterable { /// set-elements, de-duplicate your input [Iterable] before calling this /// function. /// - /// For example `['x', 'y', 'z'].powerSet()` yields the following sets: - /// - /// [] - /// ['x'] - /// ['y'] - /// ['z'] - /// ['x', 'y'] - /// ['x', 'z'] - /// ['y', 'z'] - /// ['x', 'y', 'z'] + /// For example, `['x', 'y', 'z'].powerSet()` yields the following sets: /// + /// ```text + /// [] + /// ['x'] + /// ['y'] + /// ['z'] + /// ['x', 'y'] + /// ['x', 'z'] + /// ['y', 'z'] + /// ['x', 'y', 'z'] + /// ``` Iterable> powerSet() sync* { final list = toList(growable: false); for (var i = 0; i <= list.length; i++) { diff --git a/lib/src/collection/iterable/product.dart b/lib/src/collection/iterable/product.dart index 575c618..4119288 100644 --- a/lib/src/collection/iterable/product.dart +++ b/lib/src/collection/iterable/product.dart @@ -8,19 +8,14 @@ extension ProductIterableExtension on Iterable> { /// ordering so that if the input’s iterables are sorted, the product is /// sorted as well. /// - /// For example, the product of `['x', 'y']` and `[1, 2, 3]` is created with - /// - /// [['x', 'y'], [1, 2, 3]].product(); - /// - /// and results in an iterable with the following elements: - /// - /// ['x', 1] - /// ['x', 2] - /// ['x', 3] - /// ['y', 1] - /// ['y', 2] - /// ['y', 3] + /// For example: /// + /// ```dart + /// final a = ['x', 'y']; + /// final b = [1, 2, 3]; + /// print([a, b].product()); // [['x', 1], ['x', 2], ['x', 3], + /// // ['y', 1], ['y', 2], ['y', 3]] + /// ``` Iterable> product({int repeat = 1}) { checkNonZeroPositive(repeat, 'repeat'); if (isEmpty || any((iterable) => iterable.isEmpty)) { @@ -38,19 +33,14 @@ extension Product2IterableExtension on (Iterable, Iterable) { /// Combines a tuple of iterables with the cross product to an iterable of /// tuples. /// - /// For example, the product of `['x', 'y']` and `[1, 2, 3]` is created with - /// - /// (['x', 'y'], [1, 2, 3]).product(); - /// - /// and results in an iterable with the following tuples: - /// - /// ('x', 1) - /// ('x', 2) - /// ('x', 3) - /// ('y', 1) - /// ('y', 2) - /// ('y', 3) + /// For example: /// + /// ```dart + /// final a = ['x', 'y']; + /// final b = [1, 2, 3]; + /// print((a, b).product()); // [('x', 1), ('x', 2), ('x', 3), + /// // ('y', 1), ('y', 2), ('y', 3)] + /// ``` Iterable<(T1, T2)> product() sync* { for (final v1 in $1) { for (final v2 in $2) { diff --git a/lib/src/collection/iterable/random.dart b/lib/src/collection/iterable/random.dart index 9d84e63..289919c 100644 --- a/lib/src/collection/iterable/random.dart +++ b/lib/src/collection/iterable/random.dart @@ -3,12 +3,12 @@ import 'dart:math' show Random; extension RandomIterableExtension on Iterable { /// Returns a random element from this [Iterable]. /// - /// For example - /// - /// [1, 2, 3, 4, 5, 6].atRandom() - /// - /// returns a random dice roll each time you call it. + /// For example, the following expression returns a random dice roll each + /// time you call it: /// + /// ```dart + /// [1, 2, 3, 4, 5, 6].atRandom() + /// ``` E atRandom({Random? random, E Function()? orElse}) { if (isNotEmpty) { final index = (random ?? _defaultRandom).nextInt(length); diff --git a/lib/src/collection/iterable/repeat_element.dart b/lib/src/collection/iterable/repeat_element.dart index 0a429bf..4f33e93 100644 --- a/lib/src/collection/iterable/repeat_element.dart +++ b/lib/src/collection/iterable/repeat_element.dart @@ -5,11 +5,12 @@ import 'mixins/infinite.dart'; /// Returns an infinite iterable with a constant [element]. If [count] is /// provided the resulting iterator is limited to [count] elements. /// -/// Example expressions: -/// -/// repeat(2); // [2, 2, 2, 2, 2, 2, ...] -/// repeat('a', count: 3); // ['a', 'a', 'a'] +/// For example: /// +/// ```dart +/// repeat(2); // [2, 2, 2, 2, 2, 2, ...] +/// repeat('a', count: 3); // ['a', 'a', 'a'] +/// ``` Iterable repeat(E element, {int? count}) { if (count == 0) { return const []; diff --git a/lib/src/collection/iterable/repeat_iterable.dart b/lib/src/collection/iterable/repeat_iterable.dart index 452ba2a..ad38b0e 100644 --- a/lib/src/collection/iterable/repeat_iterable.dart +++ b/lib/src/collection/iterable/repeat_iterable.dart @@ -7,11 +7,12 @@ extension RepeatIterableExtension on Iterable { /// [count] is provided the resulting iterator is limited to [count] /// repetitions. /// - /// Example expressions: - /// - /// [1, 2].repeat(); // [1, 2, 1, 2, ...] - /// [1, 2, 3].repeat(count: 2); // [1, 2, 3, 1, 2, 3] + /// For example: /// + /// ```dart + /// [1, 2].repeat(); // [1, 2, 1, 2, ...] + /// [1, 2, 3].repeat(count: 2); // [1, 2, 3, 1, 2, 3] + /// ``` Iterable repeat({int? count}) { if (count == 0 || isEmpty) { return const []; diff --git a/lib/src/collection/iterable/separated.dart b/lib/src/collection/iterable/separated.dart index 9f1de84..8bc6d5b 100644 --- a/lib/src/collection/iterable/separated.dart +++ b/lib/src/collection/iterable/separated.dart @@ -7,11 +7,14 @@ extension SeparatedIterableExtension on Iterable { /// builders can provide an element at the beginning or the end of the /// non-empty iterable. /// - /// Examples: - /// - /// [1, 2, 3].separatedBy(() => 0); // [1, 0, 2, 0, 3] - /// [1, 2].separateBy(() => 0, after: () => -1); // [1, 0, 2, -1] + /// For example: /// + /// ```dart + /// final input = [1, 2, 3]; + /// print(input.separatedBy(() => 0)); // [1, 0, 2, 0, 3] + /// print(input.separateBy(() => 0, before: () => -1)); // [-1, 1, 0, 2, 0, 3] + /// print(input.separateBy(() => 0, after: () => -1)); // [1, 0, 2, 0, 3, -1] + /// ``` Iterable separatedBy(Builder separator, {Builder? before, Builder? after}) sync* { var index = 0; diff --git a/lib/src/collection/iterable/to_map.dart b/lib/src/collection/iterable/to_map.dart index 0ce18d3..81b4549 100644 --- a/lib/src/collection/iterable/to_map.dart +++ b/lib/src/collection/iterable/to_map.dart @@ -1,17 +1,15 @@ extension ToMapIterableExtension on Iterable { /// Returns an [Map] from an [Iterable]. /// - /// For example, the expression - /// - /// ['a', 'bb', 'ccc'].toMap( - /// key: (each) => each[0], - /// value: (each) => each.length, - /// ) - /// - /// converts the input [Iterable] to a [Map]: - /// - /// {'a': 1, 'b': 2, 'c': 3} + /// For example, the following expression converts the input [Iterable] to a + /// [Map]: `{'a': 1, 'b': 2, 'c': 3}`: /// + /// ```dart + /// ['a', 'bb', 'ccc'].toMap( + /// key: (each) => each[0], + /// value: (each) => each.length, + /// ) + /// ``` Map toMap( {K Function(E element)? key, V Function(E element)? value}) { final keyProvider = key ?? (element) => element as K; diff --git a/lib/src/collection/iterable/unique.dart b/lib/src/collection/iterable/unique.dart index a98df69..fb2c14b 100644 --- a/lib/src/collection/iterable/unique.dart +++ b/lib/src/collection/iterable/unique.dart @@ -13,8 +13,10 @@ extension UniqueIterableExtension on Iterable { /// The following expression iterates over 1, 2, 3, and 4; skipping the second /// occurrence of 2: /// - /// [1, 2, 3, 2, 4].unique() - /// + /// ```dart + /// final input = [1, 2, 3, 2, 4]; + /// print(input.unique()); // [1, 2, 3, 4] + /// ``` Iterable unique({ Set Function()? factory, bool Function(E e1, E e2)? equals, diff --git a/lib/src/collection/iterable/window.dart b/lib/src/collection/iterable/window.dart index 1ea5a4a..3c82206 100644 --- a/lib/src/collection/iterable/window.dart +++ b/lib/src/collection/iterable/window.dart @@ -7,8 +7,9 @@ extension WindowIterableExtension on Iterable { /// /// The following expression yields `[1, 2, 3]`, `[2, 3, 4]`, and `[3, 4, 5]`: /// - /// [1, 2, 3, 4, 5].window(3); - /// + /// ```dart + /// [1, 2, 3, 4, 5].window(3); + /// ``` Iterable> window(int size, {int step = 1, bool includePartial = false}) sync* { checkNonZeroPositive(size, 'size'); diff --git a/lib/src/collection/iterable/zip.dart b/lib/src/collection/iterable/zip.dart index a9dcd5f..f658726 100644 --- a/lib/src/collection/iterable/zip.dart +++ b/lib/src/collection/iterable/zip.dart @@ -3,10 +3,12 @@ extension ZipIterableExtension on Iterable> { /// new list. The resulting iterable has the length of the shortest input /// iterable. /// - /// The following expression yields `[1, 'a']` and `[2, 'b']`: - /// - /// [[1, 2], ['a', 'b']].zip(); + /// For example: /// + /// ```dart + /// final input = [[1, 2], ['a', 'b']]; + /// print(input.zip()); // [[1, 'a'], [2, 'b']] + /// ``` Iterable> zip() sync* { if (isEmpty) return; final iterators = @@ -62,14 +64,12 @@ extension Zip2IterableExtension on (Iterable, Iterable) { /// Combines the tuple of iterables to an iterable of tuples. The resulting /// iterable has the length of the shortest input iterable. /// - /// For example, the following expression - /// - /// ([1, 2], ['a', 'b']).zip(); - /// - /// yields - /// - /// [(1, 'a'), (2, 'b')] + /// For example: /// + /// ```dart + /// final input = ([1, 2], ['a', 'b']); + /// print(input.zip()); // [(1, 'a'), (2, 'b')] + /// ``` Iterable<(T1, T2)> zip() sync* { final i1 = $1.iterator, i2 = $2.iterator; while (i1.moveNext() && i2.moveNext()) { diff --git a/lib/src/collection/map/default.dart b/lib/src/collection/map/default.dart index 0d9da93..c0f1264 100644 --- a/lib/src/collection/map/default.dart +++ b/lib/src/collection/map/default.dart @@ -6,10 +6,11 @@ extension DefaultMapExtension on Map { /// /// For example: /// - /// final map = {'a': 1}.withDefault(42); - /// print(map['z']); // prints '42' - /// print(map.containsKey('z')); // prints 'false' - /// + /// ```dart + /// final map = {'a': 1}.withDefault(42); + /// print(map['z']); // 42 + /// print(map.containsKey('z')); // false + /// ``` MapWithDefault withDefault(V value) => MapWithDefault(this, value); } diff --git a/lib/src/collection/range/bigint.dart b/lib/src/collection/range/bigint.dart index 2f7d118..b1ed6b7 100644 --- a/lib/src/collection/range/bigint.dart +++ b/lib/src/collection/range/bigint.dart @@ -6,9 +6,11 @@ import '../range.dart'; /// range essentially implements a lazy list that is also produced by the /// following for-loop: /// -/// for (BigInt i = start; i < stop; i += step) { -/// ... -/// +/// ```dart +/// for (BigInt i = start; i < stop; i += step) { +/// // ... +/// } +/// ``` class BigIntRange extends Range { /// The empty range. static final empty = BigIntRange._(BigInt.zero, BigInt.zero, BigInt.one, 0); diff --git a/lib/src/collection/range/double.dart b/lib/src/collection/range/double.dart index 1a34da0..6adeb19 100644 --- a/lib/src/collection/range/double.dart +++ b/lib/src/collection/range/double.dart @@ -7,9 +7,11 @@ import '../range.dart'; /// range essentially implements a lazy list that is also produced by the /// following for-loop: /// -/// for (double i = start; i < stop; i += step) { -/// ... -/// +/// ```dart +/// for (double i = start; i < stop; i += step) { +/// // ... +/// } +/// ``` class DoubleRange extends Range { /// The empty range. static const empty = DoubleRange._(0, 0, 1, 0); diff --git a/lib/src/collection/range/integer.dart b/lib/src/collection/range/integer.dart index a7ef7fc..8cc53da 100644 --- a/lib/src/collection/range/integer.dart +++ b/lib/src/collection/range/integer.dart @@ -6,9 +6,11 @@ import '../range.dart'; /// range essentially implements a lazy list that is also produced by the /// following for-loop: /// -/// for (int i = start; i < stop; i += step) { -/// ... -/// +/// ```dart +/// for (int i = start; i < stop; i += step) { +/// // ... +/// } +/// ``` class IntegerRange extends Range { /// The empty range. static const empty = IntegerRange._(0, 0, 1, 0); @@ -134,14 +136,12 @@ extension IndicesIterableExtension on Iterable { /// indices. A negative [step] counter returns the indices in reverse /// order. /// - /// For example, the expression - /// - /// ['a', 'b', 'c'].indices(step: 2) - /// - /// returns - /// - /// [0, 2] + /// For example: /// + /// ```dart + /// final input = ['a', 'b', 'c']; + /// print(input.indices(step: 2)); // [0, 2] + /// ``` Range indices({int step = 1}) => step > 0 ? IntegerRange.of(start: 0, end: length, step: step) : IntegerRange.of(start: length - 1, end: -1, step: step); diff --git a/lib/src/collection/string/string_list.dart b/lib/src/collection/string/string_list.dart index 7f54bb6..e93a197 100644 --- a/lib/src/collection/string/string_list.dart +++ b/lib/src/collection/string/string_list.dart @@ -8,26 +8,31 @@ extension StringListExtension on String { /// The immutable version is very light-weight. To loop over the characters /// of a string simply write: /// - /// for (String char in 'Hello World'.toList()) { - /// print(char); - /// } + /// ```dart + /// for (String char in 'Hello World'.toList()) { + /// print(char); + /// } + /// ``` /// /// Of course, also all other more functional operations from [List] work too: /// - /// 'Hello World'.toList() - /// .where((char) => char != 'o') - /// .forEach(print); + /// ```dart + /// 'Hello World'.toList() + /// .where((char) => char != 'o') + /// .forEach(print);` + /// ``` /// /// For a mutable copy of the string set the parameter [mutable] to `true`. /// - /// For example the following code prints 'Hello Brave World!': - /// - /// var result = 'Hello World'.toList(mutable: true); - /// result.insertAll(6, 'brave '.toList()); - /// result[6] = 'B'; - /// result.add('!'); - /// print(result); + /// For example: /// + /// ```dart + /// final result = 'Hello World'.toList(mutable: true); + /// result.insertAll(6, 'brave '.toList()); + /// result[6] = 'B'; + /// result.add('!'); + /// print(result); // Hello Brave World! + /// ``` List toList({bool mutable = false}) => mutable ? MutableStringList(List.of(codeUnits)) : ImmutableStringList(this); diff --git a/lib/src/functional/either.dart b/lib/src/functional/either.dart index 9d185f3..4511fc3 100644 --- a/lib/src/functional/either.dart +++ b/lib/src/functional/either.dart @@ -1,5 +1,5 @@ /// A container that may contain one or the other value. -library either; +library; import 'package:meta/meta.dart'; diff --git a/lib/src/functional/optional.dart b/lib/src/functional/optional.dart index 5dabcfb..e52b4cc 100644 --- a/lib/src/functional/optional.dart +++ b/lib/src/functional/optional.dart @@ -1,5 +1,5 @@ /// A container that may or may not contain a value. -library optional; +library; import 'package:meta/meta.dart'; diff --git a/lib/src/functional/scope.dart b/lib/src/functional/scope.dart index ec09781..e6e94a3 100644 --- a/lib/src/functional/scope.dart +++ b/lib/src/functional/scope.dart @@ -4,16 +4,19 @@ extension ScopeFunctionExtension on T { /// /// In a cascade, this is useful to chain calls to other functions: /// - /// [1, 2, 3] - /// ..also((list) => print('Before: $list')) - /// ..add(4) - /// ..also((list) => print('After: $list')); + /// ```dart + /// [1, 2, 3] + /// ..also((list) => print('Before: $list')) + /// ..add(4) + /// ..also((list) => print('After: $list')); + /// ``` /// /// On a nullable value, this is useful to only evaluate code on non-null /// objects. For example, to convert a nullable string to an int, one could /// write: /// - /// final value = nullableString?.also(int.tryParse); - /// + /// ```dart + /// final value = nullableString?.also(int.tryParse); + /// ``` S also(S Function(T value) callback) => callback(this); } diff --git a/lib/src/functional/types/callback.dart b/lib/src/functional/types/callback.dart index 0ad931b..5305510 100644 --- a/lib/src/functional/types/callback.dart +++ b/lib/src/functional/types/callback.dart @@ -1,7 +1,7 @@ // AUTO-GENERATED CODE: DO NOT EDIT /// Function types for generic callbacks. -library callback; +library; /// Callback function type with 0 positional arguments. typedef Callback0 = void Function(); diff --git a/lib/src/functional/types/constant.dart b/lib/src/functional/types/constant.dart index a930411..257a9fc 100644 --- a/lib/src/functional/types/constant.dart +++ b/lib/src/functional/types/constant.dart @@ -1,7 +1,7 @@ // AUTO-GENERATED CODE: DO NOT EDIT /// The constant functions. -library constant; +library; import 'mapping.dart'; diff --git a/lib/src/functional/types/curry.dart b/lib/src/functional/types/curry.dart index 3240330..f390399 100644 --- a/lib/src/functional/types/curry.dart +++ b/lib/src/functional/types/curry.dart @@ -2,7 +2,7 @@ /// Converts a function with positional arguments into a sequence of functions /// taking a single argument: https://en.wikipedia.org/wiki/Currying -library curry; +library; import 'mapping.dart'; diff --git a/lib/src/functional/types/empty.dart b/lib/src/functional/types/empty.dart index eec5f77..11433d7 100644 --- a/lib/src/functional/types/empty.dart +++ b/lib/src/functional/types/empty.dart @@ -1,7 +1,7 @@ // AUTO-GENERATED CODE: DO NOT EDIT /// Generic empty functions returning nothing. -library empty; +library; /// Empty function with 0 positional arguments. void emptyFunction0() {} diff --git a/lib/src/functional/types/identity.dart b/lib/src/functional/types/identity.dart index b89885f..5b51c58 100644 --- a/lib/src/functional/types/identity.dart +++ b/lib/src/functional/types/identity.dart @@ -1,7 +1,7 @@ // AUTO-GENERATED CODE: DO NOT EDIT /// Generic identity functions. -library identity; +library; /// Generic identity function with 1 positional argument. T identityFunction(T arg) => arg; diff --git a/lib/src/functional/types/mapping.dart b/lib/src/functional/types/mapping.dart index d8c6cf6..5e56e10 100644 --- a/lib/src/functional/types/mapping.dart +++ b/lib/src/functional/types/mapping.dart @@ -1,7 +1,7 @@ // AUTO-GENERATED CODE: DO NOT EDIT /// Function type for generic mapping functions. -library mapping; +library; /// Mapping function type with 0 positional arguments. typedef Map0 = R Function(); diff --git a/lib/src/functional/types/partial.dart b/lib/src/functional/types/partial.dart index 80e60e3..3e2de3b 100644 --- a/lib/src/functional/types/partial.dart +++ b/lib/src/functional/types/partial.dart @@ -2,7 +2,7 @@ /// Binds positional arguments and returns a new function: /// https://en.wikipedia.org/wiki/Partial_application -library partial; +library; import 'mapping.dart'; diff --git a/lib/src/functional/types/predicate.dart b/lib/src/functional/types/predicate.dart index 0af9cc9..cfc5ec0 100644 --- a/lib/src/functional/types/predicate.dart +++ b/lib/src/functional/types/predicate.dart @@ -1,7 +1,7 @@ // AUTO-GENERATED CODE: DO NOT EDIT /// Function type for generic predicate functions. -library predicate; +library; /// Predicate function type with 0 positional arguments. typedef Predicate0 = bool Function(); diff --git a/lib/src/functional/types/throwing.dart b/lib/src/functional/types/throwing.dart index 7cdfcad..6a2c6e5 100644 --- a/lib/src/functional/types/throwing.dart +++ b/lib/src/functional/types/throwing.dart @@ -1,7 +1,7 @@ // AUTO-GENERATED CODE: DO NOT EDIT /// The throwing functions. -library throwing; +library; import 'mapping.dart'; diff --git a/lib/src/math/polynomial.dart b/lib/src/math/polynomial.dart index 97e2e61..36a9edb 100644 --- a/lib/src/math/polynomial.dart +++ b/lib/src/math/polynomial.dart @@ -4,7 +4,9 @@ extension PolynomialIterableExtension on Iterable { /// /// For example, if the [Iterable] has 4 elements the function computes: /// - /// c[0]*x^0 + c[1]*x^1 + c[2]*x^3 + c[3]*x^3 + /// ```dart + /// c[0]*x^0 + c[1]*x^1 + c[2]*x^3 + c[3]*x^3 + /// ``` num polynomial([num x = 10]) { num r = 0, e = 1; for (final c in this) { diff --git a/lib/src/printer/temporal/date_time.dart b/lib/src/printer/temporal/date_time.dart index acea98a..3b7f4b6 100644 --- a/lib/src/printer/temporal/date_time.dart +++ b/lib/src/printer/temporal/date_time.dart @@ -17,13 +17,15 @@ import '../where.dart'; /// For example, to print dates in the format `YYYY-MM-DD` call the constructor /// and configure the printer as such: /// -/// final printer = DateTimePrinter((builder) => builder -/// ..year(width: 4) -/// ..literal('-') -/// ..month(width: 2) -/// ..literal('-') -/// ..day(width: 2)); -/// +/// ```dart +/// final printer = DateTimePrinter((builder) => builder +/// ..year(width: 4) +/// ..literal('-') +/// ..month(width: 2) +/// ..literal('-') +/// ..day(width: 2)); +/// print(printer(DateTime(1975, 1, 9, 15, 45))); // 1975-01-09 +/// ``` class DateTimePrinter extends SequencePrinter { /// Constructor to build a [DateTimePrinter]. factory DateTimePrinter(Callback1 callback) { diff --git a/lib/src/printer/temporal/duration.dart b/lib/src/printer/temporal/duration.dart index 4890455..c14d94d 100644 --- a/lib/src/printer/temporal/duration.dart +++ b/lib/src/printer/temporal/duration.dart @@ -14,13 +14,15 @@ import '../where.dart'; /// For example, to print dates in the format `YYYY-MM-DD` call the constructor /// and configure the printer as such: /// -/// final printer = DurationPrinter((builder) => builder -/// ..year(width: 4) -/// ..literal('-') -/// ..month(width: 2) -/// ..literal('-') -/// ..day(width: 2)); -/// +/// ```dart +/// final printer = DurationPrinter((builder) => builder +/// ..part(TimeUnit.year, printer: FixedNumberPrinter(padding: 4)) +/// ..literal(':') +/// ..part(TimeUnit.month, printer: FixedNumberPrinter(padding: 2)) +/// ..literal(':') +/// ..part(TimeUnit.day, printer: FixedNumberPrinter(padding: 2))); +/// print(printer(const Duration(days: 1234, seconds: 56789))); // 0003-04-19 +/// ``` class DurationPrinter extends SequencePrinter { /// Constructor to build a [DurationPrinter]. factory DurationPrinter(Callback1 callback, @@ -36,34 +38,34 @@ class DurationPrinter extends SequencePrinter { /// Returns the standard Dart duration format. static DurationPrinter dart() => DurationPrinter((builder) => builder ..sign() - ..part(TimeUnit.hour, FixedNumberPrinter()) + ..part(TimeUnit.hour) ..literal(':') - ..part(TimeUnit.minute, FixedNumberPrinter(padding: 2)) + ..part(TimeUnit.minute, printer: FixedNumberPrinter(padding: 2)) ..literal(':') - ..part(TimeUnit.second, FixedNumberPrinter(padding: 2)) + ..part(TimeUnit.second, printer: FixedNumberPrinter(padding: 2)) ..literal('.') - ..part(TimeUnit.millisecond, FixedNumberPrinter(padding: 3)) - ..part(TimeUnit.microsecond, FixedNumberPrinter(padding: 3))); + ..part(TimeUnit.millisecond, printer: FixedNumberPrinter(padding: 3)) + ..part(TimeUnit.microsecond, printer: FixedNumberPrinter(padding: 3))); /// Returns an ISO-8601 extended full-precision format representation. static DurationPrinter iso8601() => DurationPrinter((builder) => builder ..literal('P') ..sign() - ..part(TimeUnit.year, FixedNumberPrinter().after('Y'), - skipIfZero: true) - ..part(TimeUnit.month, FixedNumberPrinter().after('M'), - skipIfZero: true) - ..part(TimeUnit.week, FixedNumberPrinter().after('W'), - skipIfZero: true) - ..part(TimeUnit.day, FixedNumberPrinter().after('D')) + ..part(TimeUnit.year, + printer: FixedNumberPrinter().after('Y'), skipIfZero: true) + ..part(TimeUnit.month, + printer: FixedNumberPrinter().after('M'), skipIfZero: true) + ..part(TimeUnit.week, + printer: FixedNumberPrinter().after('W'), skipIfZero: true) + ..part(TimeUnit.day, printer: FixedNumberPrinter().after('D')) ..literal('T') - ..part(TimeUnit.hour, FixedNumberPrinter().after('H'), - skipIfZero: true) - ..part(TimeUnit.minute, FixedNumberPrinter().after('M'), - skipIfZero: true) - ..part(TimeUnit.second, FixedNumberPrinter()) - ..part( - TimeUnit.microsecond, FixedNumberPrinter(padding: 6).before('.'), + ..part(TimeUnit.hour, + printer: FixedNumberPrinter().after('H'), skipIfZero: true) + ..part(TimeUnit.minute, + printer: FixedNumberPrinter().after('M'), skipIfZero: true) + ..part(TimeUnit.second) + ..part(TimeUnit.microsecond, + printer: FixedNumberPrinter(padding: 6).before('.'), skipIfZero: true) ..literal('S')); } @@ -99,10 +101,12 @@ class DurationPrinterBuilder { /// If `skipIfZero` is set to `true` the unit is skipped if it is zero. /// /// See [ConvertToAllDurationExtension.convertToAll] for details. - void part(TimeUnit unit, Printer printer, - {bool absoluteValue = true, bool skipIfZero = false}) { + void part(TimeUnit unit, + {Printer? printer, + bool absoluteValue = true, + bool skipIfZero = false}) { _unitParts.add(unit); - add(printer + add((printer ?? FixedNumberPrinter()) .mapIf(absoluteValue, (printer) => printer.onResultOf((value) => value.abs())) .mapIf(skipIfZero, (printer) => printer.where((value) => value != 0)) diff --git a/lib/src/printer/to_string.dart b/lib/src/printer/to_string.dart index 84fe122..6e78295 100644 --- a/lib/src/printer/to_string.dart +++ b/lib/src/printer/to_string.dart @@ -7,10 +7,12 @@ import 'object/object.dart'; /// Add the mixin to the root of your object hierarchy and override the /// `toStringPrinter` accessor: /// -/// @override -/// ObjectPrinter get toStringPrinter => super.toStringPrinter -/// ..addValue(someField, name: 'someField') -/// ..addValue(otherField, name: 'otherField'); +/// ```dart +/// @override +/// ObjectPrinter get toStringPrinter => super.toStringPrinter +/// ..addValue(someField, name: 'someField') +/// ..addValue(otherField, name: 'otherField'); +/// ``` /// /// Note: Due to the lack of a `Self` type in Dart, this is working with a /// dynamically typed printer Object. To avoid loosing the type information diff --git a/lib/src/temporal/date_time/periodical.dart b/lib/src/temporal/date_time/periodical.dart index 43ff7d8..dae3923 100644 --- a/lib/src/temporal/date_time/periodical.dart +++ b/lib/src/temporal/date_time/periodical.dart @@ -12,22 +12,27 @@ extension PeriodicalDateTimeExtension on DateTime { /// [Iterable.take]; and to limit iteration to a specific end-timestamp use /// [Iterable.takeWhile]. For example: /// - /// // Enumerate 10 days after September 2, 2017. - /// DateTime(2017, DateTime.SEPTEMBER, 2).periodical().take(10) + /// ```dart + /// // Enumerate 10 days after September 2, 2017. + /// DateTime(2017, DateTime.SEPTEMBER, 2).periodical().take(10) + /// ``` /// - /// // Enumerate the remaining days in the current year. - /// final today = DateTime.now(); - /// final nextYear = DateTime(today.year + 1); - /// today.periodical(period: Period.daily) - /// .takeWhile((timestamp) => timestamp.isBefore(nextYear)); + /// ```dart + /// // Enumerate the remaining days in the current year. + /// final today = DateTime.now(); + /// final nextYear = DateTime(today.year + 1); + /// today.periodical(period: Period.daily) + /// .takeWhile((timestamp) => timestamp.isBefore(nextYear)); + /// ``` /// /// Note: Due to leap seconds and daylight saving time, not all periods are /// of equal length. To produce an infinite sequence of timestamps that are /// equally spaced, simply use `iterate` and an offset instead. For example: /// - /// final offset = Duration(days: 1); - /// iterate(DateTime().now(), (prev) => prev.add(offset)); - /// + /// ```dart + /// final offset = Duration(days: 1); + /// iterate(DateTime().now(), (prev) => prev.add(offset)); + /// ``` Iterable periodical(TimeUnit unit, {int step = 1}) { if (step == 0) { throw ArgumentError.value(step, 'step', 'Expected non-zero step size'); diff --git a/lib/temporal.dart b/lib/temporal.dart index 9ceccbd..bd9b5c9 100644 --- a/lib/temporal.dart +++ b/lib/temporal.dart @@ -1,5 +1,5 @@ /// Various extensions to the built-in date, time and duration objects. -library temporal; +library; export 'src/temporal/conversion.dart'; export 'src/temporal/date_time/accessors.dart'; diff --git a/lib/tuple.dart b/lib/tuple.dart index 2edebee..4e106ec 100644 --- a/lib/tuple.dart +++ b/lib/tuple.dart @@ -1,7 +1,7 @@ // AUTO-GENERATED CODE: DO NOT EDIT /// Tuple extension methods on generic records. -library tuple; +library; export 'src/tuple/tuple.dart'; export 'src/tuple/tuple_0.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index b01d112..fdbf0ba 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ topics: - unicode environment: - sdk: ^3.3.0 + sdk: ^3.4.0 dependencies: characters: ^1.3.0 clock: ^1.1.0 @@ -23,6 +23,6 @@ dev_dependencies: build_runner: ^2.4.0 build_web_compilers: ^4.0.0 fake_async: ^1.3.0 - lints: ^3.0.0 + lints: ^4.0.0 test: ^1.25.0 web: ^0.5.0 \ No newline at end of file diff --git a/test/printer_test.dart b/test/printer_test.dart index 2294f1b..a2d5cbd 100644 --- a/test/printer_test.dart +++ b/test/printer_test.dart @@ -927,9 +927,9 @@ void main() { group('part', () { test('default', () { final printer = DurationPrinter((builder) => builder - ..part(TimeUnit.day, FixedNumberPrinter()) + ..part(TimeUnit.day) ..literal('*') - ..part(TimeUnit.minute, FixedNumberPrinter())); + ..part(TimeUnit.minute)); expect(durations.map(printer.print), [ '0*0', '12345*0', @@ -942,9 +942,9 @@ void main() { }); test('skipIfZero', () { final printer = DurationPrinter((builder) => builder - ..part(TimeUnit.day, FixedNumberPrinter(), skipIfZero: true) + ..part(TimeUnit.day, skipIfZero: true) ..literal('*') - ..part(TimeUnit.minute, FixedNumberPrinter(), skipIfZero: true)); + ..part(TimeUnit.minute, skipIfZero: true)); expect(durations.map(printer.print), [ '*', '12345*', @@ -957,9 +957,9 @@ void main() { }); test('absoluteValue', () { final printer = DurationPrinter((builder) => builder - ..part(TimeUnit.day, FixedNumberPrinter(), absoluteValue: false) + ..part(TimeUnit.day, absoluteValue: false) ..literal('*') - ..part(TimeUnit.minute, FixedNumberPrinter(), absoluteValue: false)); + ..part(TimeUnit.minute, absoluteValue: false)); expect(durations.map(printer.print), [ '0*0', '12345*0',