lib/util.js
function defineLinkedProperty(obj, prop, srcProp, readOnly) {
    let propName, srcKey;
    if (Array.isArray(prop)) {
        propName = prop[0];
        srcKey = prop[1];
    } else {
        propName = srcKey = prop;
    }
    if (typeof srcProp === 'boolean') {
        readOnly = srcProp;
        srcProp = undefined;
    }
    if (! srcProp) srcProp = 'data';
    let descriptor = {
        enumerable: true,
        get: function() { return obj[srcProp][srcKey] }
    };
    if (! readOnly) {
        descriptor.set = function(val) {
            let oldVal = obj[srcProp][srcKey];
            if (! deepEqual(val, oldVal)) {
                obj[srcKey][srcKey] = val;
                if (obj instanceof EventEmitter) {
                    obj.emit('update', obj, propName, val);
                }
            }
        };
    }
    Object.defineProperty(obj, propName, descriptor);
}
function defineLinkedProperty(obj, prop, srcProp, readOnly) {
    let propName, srcKey;
    if (Array.isArray(prop)) {
        propName = prop[0];
        srcKey = prop[1];
    } else {
        propName = srcKey = prop;
    }
    if (typeof srcProp === 'boolean') {
        readOnly = srcProp;
        srcProp = undefined;
    }
    if (! srcProp) srcProp = 'data';
    let descriptor = {
        enumerable: true,
        get: function() { return obj[srcProp][srcKey] }
    };
    if (! readOnly) {
        descriptor.set = function(val) {
            let oldVal = obj[srcProp][srcKey];
            if (! deepEqual(val, oldVal)) {
                obj[srcKey][srcKey] = val;
                if (obj instanceof EventEmitter) {
                    obj.emit('update', obj, propName, val);
                }
            }
        };
    }
    Object.defineProperty(obj, propName, descriptor);
}
function defineLinkedProperty ( obj , prop , srcProp , readOnly ) { let propName , srcKey ; if ( Array . isArray ( prop ) ) { propName = prop [ 0 ] ; srcKey = prop [ 1 ] ; } else { propName = srcKey = prop ; } if ( typeof srcProp === 'boolean' ) { readOnly = srcProp ; srcProp = undefined ; } if ( ! srcProp ) srcProp = 'data' ; let descriptor = { enumerable : true , get : function ( ) { return obj [ srcProp ] [ srcKey ] } } ; if ( ! readOnly ) { descriptor . set = function ( val ) { let oldVal = obj [ srcProp ] [ srcKey ] ; if ( ! deepEqual ( val , oldVal ) ) { obj [ srcKey ] [ srcKey ] = val ; if ( obj instanceof EventEmitter ) { obj . emit ( 'update' , obj , propName , val ) ; } } } ; } Object . defineProperty ( obj , propName , descriptor ) ; }
Defines a property on the given object whose value will be linked to that
of the property of another object. If the object is an event emitter, a
property set that changes the value will emit an 'update' event for the
object with 3 parameters, the object, the name of the property, and the
new value.

@param {object} obj - the object for which to define the property
@param {string|string[]} prop - the name of the property to define, or
an array of two elements, namely the name of the property
to define, and the name of the property to link to
@param {string} [srcProp] - the name of the property that stores the
source object (from which values will be linked). Default
is 'data'.
@param {boolean} [readOnly] - whether the property is to be read-only,
defaults to `false`.
@memberof module:lib/util
@since 0.7.0
Defines a property on the given object whose value will be linked to that of the property of another object . If the object is an event emitter a property set that changes the value will emit an update event for the object with 3 parameters the object the name of the property and the new value .