<commit_before>import { Meta, get, set } from '../../core';
import { Application, singleton } from '../../runtime';
import { assert } from '../../debug';


@singleton
export class Mojito {
    
    private static GLOBAL_NAMESPACE = 'Mojito';
    
    constructor() {
        
        let instance:Mojito = get(self, Mojito.GLOBAL_NAMESPACE);
        if (!instance) {
            instance = this;
            set(self, Mojito.GLOBAL_NAMESPACE, instance);
        }
        
    }
    
    registerApplication(application: Application): Application {
        assert(arguments.length === 1, 'registerApplication must be called with one argument: an application instance');
        assert(application instanceof Application, 'The argument provided to the registerApplication method must be an application instance', TypeError);
        
        return Meta.peek(this).setProperty('applications', application.name, application);
    }
    
    getApplication(applicationName: string): Application {
        assert(arguments.length === 1, 'getApplication must be called with one argument: an application name');
        assert(typeof applicationName === 'string', 'The applicationName provided to the getApplication method must be a string', TypeError);
        
        return Meta.peek(this).getProperty('applications', applicationName);
    }
    
    getApplications() {
       return Meta.peek(this).getMember('applications');
    }
    
    static getInstance():Mojito {
        return get(Mojito, 'instance');
    }
}<commit_msg>singleton application<commit_after>import { Meta, get, set } from '../../core';
import { Application, singleton } from '../../runtime';
import { assert } from '../../debug';

export class Mojito {
    
    private static GLOBAL_NAMESPACE = 'Mojito';

    constructor() {
        let instance: Mojito = get(self, Mojito.GLOBAL_NAMESPACE);
        if (!instance) {
            instance = this;
            set(self, Mojito.GLOBAL_NAMESPACE, instance);
        }
    }

    registerApplication(application: Application): Application {
        assert(arguments.length === 1, 'registerApplication must be called with one argument: an application instance');
        assert(application instanceof Application, 'The argument provided to the registerApplication method must be an application instance', TypeError);

        return Meta.peek(this).setProperty('applications', application.name, application);
    }

    getApplication(applicationName: string): Application {
        assert(arguments.length === 1, 'getApplication must be called with one argument: an application name');
        assert(typeof applicationName === 'string', 'The applicationName provided to the getApplication method must be a string', TypeError);

        return Meta.peek(this).getProperty('applications', applicationName);
    }

    getApplications() {
        return Meta.peek(this).getMember('applications');
    }

    static getInstance(): Mojito {
        debugger;
        if (!get(Mojito, '_instance')) {
            
            let instance = new Mojito();
            Object.defineProperty(Mojito, '_instance', {
                writable: false,
                configurable: false,
                enumerable: false,
                value: instance
            });
        }
        return get(Mojito, 'instance');
    }
}
{'fraction_non_alphanumeric': 0.11054523666866387, 'fraction_numerical': 0.0011983223487118035, 'mean_word_length': 2.7686230248306996, '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': '5910388', 'n_tokens_mistral': 827, 'n_tokens_neox': 825, 'n_words': 242}