Thrust is a multi-purpose library for Swift, used to make simple operations in the language more sane.
- Simplified array querying
- NSObject <-> Literal bridging
- Elegant Queue access
- Basic HTTP querying
- JSON conversion
- Random number generation
- Additional convenience operators
- Comprehensive Unit Test Coverage
- Complete Documentation
- iOS 7.0+ / Mac OS X 10.9+
- Xcode 6.0
animate(duration: NSTimeInterval, animations: () -> Void)
after(time: NSTimeInterval, block: () -> Void)
on(queue: Queue, block: () -> Void)
index(seq: Sequence, obj: Element) -> Int?
comp(seq: Sequence, comp: (Element, Element) -> Bool) -> Element?
max(seq: Sequence) -> Element?
min(seq: Sequence) -> Element?
clamp(val: Element, range: Range<Element>) -> Element
Array {
any: Element?
index(obj: Element) -> Int?
contains(obj: Element) -> Bool
remove(obj: Element)
pad(obj: Element toLength: Int)
perform(block: (Element) -> Void)
shuffle()
}
Dictionary {
any: Key?
anyByWeight: Key?
}
Range {
all: [Element]
contains(element: Element) -> Bool
intersection(range: Range<Element>) -> Range<Element>
intersects(range: Range<Element>) -> Bool
union(range: Range<Element>) -> Range<Element>
}
NSData {
hexlifiedDescription: String
string: String
}
NSDate {
components(calendarUnits: NSCalendarUnit) -> NSDateComponents
}
String {
length: Int
cString: [CChar]?
data: NSData?
hasContent: Bool
localized() -> String
replace(string: String with: String)
random() -> String
}
Int {
clamped(range: Range<Int>) -> Int
clampTo(range: Range<Int>)
random() -> Int
random(r: Range<Int>) -> Int
}
Double {
random() -> Double
normalized(sigma: Double, mean: Double) -> Double
}
UIApplication {
version: Version?
build: String?
}
[Element] -= [Element]
[Key: Value] += [Key: Value]
[Key: Value] -= [Key]
Double ** Double = Double
Double **= Double
Double ><= Double = Bool
Int ** Int = Int
Int **= Int
NSDate == NSDate = Bool
NSDate > NSDate = Bool
NSDate + NSTimeInterval = NSDate
NSDate - NSTimeInterval = NSDate
NSDate += NSTimeInterval
NSDate -= NSTimeInterval
NSDate - NSDate = NSTimeInterval
String ><= String = Bool
String * String = String
String *= String
String[Int] -> String
String[Range<Int>] -> String
"http://github.com/pcperini/Thrust" as NSURL
[CGPoint(x: 0, y: 0), CGPoint(x: 10, y: 10)] as UIBezierPath
"(\w+)" as Regex
"0.1.0" as Version
[
"user": [
"name": "Patrick Perini",
"id": "0000"
] as JSONDictionary
] as JSONDictionary
class HTTP {
struct Response {
requestURL: NSURL
requestBody: NSData
status: Int?
data: NSData?
string: String?
object: JSONContainer?
}
struct RequestBatch {
requestCount: Int
addGETRequest(url: NSURL)
addPUTRequest(url: NSURL)
addPOSTRequest(url: NSURL)
addDELETERequest(url: NSURL)
performRequests(block: ([Response]) -> Void)
}
class get(url: NSURL, block: ((Response) -> Void)?)
class get(url: NSURL) -> Response
class put(url: NSURL, block: ((Response) -> Void)?)
class put(url: NSURL) -> Response
class post(url: NSURL, block: ((Response) -> Void)?)
class post(url: NSURL) -> Response
class delete(url: NSURL, block: ((Response) -> Void)?)
class delete(url: NSURL) -> Response
}
struct Queue {
static main: Queue
static background: Queue
label: String?
}
struct Regex {
error: NSError?
doesMatch(string: String) -> Bool
hasMatch(string: String) -> Bool
matchedCaptureGroups(string: String) -> [[String]]
}
class IdentifiableObject: Hashable {
identifier: String
}
struct Distribution: CollectionType, Sliceable {
sum: Double
mean: Double
mode: Double
median: Double
max: Double
histogram() -> String
}
Thrust is released under the MIT license. See LICENSE for details.
Mattt Thompson, for the README structure. Zachary Waldowski and Alexsander Akers for feedback.