function singa(context = {}) {
    let instance;
    let factory;
    if (context.factory) {
        factory = context.factory;
    }
    return {
        use: ()=>{
            if (typeof instance !== 'undefined') {
                return instance;
            }
            if (typeof factory !== 'undefined') {
                instance = factory();
                return instance;
            }
            throw new Error(`The ${context.name || 'singleton'} instance is not defined.`);
        },
        set: (input)=>{
            instance = input;
        },
        setFactory: (input)=>{
            factory = input;
        },
        has: ()=>typeof instance !== 'undefined',
        hasFactory: ()=>typeof factory !== 'undefined',
        reset: ()=>{
            instance = undefined;
        }
    };
}

export { singa };
//# sourceMappingURL=index.mjs.map
