<commit_before>import es6Promise = require('es6-promise');
import Promise = es6Promise.Promise;
class PromiseQueue {
    
    private promise: Promise<any>;
    private initializer: (result: any) => any;
    
    constructor() {
        this.promise = new Promise(resolve => {
            this.initializer = resolve;    
        })
    }
    
    init<T>(val: Promise<T>):Promise<T>
    init<T>(val: T): Promise<T> {
        this.initializer(val);
        return this.promise;
    }
    
   
    then<T>(action: () => Promise<T>):Promise<T>
    then<T>(action: () => T): Promise<T>
    then(action: () => void): Promise<void> {
        return this.promise = this.promise.then(() => action());
    }
}

export = PromiseQueue;<commit_msg>allow reset in promise queue<commit_after>import es6Promise = require('es6-promise');
import Promise = es6Promise.Promise;
class PromiseQueue {
    
    private promise: Promise<any>;
    private initializer: (result: any) => any;
    private initialized: boolean = false;
    
    constructor() {
        this.promise = new Promise(resolve => {
            this.initializer = resolve;    
        })
    }
    
    init<T>(val: Promise<T>):Promise<T>
    init<T>(val: T): Promise<T> {
        if (this.initialized) {
            this.promise = Promise.cast(val);
        } else {
            this.initialized = true;
            this.initializer(val);
            return this.promise; 
        }
    }
    
    then<T>(action: () => Promise<T>):Promise<T>
    then<T>(action: () => T): Promise<T>
    then(action: () => void): Promise<void> {
        return this.promise = this.promise.then(() => action());
    }
}

export = PromiseQueue;
{'fraction_non_alphanumeric': 0.15453460620525059, 'fraction_numerical': 0.003579952267303103, 'mean_word_length': 2.4364754098360657, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 39, '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': '1525122', 'n_tokens_mistral': 521, 'n_tokens_neox': 520, 'n_words': 102}