<commit_before>//
//  Promise.swift
//  Futuristics
//
//  Created by <NAME> on 03/08/2015.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation


open class Promise<T> {
    open let future = Future<T>()
    
    open var isPending: Bool  {
        if case .pending = future.state {
            return true
        }
        return false
    }
    
    public init() { }

    @discardableResult
    open func reject(_ error: Error) -> Future<T> {
        self.future.reject(error)
        return self.future
    }

    @discardableResult
    open func fulfill(_ value: T) -> Future<T> {
        self.future.fulfill(value)
        return self.future
    }

    open func resolveWith(_ f: (Void) throws -> T) {
        future.resolveWith(f)
    }
    
    /**
    Experimental - use with defer
    */
    open func ensureResolution() {
        assert(!self.isPending, "Promise was not resolved")
    }
}<commit_msg>proper func access modifiers<commit_after>//
//  Promise.swift
//  Futuristics
//
//  Created by <NAME> on 03/08/2015.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation


public class Promise<T> {

    public let future = Future<T>()
    
    public var isPending: Bool  {
        if case .pending = future.state {
            return true
        }
        return false
    }
    
    public init() { }

    @discardableResult
    public func reject(_ error: Error) -> Future<T> {
        self.future.reject(error)
        return self.future
    }

    @discardableResult
    public func fulfill(_ value: T) -> Future<T> {
        self.future.fulfill(value)
        return self.future
    }

    public func resolveWith(_ f: (Void) throws -> T) {
        future.resolveWith(f)
    }
    
    /**
    Experimental - use with defer
    */
    public func ensureResolution() {
        assert(!self.isPending, "Promise was not resolved")
    }
}
{'fraction_non_alphanumeric': 0.11392405063291139, 'fraction_numerical': 0.012658227848101266, 'mean_word_length': 1.9319938176197837, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, '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': '1416112', 'n_tokens_mistral': 603, 'n_tokens_neox': 571, 'n_words': 159}