index.js
/**
 * Attempt to get object path, otherwise use defaultValue
 * @param object - the object where we are extracting data
 * @param path - a string representation of the lookup
 * @param defaultValue - default when data is absent, also used to check type
 * @param logType - logger method to use
 */
Attempt to get object path, otherwise use defaultValue
@param object - the object where we are extracting data
@param path - a string representation of the lookup
@param defaultValue - default when data is absent, also used to check type
@param logType - logger method to use
Attempt to get object path otherwise use defaultValue @param object - the object where we are extracting data @param path - a string representation of the lookup @param defaultValue - default when data is absent also used to check type @param logType - logger method to use
function access(object, path, defaultValue, logType) {
    var eventType;
    var result = _get(object, path);
    var typeofResult = getType(result);
    var typeofDefaultValue = getType(defaultValue);
    if (typeofDefaultValue === 'undefined') {
        defaultValue = '';
        typeofDefaultValue = 'string';
    } else if (typeofDefaultValue === 'object' && isEmpty(defaultValue)) {
        defaultValue = {__isEmpty: true};
    }
    if (typeofResult !== 'undefined') {
        if (typeofResult !== typeofDefaultValue) {
            eventType = EVENT_TYPES.TYPE_MISMATCH;
            result = defaultValue;
        }
    } else {
        eventType = EVENT_TYPES.DATA_MISSING;
        result = defaultValue;
    }
    if (logger && logType && eventType) {
        log(eventType, path, defaultValue, logType);
    }
    return result;
}
function access ( object , path , defaultValue , logType ) { var eventType ; var result = _get ( object , path ) ; var typeofResult = getType ( result ) ; var typeofDefaultValue = getType ( defaultValue ) ; if ( typeofDefaultValue === 'undefined' ) { defaultValue = '' ; typeofDefaultValue = 'string' ; } else if ( typeofDefaultValue === 'object' && isEmpty ( defaultValue ) ) { defaultValue = { __isEmpty : true } ; } if ( typeofResult !== 'undefined' ) { if ( typeofResult !== typeofDefaultValue ) { eventType = EVENT_TYPES . TYPE_MISMATCH ; result = defaultValue ; } } else { eventType = EVENT_TYPES . DATA_MISSING ; result = defaultValue ; } if ( logger && logType && eventType ) { log ( eventType , path , defaultValue , logType ) ; } return result ; }
Attempt to get object path, otherwise use defaultValue
 @param object - the object where we are extracting data
 @param path - a string representation of the lookup
 @param defaultValue - default when data is absent, also used to check type
 @param logType - logger method to use
Attempt to get object path otherwise use defaultValue @param object - the object where we are extracting data @param path - a string representation of the lookup @param defaultValue - default when data is absent also used to check type @param logType - logger method to use