Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
simc committed Oct 26, 2019
1 parent b1cbd10 commit 3804a6c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
5 changes: 5 additions & 0 deletions dartx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions dartx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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),
Expand All @@ -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']
Expand All @@ -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()
Expand All @@ -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'
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions dartx/lib/src/io/directory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 <from> <to>`:
/// * 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<Null> copyRecursively(Directory target) async {
Expand Down
2 changes: 1 addition & 1 deletion dartx/lib/src/io/file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> appendString(String string, {Encoding encoding: utf8}) async {
Future<void> appendString(String string, {Encoding encoding = utf8}) async {
var raf = await open(mode: FileMode.writeOnlyAppend);
await raf.writeString(string);
await raf.close();
Expand Down
4 changes: 2 additions & 2 deletions dartx/lib/src/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ extension ListX<E> on List<E> {
///
/// This insertion sort is stable: Equal elements end up in the same order
/// as they started in.
void insertionSort({Comparator<E> comparator, int start: 0, int end}) {
void insertionSort({Comparator<E> comparator, int start = 0, int end}) {
_insertionSort(this, compare: comparator, start: start, end: end);
}

Expand All @@ -150,7 +150,7 @@ extension ListX<E> on List<E> {
///
/// 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<E> comparator}) {
void mergeSort({int start = 0, int end, Comparator<E> comparator}) {
_mergeSort(this, start: start, end: end, compare: comparator);
}
}

0 comments on commit 3804a6c

Please sign in to comment.