Skip to content

Commit

Permalink
Fix Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
simc committed Sep 19, 2018
1 parent ee3ffd1 commit 607fa51
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 48 deletions.
19 changes: 13 additions & 6 deletions CHANGELOG.md
@@ -1,22 +1,29 @@
## 0.3.2
- Fixed Readme

## 0.3.1
- Added logo to repository
- Fixed docs

## 0.3.0
- **Breaking:** `$Iterable.whereNotNull` -> `$Iterable.whereNotNull()`
- Added `$Map` and `$map()`
- Added `$Iterable.all()`, `$Iterable.toMap()`, `$Iterable.windowed()`
- Added parameter `n` to `$Iterable.cycle()`
- Added more tests
- Fix wrong naming in docs: ~~`sortBy`~~ is really called `sortedBy` (thanks @bltavares)
- Fixed wrong naming in docs: ~~`sortBy`~~ is really called `sortedBy` (thanks @bltavares)
- Improved docs and added examples to many functions

## 0.2.0
- Remove `drop()` and `dropWhile()` from `$List` and `$Iterable` (use `skip()` and `skipWhile()` instead)
- Add `$it()` as short form of `$Iterable()`
- Add test cases
- Removed `drop()` and `dropWhile()` from `$List` and `$Iterable` (use `skip()` and `skipWhile()` instead)
- Added `$it()` as short form of `$Iterable()`
- Added test cases

## 0.1.3
- Add `$Iterable.joinToString()`, `$Iterable.onEach()` and `$Iterable.shuffled`
- Added `$Iterable.joinToString()`, `$Iterable.onEach()` and `$Iterable.shuffled`

## 0.1.2
- Add `$Iterable.mapNotNull()`
- Added `$Iterable.mapNotNull()`

## 0.1.1
- Documentation fixes
Expand Down
71 changes: 30 additions & 41 deletions README.md
Expand Up @@ -18,12 +18,10 @@ Inspired by Kotlin.
Just wrap your existing `List` with `$(myList)` or create a new empty list with `$()` and you are good to go.

```dart
var superList = $([1, 10, 2, 9, null, 3, 8, 4, 7, 5, 6]);
superList
.slice(2, -2) // [2, 9, null, 3, 8, 4, 7]
.whereNotNull() // [2, 9, 3, 8, 4, 7]
.whereIndexed((_, index) => index % 2 == 1) // [9, 8, 7]
.sum(); // 24
var superList = $([0, 10, 100, 1000]);
var sum = superList.sum(); // 1110
var last = superList[-1]; // 1000
var lastTwo = superList.slice(-2); // [100, 1000]
```

`Iterable`s can be wrapped with `$it(myIterable)` and `Map`s with `$map(myMap)`.
Expand All @@ -46,24 +44,6 @@ var negativeItem = negativeIndices[-3]; // 1
```
You can use negative indices on all new and existing methods of $List and $Iterable.

## firstOrNull & firstOrNullWhere
Find the first element of the collection matching a predicate:
```dart
var list = $(['This', 'is', 'a', 'Test']);
var first = list.firstOrNull; // 'This'
var firstWhere = list.firstOrNullWhere((s) => s.length <= 2); // 'is'
var firtNull = list.firstOrNullWhere((s) => s.length > 4); // null
```

## elementAtOrNull & elementAtOrElse
Get the element at an index or null if the index does not exist:
```dart
var list = $([0, 1, 2, 3, 4, 5, 6]);
var second = list.elementAtOrNull(1); // 1
var highIndexNull = list.elementAtOrNull(10); // null
var highIndexDefault = list.elementAtOrDefault(10, -1); // -1
```

## slice
Get a sublist of the collection:
```dart
Expand All @@ -73,23 +53,6 @@ var lastHalf = list.slice(3); // [3, 4, 5]
var allButFirstAndLast = list.slice(1,-2); // [1, 2, 3, 4]
```

## drop & dropLast
Get a list containing all elements except first `n` elements:
```dart
var list = $([0, 1, 2, 3, 4, 5]);
var lastElements = list.drop(3); // [3, 4, 5]
var firstElements = list.dropLast(3); // [0, 1, 2]
var middleElements = list.drop(2).dropLast(2); // [2, 3]
```

## contentEquals
Compare two lists:
```dart
var list = $(['some', 'items']);
var equals1 = list.contentEquals(['some', 'items']); // true
var equals2 = list.contentEquals(['SOME', 'items']); // false
```

## sortedBy & thenBy
Sort lists by multiple properties
```dart
Expand All @@ -113,6 +76,14 @@ var sorted = dogs
// Bark, Cookie, Charlie (7), Charlie (2), Tom
```

## contentEquals
Compare two lists:
```dart
var list = $(['some', 'items']);
var equals1 = list.contentEquals(['some', 'items']); // true
var equals2 = list.contentEquals(['SOME', 'items']); // false
```

## minBy & maxBy
Get the smallest or largest element from a list:
```dart
Expand All @@ -138,6 +109,24 @@ var nestedList = $List([[1, 2, 3], [4, 5, 6]]);
var flattened = nestedList.flatten(); // [1, 2, 3, 4, 5, 6]
```

## firstOrNull & firstOrNullWhere
Find the first element of the collection matching a predicate:
```dart
var list = $(['This', 'is', 'a', 'Test']);
var first = list.firstOrNull; // 'This'
var firstWhere = list.firstOrNullWhere((s) => s.length <= 2); // 'is'
var firtNull = list.firstOrNullWhere((s) => s.length > 4); // null
```

## elementAtOrNull & elementAtOrElse
Get the element at an index or null if the index does not exist:
```dart
var list = $([0, 1, 2, 3, 4, 5, 6]);
var second = list.elementAtOrNull(1); // 1
var highIndexNull = list.elementAtOrNull(10); // null
var highIndexDefault = list.elementAtOrDefault(10, -1); // -1
```

## many more superpowers
There are many more handy superpowers (like `intersect()`, `groupBy()` and
`associateWith()`) available. Take a look at the
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,5 +1,5 @@
name: superpower
version: 0.3.1
version: 0.3.2
author: Simon Leier <simonleier@gmail.com>
description: "Lists, Iterables and Maps on steroids! 馃 Extends Lists with negative indices, sort, group, distinct, slice, flatten etc. Inspired by Kotlin."
homepage: https://github.com/leisim/superpower
Expand Down

0 comments on commit 607fa51

Please sign in to comment.