vargate.js
function assignNestedPropertyListener(object, key, fullKey, context) {
            /** @type {Array} */
            const pathArray = key.split('.');
            if (pathArray.length === 1 && typeof key === 'string') {
                // Sanitize `key`
                key = key.replace(/[^\w$]/g, '');
                if (object[key] === undefined) {
                    // Create a watch on the property, and run once it's been set
                    Object.defineProperty(object, key, {
                        /** @type {boolean} */
                        'configurable': true,
                        /** @param {*} val */
                        'set': function(val) {
                            delete object[key];
                            object[key] = val;
                            context.set(fullKey, object);
                        }
                    });
                } else {
                    // The property's already been defined. Trigger it.
                    context.set(fullKey, object);
                }
            } else {
                assignNestedPropertyListener(object[pathArray[0]], pathArray.splice(1).join('.'), fullKey, context);
            }
        }
function assignNestedPropertyListener(object, key, fullKey, context) {
            /** @type {Array} */
            const pathArray = key.split('.');
            if (pathArray.length === 1 && typeof key === 'string') {
                // Sanitize `key`
                key = key.replace(/[^\w$]/g, '');
                if (object[key] === undefined) {
                    // Create a watch on the property, and run once it's been set
                    Object.defineProperty(object, key, {
                        /** @type {boolean} */
                        'configurable': true,
                        /** @param {*} val */
                        'set': function(val) {
                            delete object[key];
                            object[key] = val;
                            context.set(fullKey, object);
                        }
                    });
                } else {
                    // The property's already been defined. Trigger it.
                    context.set(fullKey, object);
                }
            } else {
                assignNestedPropertyListener(object[pathArray[0]], pathArray.splice(1).join('.'), fullKey, context);
            }
        }
function assignNestedPropertyListener ( object , key , fullKey , context ) { /** @type {Array} */ const pathArray = key . split ( '.' ) ; if ( pathArray . length === 1 && typeof key === 'string' ) { // Sanitize `key` key = key . replace ( / [^\w$] / g , '' ) ; if ( object [ key ] === undefined ) { // Create a watch on the property, and run once it's been set Object . defineProperty ( object , key , { /** @type {boolean} */ 'configurable' : true , /** @param {*} val */ 'set' : function ( val ) { delete object [ key ] ; object [ key ] = val ; context . set ( fullKey , object ) ; } } ) ; } else { // The property's already been defined. Trigger it. context . set ( fullKey , object ) ; } } else { assignNestedPropertyListener ( object [ pathArray [ 0 ] ] , pathArray . splice ( 1 ) . join ( '.' ) , fullKey , context ) ; } }
Listens and marks when a property is available
@param {Object} object
@param {string} key
@param {string} fullKey
@param {VarGate} context
Listens and marks when a property is available