How to access 'private functions' in a singleton from another object inside it.

Posted by Cedric Dugas on Stack Overflow See other posts from Stack Overflow or by Cedric Dugas
Published on 2010-05-10T02:27:20Z Indexed on 2010/05/10 2:38 UTC
Read the original article Hit count: 216

Filed under:
|
|

I am currently trying to create a test suite for my javascript apps. My problem is that, it seems I cannot get access to init() from my utils object, as you can see below:

I have my app that follow a singleton pattern:

var appModal = function () {
    var utils = Object.create(moduleUtils);
     function init(caller, options ) {
    }
}();

My test suite is in moduleUtils, this is a object literal converted to a prototype

moduleUtils.debug = {
    addSlideTest : function(){
        /* this function cannot fire init() from appModal */
}}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about prototype