<commit_before>//
//  Alamofire+Synchronous.swift
//  Alamofire-Synchronous
//
//  Created by <NAME> on 15/11/8.
//  Copyright © 2015年 <NAME>. All rights reserved.
//

import Foundation
import Alamofire

extension DataRequest {
    
    
    /**
     Wait for the request to finish then return the response value.
     
     - returns: The response.
     */
    public func response() -> (request: NSURLRequest?, response: HTTPURLResponse?, data: NSData?, error: NSError?) {
        
        let semaphore = DispatchSemaphore(value: 0)
        var result: (request: NSURLRequest?, response: HTTPURLResponse?, data: NSData?, error: NSError?)!

        self.response(queue: DispatchQueue.global(qos: .default)){ response in
            
            result = (
                request: request,
                response: response,
                data: data,
                error: error
            )
            
            semaphore.signal()
        }
        
        _ = semaphore.wait(timeout: DispatchTime.distantFuture)
        
        return result
    }
    
    
    /**
     Wait for the request to finish then return the response value.
     
     - returns: The response.
     */
    public func responseData() -> DataResponse<Data> {
        
        let semaphore = DispatchSemaphore(value: 0)
        
        var result: DataResponse<Data>!
        
        self.responseData(queue: DispatchQueue.global(qos: .default)) { response in
            
            result = response
            semaphore.signal()
            
        }
        
        _ = semaphore.wait(timeout: DispatchTime.distantFuture)
        
        return result
    }
    
    
    /**
     Wait for the request to finish then return the response value.
     
     - parameter options: The JSON serialization reading options. `.AllowFragments` by default.
     
     - returns: The response.
     */
    public func responseJSON(options: JSONSerialization.ReadingOptions = .allowFragments) -> DataResponse<Any> {
        
        let semaphore = DispatchSemaphore(value: 0)
        
        var result: DataResponse<Any>!
        
        self.responseJSON(queue: DispatchQueue.global(qos: .default), options: options) { response in
            
            result = response
            semaphore.signal()
            
        }
        
        _ = semaphore.wait(timeout: DispatchTime.distantFuture)
        
        return result
    }
    
    
    /**
     Wait for the request to finish then return the response value.
     
     - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the
     server response, falling back to the default HTTP default character set,
     ISO-8859-1.
     
     - returns: The response.
     */
    public func responseString(encoding: String.Encoding? = nil) -> DataResponse<String> {
        
        let semaphore = DispatchSemaphore(value: 0)
        
        var result: DataResponse<String>!
        self.responseString(queue: DispatchQueue.global(qos: .default), encoding: encoding){ response in
            
            result = response
            semaphore.signal()
            
        }
        
        _ = semaphore.wait(timeout: DispatchTime.distantFuture)
        
        return result
    }
    
    
    /**
     Wait for the request to finish then return the response value.
     
     - parameter options: The property list reading options. `0` by default.
     
     - returns: The response.
     */
    public func responsePropertyList(options: PropertyListSerialization.ReadOptions = PropertyListSerialization.ReadOptions()) -> DataResponse<Any> {
        
        let semaphore = DispatchSemaphore(value: 0)
        
        var result: DataResponse<Any>!
        
        self.responsePropertyList(queue: DispatchQueue.global(qos: .default), options: options) { response in
            
            result = response
            semaphore.signal()
            
        }
        
        _ = semaphore.wait(timeout: DispatchTime.distantFuture)
        
        return result
    }
}
<commit_msg>Swift 3 and Alamofire 4.0 Compatibility<commit_after>//
//  Alamofire+Synchronous.swift
//  Alamofire-Synchronous
//
//  Created by <NAME> on 15/11/8.
//  Copyright © 2015年 <NAME>. All rights reserved.
//

import Foundation
import Alamofire

extension DataRequest {
    
    
    /**
     Wait for the request to finish then return the response value.
     
     - returns: The response.
     */
    public func response() -> DefaultDataResponse {
        
        let semaphore = DispatchSemaphore(value: 0)
        var result: DefaultDataResponse!

        self.response(queue: DispatchQueue.global(qos: .default)){ response in
            
            result = response
            
            semaphore.signal()
        }
        
        _ = semaphore.wait(timeout: DispatchTime.distantFuture)
        
        return result
    }
    
    
    /**
     Wait for the request to finish then return the response value.
     
     - returns: The response.
     */
    public func responseData() -> DataResponse<Data> {
        
        let semaphore = DispatchSemaphore(value: 0)
        
        var result: DataResponse<Data>!
        
        self.responseData(queue: DispatchQueue.global(qos: .default)) { response in
            
            result = response
            semaphore.signal()
            
        }
        
        _ = semaphore.wait(timeout: DispatchTime.distantFuture)
        
        return result
    }
    
    
    /**
     Wait for the request to finish then return the response value.
     
     - parameter options: The JSON serialization reading options. `.AllowFragments` by default.
     
     - returns: The response.
     */
    public func responseJSON(options: JSONSerialization.ReadingOptions = .allowFragments) -> DataResponse<Any> {
        
        let semaphore = DispatchSemaphore(value: 0)
        
        var result: DataResponse<Any>!
        
        self.responseJSON(queue: DispatchQueue.global(qos: .default), options: options) { response in
            
            result = response
            semaphore.signal()
            
        }
        
        _ = semaphore.wait(timeout: DispatchTime.distantFuture)
        
        return result
    }
    
    
    /**
     Wait for the request to finish then return the response value.
     
     - parameter encoding: The string encoding. If `nil`, the string encoding will be determined from the
     server response, falling back to the default HTTP default character set,
     ISO-8859-1.
     
     - returns: The response.
     */
    public func responseString(encoding: String.Encoding? = nil) -> DataResponse<String> {
        
        let semaphore = DispatchSemaphore(value: 0)
        
        var result: DataResponse<String>!
        self.responseString(queue: DispatchQueue.global(qos: .default), encoding: encoding){ response in
            
            result = response
            semaphore.signal()
            
        }
        
        _ = semaphore.wait(timeout: DispatchTime.distantFuture)
        
        return result
    }
    
    
    /**
     Wait for the request to finish then return the response value.
     
     - parameter options: The property list reading options. `0` by default.
     
     - returns: The response.
     */
    public func responsePropertyList(options: PropertyListSerialization.ReadOptions = PropertyListSerialization.ReadOptions()) -> DataResponse<Any> {
        
        let semaphore = DispatchSemaphore(value: 0)
        
        var result: DataResponse<Any>!
        
        self.responsePropertyList(queue: DispatchQueue.global(qos: .default), options: options) { response in
            
            result = response
            semaphore.signal()
            
        }
        
        _ = semaphore.wait(timeout: DispatchTime.distantFuture)
        
        return result
    }
}

{'fraction_non_alphanumeric': 0.08050314465408805, 'fraction_numerical': 0.005408805031446541, 'mean_word_length': 1.7588480222068008, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 33, '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': '953138', 'n_tokens_mistral': 2128, 'n_tokens_neox': 2098, 'n_words': 556}