swift-filter

2.0.0

roanutil/swift-filter

What's New

2.0.0

2022-12-31T02:51:36Z

What's Changed

  • Rename package and raise minimum swift version by @roanutil in #1

New Contributors

Full Changelog: 1.1.0...2.0.0

Filter

CI codecov

Filter is a library that makes it easy to model filters in state and then create predicates from that state.

Included Products

  • Filter
  • FilterClosure
  • FilterNSPredicate

Filter

Core library that supports filter modeling and protocols for predicates.

FilterClosure and FilterNSPredicate provide good examples of implementing the predicate protocols.

Example

let filter = ComparableFilter<Date>.andMulti([
    .greaterThanOrEqualTo(Date.distantPast),
    .equatable(.not(.equalTo(Date.now))),
    .lessThanOrEqualTo(Date.distantFuture)
])
let nsPredicate = NSPredicate.build(from: filter)
let closure = Closure.build(from: filter)
let dates: [Date] = (Int.zero...Int.max).map { Date(timeIntervalSince1970: Double($0)) }
let filteredByClosure = dates.filter(closure)
let filteredByNSPredicate = dates.filter { nsPredicate.evaluate(with: $0) }

FilterClosure

Implementations of strongly typed predicate protocols that produce closures for filtering

FilterNSPredicate

Implementation of type erased predicate protocols that produce NSPredicates.

Installation

Add Filter to your Xcode project with Swift Package Manager.

Use the https URL from this repository in the Xcode Swift Packages dialogue or package manifest.

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Jan 05 2023 08:13:32 GMT-0500 (GMT-05:00)