function MiniManager(obj) {
    if (typeof obj !== 'object' || obj == null) throw new TypeError('Expected object, got ' + typeof obj);

    var isEnabled = false, self = this, instance = {};
    Object.defineProperty(this, 'enabled', {
        get: function () {
            return isEnabled;
        },
        set: function (val) {
            isEnabled = !!val;
        }
    });

    function getProp(prop) {
        var val = obj[prop], getFunc;
        if (typeof val === 'function') {
            getFunc = function () {
                return function () {
                    // If the context is the instance, then use the base object to
                    // prevent weird things happening
                    var ctx = this === instance ? obj : this;
                    if (isEnabled) return obj[prop].apply(ctx, arguments);
                }
            };
        } else getFunc = function () {
            return obj[prop];
        };

        return {
            configurable: true,
            enumerable: obj.hasOwnProperty(prop),
            get: getFunc,
            set: function (val) {
                if (isEnabled) obj[prop] = val;
            }
        };
    }

    var defines = {};
    for (var prop in obj) {
        // We want to iterate over *all* properties (including prototypes)
        // so we don't want the .hasOwnProperty check here
        // if (!obj.hasOwnProperty(prop)) continue;
        defines[prop] = getProp(prop);
    }

    Object.defineProperties(instance, defines);
    Object.defineProperty(instance, '__enabled', {
        get: function () {
            return isEnabled;
        }
    });

    this.instance = instance;
}
/**
 * MiniManager
 *
 * The tiny instance manager
 *
 * @param {Object} obj The object to wrap around
 */
MiniManager
The tiny instance manager

@param {Object} obj The object to wrap around
MiniManager The tiny instance manager @param { Object } obj The object to wrap around
function MiniManager(obj) {
    if (typeof obj !== 'object' || obj == null) throw new TypeError('Expected object, got ' + typeof obj);
    var isEnabled = false, self = this, instance = {};
    Object.defineProperty(this, 'enabled', {
        get: function () {
            return isEnabled;
        },
        set: function (val) {
            isEnabled = !!val;
        }
    });
    function getProp(prop) {
        var val = obj[prop], getFunc;
        if (typeof val === 'function') {
            getFunc = function () {
                return function () {
                    var ctx = this === instance ? obj : this;
                    if (isEnabled) return obj[prop].apply(ctx, arguments);
                }
            };
        } else getFunc = function () {
            return obj[prop];
        };
        return {
            configurable: true,
            enumerable: obj.hasOwnProperty(prop),
            get: getFunc,
            set: function (val) {
                if (isEnabled) obj[prop] = val;
            }
        };
    }
    var defines = {};
    for (var prop in obj) {
        defines[prop] = getProp(prop);
    }
    Object.defineProperties(instance, defines);
    Object.defineProperty(instance, '__enabled', {
        get: function () {
            return isEnabled;
        }
    });
    this.instance = instance;
}
function MiniManager ( obj ) { if ( typeof obj !== 'object' || obj == null ) throw new TypeError ( 'Expected object, got ' + typeof obj ) ; var isEnabled = false , self = this , instance = { } ; Object . defineProperty ( this , 'enabled' , { get : function ( ) { return isEnabled ; } , set : function ( val ) { isEnabled = ! ! val ; } } ) ; function getProp ( prop ) { var val = obj [ prop ] , getFunc ; if ( typeof val === 'function' ) { getFunc = function ( ) { return function ( ) { var ctx = this === instance ? obj : this ; if ( isEnabled ) return obj [ prop ] . apply ( ctx , arguments ) ; } } ; } else getFunc = function ( ) { return obj [ prop ] ; } ; return { configurable : true , enumerable : obj . hasOwnProperty ( prop ) , get : getFunc , set : function ( val ) { if ( isEnabled ) obj [ prop ] = val ; } } ; } var defines = { } ; for ( var prop in obj ) { defines [ prop ] = getProp ( prop ) ; } Object . defineProperties ( instance , defines ) ; Object . defineProperty ( instance , '__enabled' , { get : function ( ) { return isEnabled ; } } ) ; this . instance = instance ; }
MiniManager
 The tiny instance manager
MiniManager The tiny instance manager
// If the context is the instance, then use the base object to // prevent weird things happening // We want to iterate over *all* properties (including prototypes) // so we don't want the .hasOwnProperty check here // if (!obj.hasOwnProperty(prop)) continue;