waltz-ng/client/flow-diagram/components/diagram-svelte/store/model.js
/**
 * private helper to add an entity (e.g. a flow or node)

 * @param state  current state
 * @param entity  the entity to add (must have an `id` property)
 * @param propName  property name of the entity collection within the state
 * @returns updated state
 */
private helper to add an entity
@param state  current state
@param entity  the entity to add (must have an `id` property)
@param propName  property name of the entity collection within the state
@returns updated state
private helper to add an entity @param state current state @param entity the entity to add ( must have an ` id ` property ) @param propName property name of the entity collection within the state @returns updated state
function addEntity(state, entity, propName) {
    checkNotEmpty(entity, `Cannot add a null to ${propName}`);
    checkNotEmpty(entity.id, `Cannot add an entity with a null id to ${propName}`);
    const existing = _.find(state[propName], d => d.id === entity.id);
    if (existing) {
        return state;
    } else {
        dirty.set(true);
        const delta = {};
        delta[propName] = [...state[propName], entity];
        return Object.assign({}, state, delta);
    }
}
function addEntity ( state , entity , propName ) { checkNotEmpty ( entity , ` ${ propName } ` ) ; checkNotEmpty ( entity . id , ` ${ propName } ` ) ; const existing = _ . find ( state [ propName ] , d => d . id === entity . id ) ; if ( existing ) { return state ; } else { dirty . set ( true ) ; const delta = { } ; delta [ propName ] = [ ... state [ propName ] , entity ] ; return Object . assign ( { } , state , delta ) ; } }
private helper to add an entity (e.g.
private helper to add an entity ( e . g .