Releases: RougeWare/Swift-Collection-Tools
3.2 - Element + Collection
We already had integers + 7
, now we also have 7 + integers
!
3.1 - Added @ArrayBuilder
@ArrayBuilder
is a basic result builder which transforms all of its children into an array. This can be used to great effect when needing to use logic while building an array, like this:
self.tabsArray = Array {
homeTab
searchTab
if !isGuestMode {
profileTab
}
settingsTab
}
3.0.0 - Changed some of the new map APIs
2.3.0 introduced some new map
APIs which take a transformer function. Two of them were ambiguous in many circumstances without explicit type declaration, which doesn't work well in Swift. So, I removed the one that's only for lazy collections and made the one for all collections always-lazy.
2.3.0 - Added map variants which take member functions
I have no idea why this isn't in the standard library nor Foundation, but I often find myself wanting to do something like this:
["Vivien", "Marlon", "Kim", "Karl"].map(String.lowercased)
Now I can! With any collection type, into any collection type.
2.2.0 - Added many small tools
This update adds these small tools:
isNotEmpty
- Simply an inverse ofisEmpty
, for terse and clear code. Inlined so you never worry about this bloating your executablenonEmptyOrNil
- Iff the collection is empty, this returns nil, otherwise it returns the collection. Useful for leveraging APIs whose behavior changes based on a value's optionality, such asguard
or??
onlyFirst(_:)
- Returns only the firstk
values of the collection. This usesdropLast(_:)
under the hood for performance.onlyLast(_:)
- Returns only the lastk
values of the collection. This usesdropFirst(_:)
under the hood for performance.+
- Range-replaceable collections have this to concatenate two collections together. This lets you simply concatenate one element to the end of an existing range-replaceable collection.+=
- The same as+
, but mutates the left-hand-side, rather than returning a new collection
2.1.0 - Introduced `.sequentialPairs`
This allows you to lazily consume any sequence as a series of its ordered pairs
2.0.0 - Reworked `everyPairWithoutDuplicates` and `mapEveryPair`
These no longer return a generic collection, but instead always return the same kind of lazy version of the current collection. Also added variants to everyPairWithoutDuplicates
which allow you to use them when the collection elements aren't Equatable
!
1.1.0 - `withoutDuplicates`
Added withoutDuplicates()
to filter out duplicate elements
1.0.0 - MVP
Starting with something simple: everyPair
and CollectionWhichCanBeEmpty