<commit_before>
import $ = require('zepto');
import Q = require('q');

//six seconds? maybe a little bit too much?
//this is the timeout for loading the resources
var DEFAULT_TIMEOUT = 6000;

class ResourceLoader {
    
    private static _instance;
    
    constructor() {
      if (ResourceLoader._instance){
            throw new Error("Error: Instantiation failed: Use ResourceLoader.getInstance() instead of new.");
        }
        ResourceLoader._instance = this;    
    }
    
    public static getInstance(): ResourceLoader {
        if (ResourceLoader._instance == null) {
            ResourceLoader._instance = new ResourceLoader();
        }
        return ResourceLoader._instance;
    }
    
    
    public loadJSONFile(jsonFile: String) {
        var deferred = Q.defer();
        $.ajax({
            type: 'GET',
            url: jsonFile,
            dataType: 'json',
            timeout: DEFAULT_TIMEOUT,
            context: this,
            success: deferred.resolve,
            error: function(xhr, type){
                deferred.reject(new Error("Failed to load File!"));
            }
        });
        return deferred.promise;
    }
    
    
    public loadTextFile(textFile: String) {
    }
};


export = ResourceLoader;<commit_msg>worked on #17. Complete docblocks for the engine.util namespace<commit_after>
import $ = require('zepto');
import Q = require('q');

//six seconds? maybe a little bit too much?
//this is the timeout for loading the resources
var DEFAULT_TIMEOUT = 6000;

/**
 * The ResourceLoader helps you loading various resources with promises.
 *
 * Warning: SINGLETON! Use `getInstance()` instead of `new`
 *
 * @namespace engine.util
 * @class ResourceLoader
 */
class ResourceLoader {
    
    private static _instance;

    /**
     * Warning: SINGLETON. Don't use this constructor, use `getInstance()` instead
     *
     * @method __constructor
     */
    constructor() {
      if (ResourceLoader._instance){
            throw new Error("Error: Instantiation failed: Use ResourceLoader.getInstance() instead of new.");
        }
        ResourceLoader._instance = this;    
    }

    /**
     * Singleton method for getting the instance for this `ResourceLoader`
     *
     * @method getInstance
     * @static
     * @returns {engine.util.ResourceLoader} the singleton instance of this `ResourceLoader`
     */
    public static getInstance(): ResourceLoader {
        if (ResourceLoader._instance == null) {
            ResourceLoader._instance = new ResourceLoader();
        }
        return ResourceLoader._instance;
    }

    /**
     * Loads and parses a json file and returns a promise to it
     *
     * @param jsonFile the file to load
     * @returns {Promise(*)} promise for the parsed JSON Data
     */
    public loadJSONFile(jsonFile: string) {
        var deferred = Q.defer();
        $.ajax({
            type: 'GET',
            url: jsonFile,
            dataType: 'json',
            timeout: DEFAULT_TIMEOUT,
            context: this,
            success: deferred.resolve,
            error: function(xhr, type){
                deferred.reject(new Error("Failed to load File!"));
            }
        });
        return deferred.promise;
    }

};


export = ResourceLoader;
{'fraction_non_alphanumeric': 0.10131619222528314, 'fraction_numerical': 0.003060912151821243, 'mean_word_length': 2.178988326848249, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '950002', 'n_tokens_mistral': 863, 'n_tokens_neox': 835, 'n_words': 263}