From 3804a6cf01aa2f54531ac8c3533eaa2ed581c08b Mon Sep 17 00:00:00 2001 From: Simon Leier Date: Sat, 26 Oct 2019 12:30:44 +0200 Subject: [PATCH] Fix docs --- dartx/CHANGELOG.md | 5 +++++ dartx/README.md | 14 +++++++------- dartx/lib/src/io/directory.dart | 6 +++--- dartx/lib/src/io/file.dart | 2 +- dartx/lib/src/list.dart | 4 ++-- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/dartx/CHANGELOG.md b/dartx/CHANGELOG.md index 862c10a..80610e4 100644 --- a/dartx/CHANGELOG.md +++ b/dartx/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.1.2 +- Fixed docs +- `'string'.reversed` now correctly handles grapheme clusters +- **Breaking:** `'string'.chars` now returns the grapheme clusters instead of `Rune`s + ## 0.1.1 - Bugfixes - More tests diff --git a/dartx/README.md b/dartx/README.md index 8612206..8bc838c 100644 --- a/dartx/README.md +++ b/dartx/README.md @@ -31,7 +31,7 @@ var slice = [1, 2, 3, 4, 5].slice(1, -2); // [2, 3] ## Iterable ### slice() -Returns elements at indices between `start` (inclusive) and `end` (inclusive) +Returns elements at indices between `start` (inclusive) and `end` (inclusive). ```dart var list = [0, 1, 2, 3, 4, 5]); var last = list.slice(-1); // [5] @@ -40,7 +40,7 @@ var allButFirstAndLast = list.slice(1, -2); // [1, 2, 3, 4] ``` ### sortedBy() & thenBy() -Sort lists by multiple properties +Sort lists by multiple properties. ```dart var dogs = [ Dog(name: "Tom", age: 3), @@ -57,7 +57,7 @@ var sorted = dogs ``` ### distinctBy() -Get distinct elements from a list: +Get distinct elements from a list. ```dart var list = ['this', 'is', 'a', 'test']; var distinctByLength = list.distinctBy((it) => it.length); // ['this', 'is', 'a'] @@ -73,9 +73,9 @@ var flattened = nestedList.flatten(); // [1, 2, 3, 4, 5, 6] ## String ### chars -Get a list of single character strings from a string. +Get a list of single character strings from a string. Supports emojis. ```dart -var chars = 'test'.chars; // ['t', 'e', 's', 't'] +var chars = 'family๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ'.chars; // ['f', 'a', 'm', 'i', 'l', 'y', '๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ'] ``` ### isBlank() @@ -95,7 +95,7 @@ var notANumber = '123-45'.toIntOrNull(); // null ## File ### name -Get the name and extension of a file: +Get the name and extension of a file. ```dart var file = File('some/path/testFile.dart'); print(file.name); // 'testFile.dart' @@ -109,7 +109,7 @@ await File('someFile.json').appendText('{test: true}'); ``` ### isWithin() -Checks if a file is inside a directory +Checks if a file is inside a directory. ```dart var dir = Directory('some/path'); File('some/path/file.dart').isWithin(dir); // true diff --git a/dartx/lib/src/io/directory.dart b/dartx/lib/src/io/directory.dart index b35b507..fb409ec 100644 --- a/dartx/lib/src/io/directory.dart +++ b/dartx/lib/src/io/directory.dart @@ -13,13 +13,13 @@ extension DirectoryX on Directory { ); } - /// Copies all of the files in the [from] directory to [to]. + /// Copies all of the files in this directory to [target]. /// /// This is similar to `cp -R `: /// * Symlinks are supported. /// * Existing files are over-written, if any. - /// * If [to] is within [from], throws [ArgumentError] (an infinite operation). - /// * If [from] and [to] are canonically the same, no operation occurs. + /// * If [target] is within `this`, throws [ArgumentError]. + /// * If `this` and [target] are canonically the same, no operation occurs. /// /// Returns a future that completes when complete. Future copyRecursively(Directory target) async { diff --git a/dartx/lib/src/io/file.dart b/dartx/lib/src/io/file.dart index baa34e4..b0e434d 100644 --- a/dartx/lib/src/io/file.dart +++ b/dartx/lib/src/io/file.dart @@ -10,7 +10,7 @@ extension FileX on File { /// Appends a [string] to the content of this file using UTF-8 or the /// specified [encoding]. - Future appendString(String string, {Encoding encoding: utf8}) async { + Future appendString(String string, {Encoding encoding = utf8}) async { var raf = await open(mode: FileMode.writeOnlyAppend); await raf.writeString(string); await raf.close(); diff --git a/dartx/lib/src/list.dart b/dartx/lib/src/list.dart index 7ad4f6d..f78f015 100644 --- a/dartx/lib/src/list.dart +++ b/dartx/lib/src/list.dart @@ -130,7 +130,7 @@ extension ListX on List { /// /// This insertion sort is stable: Equal elements end up in the same order /// as they started in. - void insertionSort({Comparator comparator, int start: 0, int end}) { + void insertionSort({Comparator comparator, int start = 0, int end}) { _insertionSort(this, compare: comparator, start: start, end: end); } @@ -150,7 +150,7 @@ extension ListX on List { /// /// This merge sort is stable: Equal elements end up in the same order /// as they started in. - void mergeSort({int start: 0, int end, Comparator comparator}) { + void mergeSort({int start = 0, int end, Comparator comparator}) { _mergeSort(this, start: start, end: end, compare: comparator); } }