lib/index.js
function xmultipleObjects(parents, proxyTarget = Object.create(null)) {
    // Create proxy that traps property accesses and forwards to each parent, returning the first defined value we find
    const forwardingProxy = new Proxy(proxyTarget, {
        get: function (proxyTarget, propertyKey) {
            // The proxy target gets first dibs
            // So, for example, if the proxy target is constructible, this will find its prototype
            if (Object.prototype.hasOwnProperty.call(proxyTarget, propertyKey)) {
                return proxyTarget[propertyKey];
            }

            // Check every parent for the property key
            // We might find more than one defined value if multiple parents have the same property
            const foundValues = parents.reduce(function(foundValues, parent) {
                // It's important that we access the object property only once,
                // because it might be a getter that causes side-effects
                const currentValue = parent[propertyKey];
                if (currentValue !== undefined) {
                    foundValues.push(currentValue);
                }

                return foundValues;
            }, []);

            // Just because we found multiple values doesn't necessarily mean there's a collision
            // If, for example, we inherit from three plain objects that each inherit from Object.prototype,
            // then we would find three references for the key "hasOwnProperty"
            // But that doesn't mean we have three different functions; it means we have three references to the *same* function
            // Thus, if every found value compares strictly equal, then don't treat it as a collision
            const firstValue = foundValues[0];
            const areFoundValuesSame = foundValues.every(value => value === firstValue);
            if (!areFoundValuesSame) {
                throw new Error(`Ambiguous property: ${propertyKey}.`);
            }

            return firstValue;
        }
    });

    return forwardingProxy;
}
function xmultipleObjects(parents, proxyTarget = Object.create(null)) {
    // Create proxy that traps property accesses and forwards to each parent, returning the first defined value we find
    const forwardingProxy = new Proxy(proxyTarget, {
        get: function (proxyTarget, propertyKey) {
            // The proxy target gets first dibs
            // So, for example, if the proxy target is constructible, this will find its prototype
            if (Object.prototype.hasOwnProperty.call(proxyTarget, propertyKey)) {
                return proxyTarget[propertyKey];
            }

            // Check every parent for the property key
            // We might find more than one defined value if multiple parents have the same property
            const foundValues = parents.reduce(function(foundValues, parent) {
                // It's important that we access the object property only once,
                // because it might be a getter that causes side-effects
                const currentValue = parent[propertyKey];
                if (currentValue !== undefined) {
                    foundValues.push(currentValue);
                }

                return foundValues;
            }, []);

            // Just because we found multiple values doesn't necessarily mean there's a collision
            // If, for example, we inherit from three plain objects that each inherit from Object.prototype,
            // then we would find three references for the key "hasOwnProperty"
            // But that doesn't mean we have three different functions; it means we have three references to the *same* function
            // Thus, if every found value compares strictly equal, then don't treat it as a collision
            const firstValue = foundValues[0];
            const areFoundValuesSame = foundValues.every(value => value === firstValue);
            if (!areFoundValuesSame) {
                throw new Error(`Ambiguous property: ${propertyKey}.`);
            }

            return firstValue;
        }
    });

    return forwardingProxy;
}
function xmultipleObjects ( parents , proxyTarget = Object . create ( null ) ) { // Create proxy that traps property accesses and forwards to each parent, returning the first defined value we find const forwardingProxy = new Proxy ( proxyTarget , { get : function ( proxyTarget , propertyKey ) { // The proxy target gets first dibs // So, for example, if the proxy target is constructible, this will find its prototype if ( Object . prototype . hasOwnProperty . call ( proxyTarget , propertyKey ) ) { return proxyTarget [ propertyKey ] ; } // Check every parent for the property key // We might find more than one defined value if multiple parents have the same property const foundValues = parents . reduce ( function ( foundValues , parent ) { // It's important that we access the object property only once, // because it might be a getter that causes side-effects const currentValue = parent [ propertyKey ] ; if ( currentValue !== undefined ) { foundValues . push ( currentValue ) ; } return foundValues ; } , [ ] ) ; // Just because we found multiple values doesn't necessarily mean there's a collision // If, for example, we inherit from three plain objects that each inherit from Object.prototype, // then we would find three references for the key "hasOwnProperty" // But that doesn't mean we have three different functions; it means we have three references to the *same* function // Thus, if every found value compares strictly equal, then don't treat it as a collision const firstValue = foundValues [ 0 ] ; const areFoundValuesSame = foundValues . every ( value => value === firstValue ) ; if ( ! areFoundValuesSame ) { throw new Error ( ` ${ propertyKey } ` ) ; } return firstValue ; } } ) ; return forwardingProxy ; }
Creates a proxy that delegates to multiple other plain objects.

@param {Array<Object>} parents The list of objects to delegate to.
@param {any=Object.create(null)} proxyTarget Object for the proxy to
virtualize. Some characteristics of the proxy are verified against the
target. For example, for the proxy to be considered constructible, the
target must be constructible.
@return {Proxy}
Creates a proxy that delegates to multiple other plain objects .