source/node/entryFacade.js
function consumeEntryFacade(entry, facade) {
    const facadeType = getEntryFacadeType(entry);
    if (facade && facade.type) {
        const properties = entry.getProperty();
        const attributes = entry.getAttribute();
        if (facade.type !== facadeType) {
            throw new Error(`Failed consuming entry data: Expected type "${facadeType}" but received "${facade.type}"`);
        }
        // update data
        (facade.fields || []).forEach(field => applyFieldDescriptor(entry, field));
        // remove missing properties
        Object.keys(properties).forEach(propKey => {
            const correspondingField = facade.fields.find(
                ({ field, property }) => field === "property" && property === propKey
            );
            if (typeof correspondingField === "undefined") {
                entry.deleteProperty(propKey);
            }
        });
        // remove missing attributes
        Object.keys(attributes).forEach(attrKey => {
            const correspondingField = facade.fields.find(
                ({ field, property }) => field === "attribute" && property === attrKey
            );
            if (typeof correspondingField === "undefined") {
                entry.deleteAttribute(attrKey);
            }
        });
    } else {
        throw new Error("Failed consuming entry data: Invalid item passed as a facade");
    }
}
function consumeEntryFacade(entry, facade) {
    const facadeType = getEntryFacadeType(entry);
    if (facade && facade.type) {
        const properties = entry.getProperty();
        const attributes = entry.getAttribute();
        if (facade.type !== facadeType) {
            throw new Error(`Failed consuming entry data: Expected type "${facadeType}" but received "${facade.type}"`);
        }
        // update data
        (facade.fields || []).forEach(field => applyFieldDescriptor(entry, field));
        // remove missing properties
        Object.keys(properties).forEach(propKey => {
            const correspondingField = facade.fields.find(
                ({ field, property }) => field === "property" && property === propKey
            );
            if (typeof correspondingField === "undefined") {
                entry.deleteProperty(propKey);
            }
        });
        // remove missing attributes
        Object.keys(attributes).forEach(attrKey => {
            const correspondingField = facade.fields.find(
                ({ field, property }) => field === "attribute" && property === attrKey
            );
            if (typeof correspondingField === "undefined") {
                entry.deleteAttribute(attrKey);
            }
        });
    } else {
        throw new Error("Failed consuming entry data: Invalid item passed as a facade");
    }
}
function consumeEntryFacade ( entry , facade ) { const facadeType = getEntryFacadeType ( entry ) ; if ( facade && facade . type ) { const properties = entry . getProperty ( ) ; const attributes = entry . getAttribute ( ) ; if ( facade . type !== facadeType ) { throw new Error ( ` ${ facadeType } ${ facade . type } ` ) ; } // update data ( facade . fields || [ ] ) . forEach ( field => applyFieldDescriptor ( entry , field ) ) ; // remove missing properties Object . keys ( properties ) . forEach ( propKey => { const correspondingField = facade . fields . find ( ( { field , property } ) => field === "property" && property === propKey ) ; if ( typeof correspondingField === "undefined" ) { entry . deleteProperty ( propKey ) ; } } ) ; // remove missing attributes Object . keys ( attributes ) . forEach ( attrKey => { const correspondingField = facade . fields . find ( ( { field , property } ) => field === "attribute" && property === attrKey ) ; if ( typeof correspondingField === "undefined" ) { entry . deleteAttribute ( attrKey ) ; } } ) ; } else { throw new Error ( "Failed consuming entry data: Invalid item passed as a facade" ) ; } }
Process a modified entry facade
@param {Entry} entry The entry to apply processed data on
@param {EntryFacade} facade The facade object
Process a modified entry facade