<commit_before># Do.this

Do.this is a Swift 3 quick async helper inspired by node.js Async

### Usage:

```swift
Do.this { this in
    
    //do stuff
    this.done(result: someResult)
    
}.then (name: "result step") { this in
    
    //do more stuff
	
	//every this has an index property and an optional name property
	//which can be useful for debugging and error handling
	print("this: \(this.name ?? String(this.index))")
		
    //you can also access the previous result if needed:
    print("previousResult: \(this.previousResult)")
	
	//if you're doing anything async, don't forget to call done()	
	DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
     	
		//async stuff
		
	    //btw, result is optional
	    this.done()
    }    
    
}.then { this in
    
    //if an error happened, pass it in the done callback (you can still pass a result)
    //if you pass an error, the chain will break (see catch and finally below)
    let error = SomeError.bummer
    this.done(result: someResult, error: error)
    
}.then (on: DispatchQueue.global(qos: .background)) { this in
    
    //this will execute in a background queue
    print("on: \(DispatchQueue.currentLabel)")
    this.done(result: someResult)
    
}.then (on: .main) { this in
    
    //this will be execute in the main queue
    //if you dont specify a queue, this will be executed on the current (last used) queue
    print("on: \(DispatchQueue.currentLabel)")
    this.done(result: someResult)
    
}.catch { this in
    
    //catch an error, this will point to the step that triggered the error	
    print("catched error: \(this.error) from \(this.name ?? String(this.index))")
    
}.finally { this in
    
    //finally - will execute even if an error happened
    print("finally (previousResult: \(this.previousResult))")
    exp.fulfill()
}
```

## Requirements

Swift 3

## Author

<NAME>, <EMAIL>
<commit_msg>added cocoapod install instructions<commit_after># Do.this

Do.this is a Swift 3 quick async helper inspired by node.js Async

### Usage:

```swift
Do.this { this in
    
    //do stuff
    this.done(result: someResult)
    
}.then (name: "result step") { this in
    
    //do more stuff
	
	//every this has an index property and an optional name property
	//which can be useful for debugging and error handling
	print("this: \(this.name ?? String(this.index))")
		
    //you can also access the previous result if needed:
    print("previousResult: \(this.previousResult)")
	
	//if you're doing anything async, don't forget to call done()	
	DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
     	
		//async stuff
		
	    //btw, result is optional
	    this.done()
    }    
    
}.then { this in
    
    //if an error happened, pass it in the done callback (you can still pass a result)
    //if you pass an error, the chain will break (see catch and finally below)
    let error = SomeError.bummer
    this.done(result: someResult, error: error)
    
}.then (on: DispatchQueue.global(qos: .background)) { this in
    
    //this will execute in a background queue
    print("on: \(DispatchQueue.currentLabel)")
    this.done(result: someResult)
    
}.then (on: .main) { this in
    
    //this will be execute in the main queue
    //if you dont specify a queue, this will be executed on the current (last used) queue
    print("on: \(DispatchQueue.currentLabel)")
    this.done(result: someResult)
    
}.catch { this in
    
    //catch an error, this will point to the step that triggered the error	
    print("catched error: \(this.error) from \(this.name ?? String(this.index))")
    
}.finally { this in
    
    //finally - will execute even if an error happened
    print("finally (previousResult: \(this.previousResult))")
    exp.fulfill()
}
```

## Requirements

Swift 3

## Installation

Do.this is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:

```ruby
pod "Do.this"
```

## Author

<NAME>

{'fraction_non_alphanumeric': 0.11507537688442211, 'fraction_numerical': 0.001507537688442211, 'mean_word_length': 2.7914285714285714, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5571391', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1187, 'n_words': 460}