lib/modelItem.js
function update(item, model, data, funcParams) {
    var working = [];
    var definedByData = [];

    _.forEach(data, function(value, key) {
        if (_.isFunction(value)) {
            working.push(Promise.resolve(value()).then(function(val) {
                item[key] = val;
            }));
        } else item[key] = value;
        definedByData.push(value);
    });

    _.forEach(model.itemDef, function(value, key) {
        if (value && value.__precalc) {
            var func = value.__precalc, previousVal = data[key];
            working.push(Promise.resolve(func.call(item, previousVal, funcParams || {})).then(function(val) {
                item[key] = (val && val._stWrapped) ? val.val : val;
            }));
        } // if the property has not been set from the itemDef yet. This allows item def properties to be changed
        else if (!_.has(item, key) || definedByData.indexOf(key) !== -1) item[key] = value;
    });

    return Promise.all(working);
}
function update(item, model, data, funcParams) {
    var working = [];
    var definedByData = [];

    _.forEach(data, function(value, key) {
        if (_.isFunction(value)) {
            working.push(Promise.resolve(value()).then(function(val) {
                item[key] = val;
            }));
        } else item[key] = value;
        definedByData.push(value);
    });

    _.forEach(model.itemDef, function(value, key) {
        if (value && value.__precalc) {
            var func = value.__precalc, previousVal = data[key];
            working.push(Promise.resolve(func.call(item, previousVal, funcParams || {})).then(function(val) {
                item[key] = (val && val._stWrapped) ? val.val : val;
            }));
        } // if the property has not been set from the itemDef yet. This allows item def properties to be changed
        else if (!_.has(item, key) || definedByData.indexOf(key) !== -1) item[key] = value;
    });

    return Promise.all(working);
}
function update ( item , model , data , funcParams ) { var working = [ ] ; var definedByData = [ ] ; _ . forEach ( data , function ( value , key ) { if ( _ . isFunction ( value ) ) { working . push ( Promise . resolve ( value ( ) ) . then ( function ( val ) { item [ key ] = val ; } ) ) ; } else item [ key ] = value ; definedByData . push ( value ) ; } ) ; _ . forEach ( model . itemDef , function ( value , key ) { if ( value && value . __precalc ) { var func = value . __precalc , previousVal = data [ key ] ; working . push ( Promise . resolve ( func . call ( item , previousVal , funcParams || { } ) ) . then ( function ( val ) { item [ key ] = ( val && val . _stWrapped ) ? val . val : val ; } ) ) ; } // if the property has not been set from the itemDef yet. This allows item def properties to be changed else if ( ! _ . has ( item , key ) || definedByData . indexOf ( key ) !== - 1 ) item [ key ] = value ; } ) ; return Promise . all ( working ) ; }
Updates the model to represent the given data

@param {object} item
@param {Model} model
@param {object} data the data to add to the model
@param {object?} funcParams parameters to pass to any precalc functions
@returns {Promise}
Updates the model to represent the given data