<commit_before>//  Copyright (c) 2015-2016 <NAME>. See LICENSE file for more info

/// May be applied to any method that takes no arguments and returns none. The resulting closure can accept an argument which will simply be ignored (useful in cases like `NSNotificationCenter` when you don't care about the `notification` argument), or the type may also represent `Void`, meaning no input arguments are necessary.
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, nothing happens. If owner is not nil, calls `f(owner)()`
#if swift(>=3.0)
public func weakify <T: AnyObject, U>(_ owner: T, _ f: (T) -> () -> Void) -> (U) -> Void {
    return { [weak owner] _ in
        if let this = owner {
            f(this)()
        }
    }
}
#else
public func weakify <T: AnyObject, U>(owner: T, _ f: (T) -> () -> Void) -> (U) -> Void {
    return { [weak owner] _ in
        if let this = owner {
            f(this)()
        }
    }
}
#endif

/// May be applied to any method that takes no arguments and returns none or throws. The resulting closure can accept an argument which will simply be ignored (useful in cases like `NSNotificationCenter` when you don't care about the `notification` argument), or the type may also represent `Void`, meaning no input arguments are necessary.
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, nothing happens. If owner is not nil, calls `try f(owner)()`
#if swift(>=3.0)
public func weakify <T: AnyObject, U>(_ owner: T, _ f: (T) -> () throws -> Void) -> (U) throws -> Void {
    return { [weak owner] _ in
        if let this = owner {
            try f(this)()
        }
    }
}
#else
public func weakify <T: AnyObject, U>(owner: T, _ f: (T) -> () throws -> Void) -> (U) throws -> Void {
    return { [weak owner] _ in
        if let this = owner {
            try f(this)()
        }
    }
}
#endif

/// May be applied to a method that accepts an argument and returns none, which the resulting closure mirrors.
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, nothing happens. If owner is not nil, calls `f(owner)($0)`
#if swift(>=3.0)
public func weakify <T: AnyObject, U>(_ owner: T, _ f: (T) -> (U) -> Void) -> (U) -> Void {
    return { [weak owner] obj in
        if let this = owner {
            f(this)(obj)
        }
    }
}
#else
public func weakify <T: AnyObject, U>(owner: T, _ f: (T) -> (U) -> Void) -> (U) -> Void {
    return { [weak owner] obj in
        if let this = owner {
            f(this)(obj)
        }
    }
}
#endif

/// May be applied to a method that accepts an argument and returns none or throws, which the resulting closure mirrors.
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, nothing happens. If owner is not nil, calls `try f(owner)($0)`
#if swift(>=3.0)
public func weakify <T: AnyObject, U>(_ owner: T, _ f: (T) -> (U) throws -> Void) -> (U) throws -> Void {
    return { [weak owner] obj in
        if let this = owner {
            try f(this)(obj)
        }
    }
}
#else
public func weakify <T: AnyObject, U>(owner: T, _ f: (T) -> (U) throws -> Void) -> (U) throws -> Void {
    return { [weak owner] obj in
        if let this = owner {
            try f(this)(obj)
        }
    }
}
#endif

/// May be applied to a function that accepts and returns something. The resulting closure must return optional, since if owner is deallocated before it is called there's nothing else it can return.
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, returns nil. If owner is not nil, returns `f(owner)($0)`
#if swift(>=3.0)
public func weakify <T: AnyObject, U, V>(_ owner: T, _ f: (T) -> (U) -> V) -> (U) -> V? {
    return { [weak owner] obj in
        if let this = owner {
            return f(this)(obj)
        } else {
            return nil
        }
    }
}
#else
public func weakify <T: AnyObject, U, V>(owner: T, _ f: (T) -> (U) -> V) -> (U) -> V? {
    return { [weak owner] obj in
        if let this = owner {
            return f(this)(obj)
        } else {
            return nil
        }
    }
}
#endif

/// May be applied to a function that accepts and returns something or throws. The resulting closure must return optional, since if owner is deallocated before it is called there's nothing else it can return.
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, returns nil. If owner is not nil, returns `f(owner)($0)`
#if swift(>=3.0)
public func weakify <T: AnyObject, U, V>(_ owner: T, _ f: (T) -> (U) throws -> V) -> (U) throws -> V? {
    return { [weak owner] obj in
        if let this = owner {
            return try f(this)(obj)
        } else {
            return nil
        }
    }
}
#else
public func weakify <T: AnyObject, U, V>(owner: T, _ f: (T) -> (U) throws -> V) -> (U) throws -> V? {
    return { [weak owner] obj in
        if let this = owner {
            return try f(this)(obj)
        } else {
            return nil
        }
    }
}
#endif

/// May be applied to a function that accepts an optional value. The resulting closure can have a completely different type for the input argument. If owner is not nil at call time, the argument to the resulting closure is conditionally cast from V to U with the as? operator, and the result of that is passed to the original function (which is why it must accept an optional, in case the cast fails).
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, nothing happens. If owner is not nil, returns `f(owner)($0 as? U)`
#if swift(>=3.0)
public func weakify <T: AnyObject, U, V>(_ owner: T, _ f: (T) -> (U?) -> Void) -> (V) -> Void {
    return { [weak owner] obj in
        if let this = owner {
            f(this)(obj as? U)
        }
    }
}
#else
public func weakify <T: AnyObject, U, V>(owner: T, _ f: (T) -> (U?) -> Void) -> (V) -> Void {
    return { [weak owner] obj in
        if let this = owner {
            f(this)(obj as? U)
        }
    }
}
#endif

/// May be applied to a function that accepts an optional value or throws. The resulting closure can have a completely different type for the input argument. If owner is not nil at call time, the argument to the resulting closure is conditionally cast from V to U with the as? operator, and the result of that is passed to the original function (which is why it must accept an optional, in case the cast fails).
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, nothing happens. If owner is not nil, returns `try f(owner)($0 as? U)`
#if swift(>=3.0)
public func weakify <T: AnyObject, U, V>(_ owner: T, _ f: (T) -> (U?) throws -> Void) -> (V) throws -> Void {
    return { [weak owner] obj in
        if let this = owner {
            try f(this)(obj as? U)
        }
    }
}
#else
public func weakify <T: AnyObject, U, V>(owner: T, _ f: (T) -> (U?) throws -> Void) -> (V) throws -> Void {<commit_msg>Added @escaping requirement for swift 3 Xcode b6<commit_after>//  Copyright (c) 2015-2016 <NAME>. See LICENSE file for more info

/// May be applied to any method that takes no arguments and returns none. The resulting closure can accept an argument which will simply be ignored (useful in cases like `NSNotificationCenter` when you don't care about the `notification` argument), or the type may also represent `Void`, meaning no input arguments are necessary.
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, nothing happens. If owner is not nil, calls `f(owner)()`
#if swift(>=3.0)
public func weakify <T: AnyObject, U>(_ owner: T, _ f: @escaping (T) -> () -> Void) -> (U) -> Void {
    return { [weak owner] _ in
        if let this = owner {
            f(this)()
        }
    }
}
#else
public func weakify <T: AnyObject, U>(owner: T, _ f: (T) -> () -> Void) -> (U) -> Void {
    return { [weak owner] _ in
        if let this = owner {
            f(this)()
        }
    }
}
#endif

/// May be applied to any method that takes no arguments and returns none or throws. The resulting closure can accept an argument which will simply be ignored (useful in cases like `NSNotificationCenter` when you don't care about the `notification` argument), or the type may also represent `Void`, meaning no input arguments are necessary.
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, nothing happens. If owner is not nil, calls `try f(owner)()`
#if swift(>=3.0)
public func weakify <T: AnyObject, U>(_ owner: T, _ f: @escaping (T) -> () throws -> Void) -> (U) throws -> Void {
    return { [weak owner] _ in
        if let this = owner {
            try f(this)()
        }
    }
}
#else
public func weakify <T: AnyObject, U>(owner: T, _ f: (T) -> () throws -> Void) -> (U) throws -> Void {
    return { [weak owner] _ in
        if let this = owner {
            try f(this)()
        }
    }
}
#endif

/// May be applied to a method that accepts an argument and returns none, which the resulting closure mirrors.
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, nothing happens. If owner is not nil, calls `f(owner)($0)`
#if swift(>=3.0)
public func weakify <T: AnyObject, U>(_ owner: T, _ f: @escaping (T) -> (U) -> Void) -> (U) -> Void {
    return { [weak owner] obj in
        if let this = owner {
            f(this)(obj)
        }
    }
}
#else
public func weakify <T: AnyObject, U>(owner: T, _ f: (T) -> (U) -> Void) -> (U) -> Void {
    return { [weak owner] obj in
        if let this = owner {
            f(this)(obj)
        }
    }
}
#endif

/// May be applied to a method that accepts an argument and returns none or throws, which the resulting closure mirrors.
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, nothing happens. If owner is not nil, calls `try f(owner)($0)`
#if swift(>=3.0)
public func weakify <T: AnyObject, U>(_ owner: T, _ f: @escaping (T) -> (U) throws -> Void) -> (U) throws -> Void {
    return { [weak owner] obj in
        if let this = owner {
            try f(this)(obj)
        }
    }
}
#else
public func weakify <T: AnyObject, U>(owner: T, _ f: (T) -> (U) throws -> Void) -> (U) throws -> Void {
    return { [weak owner] obj in
        if let this = owner {
            try f(this)(obj)
        }
    }
}
#endif

/// May be applied to a function that accepts and returns something. The resulting closure must return optional, since if owner is deallocated before it is called there's nothing else it can return.
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, returns nil. If owner is not nil, returns `f(owner)($0)`
#if swift(>=3.0)
public func weakify <T: AnyObject, U, V>(_ owner: T, _ f: @escaping (T) -> (U) -> V) -> (U) -> V? {
    return { [weak owner] obj in
        if let this = owner {
            return f(this)(obj)
        } else {
            return nil
        }
    }
}
#else
public func weakify <T: AnyObject, U, V>(owner: T, _ f: (T) -> (U) -> V) -> (U) -> V? {
    return { [weak owner] obj in
        if let this = owner {
            return f(this)(obj)
        } else {
            return nil
        }
    }
}
#endif

/// May be applied to a function that accepts and returns something or throws. The resulting closure must return optional, since if owner is deallocated before it is called there's nothing else it can return.
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, returns nil. If owner is not nil, returns `f(owner)($0)`
#if swift(>=3.0)
public func weakify <T: AnyObject, U, V>(_ owner: T, _ f: @escaping (T) -> (U) throws -> V) -> (U) throws -> V? {
    return { [weak owner] obj in
        if let this = owner {
            return try f(this)(obj)
        } else {
            return nil
        }
    }
}
#else
public func weakify <T: AnyObject, U, V>(owner: T, _ f: (T) -> (U) throws -> V) -> (U) throws -> V? {
    return { [weak owner] obj in
        if let this = owner {
            return try f(this)(obj)
        } else {
            return nil
        }
    }
}
#endif

/// May be applied to a function that accepts an optional value. The resulting closure can have a completely different type for the input argument. If owner is not nil at call time, the argument to the resulting closure is conditionally cast from V to U with the as? operator, and the result of that is passed to the original function (which is why it must accept an optional, in case the cast fails).
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, nothing happens. If owner is not nil, returns `f(owner)($0 as? U)`
#if swift(>=3.0)
public func weakify <T: AnyObject, U, V>(_ owner: T, _ f: @escaping (T) -> (U?) -> Void) -> (V) -> Void {
    return { [weak owner] obj in
        if let this = owner {
            f(this)(obj as? U)
        }
    }
}
#else
public func weakify <T: AnyObject, U, V>(owner: T, _ f: (T) -> (U?) -> Void) -> (V) -> Void {
    return { [weak owner] obj in
        if let this = owner {
            f(this)(obj as? U)
        }
    }
}
#endif

/// May be applied to a function that accepts an optional value or throws. The resulting closure can have a completely different type for the input argument. If owner is not nil at call time, the argument to the resulting closure is conditionally cast from V to U with the as? operator, and the result of that is passed to the original function (which is why it must accept an optional, in case the cast fails).
///
/// - parameter owner: The object to weakly apply to the given curried function or method
/// - parameter f:     The function/method to weakly apply owner to as the first argument
///
/// - returns: A function where owner is weakly applied to the given function f. If owner is nil, nothing happens. If owner is not nil, returns `try f(owner)($0 as? U)`
#if swift(>=3.0)
public func weakify <T: AnyObject, U, V>(_ owner: T, _ f: @escaping (T) -> (U?) throws -> Void) -> (V) throws -> Void {
    return { [weak owner] obj in
        if let this = owner {
            try f(this)(obj as? U)
        }
    }
}
#else
public func weakify <T: AnyObject, U, V>(owner: T, _ f: (T) -> (U?) throws -> Void) -> (V) throws -> Void {
{'fraction_non_alphanumeric': 0.11685017582290887, 'fraction_numerical': 0.0035741050325704734, 'mean_word_length': 2.5174371451743713, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 181, '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': '3702541', 'n_tokens_mistral': 5104, 'n_tokens_neox': 4971, 'n_words': 2495}