function objectFactory(data) {
    // If we were given a byte Buffer, parse it as utf-8 string.
    if (data instanceof Buffer) {
        data = data.toString('utf-8');
    } else if (_.isObject(data)) {
        // if we were given a a JS object, return it now.
        return data;
    }

    // If we now have a string, then assume it is a YAML/JSON string.
    if (_.isString(data)) {
        data = yaml.safeLoad(data);
    } else {
        throw new Error(
            'Could not convert data into an object.  ' +
            'Data must be a utf-8 byte buffer or a YAML/JSON string'
        );
    }

    return data;
}
/**
 * Converts a utf-8 byte buffer or a YAML/JSON string into
 * an object and returns it.
 * @param {string|Buffer|Object} data
 */
Converts a utf-8 byte buffer or a YAML/JSON string into
an object and returns it.
@param {string|Buffer|Object} data
Converts a utf - 8 byte buffer or a YAML / JSON string into an object and returns it . @param { string|Buffer|Object } data
function objectFactory(data) {
    if (data instanceof Buffer) {
        data = data.toString('utf-8');
    } else if (_.isObject(data)) {
        return data;
    }
    if (_.isString(data)) {
        data = yaml.safeLoad(data);
    } else {
        throw new Error(
            'Could not convert data into an object.  ' +
            'Data must be a utf-8 byte buffer or a YAML/JSON string'
        );
    }
    return data;
}
function objectFactory ( data ) { if ( data instanceof Buffer ) { data = data . toString ( 'utf-8' ) ; } else if ( _ . isObject ( data ) ) { return data ; } if ( _ . isString ( data ) ) { data = yaml . safeLoad ( data ) ; } else { throw new Error ( 'Could not convert data into an object.  ' + 'Data must be a utf-8 byte buffer or a YAML/JSON string' ) ; } return data ; }
Converts a utf-8 byte buffer or a YAML/JSON string into
 an object and returns it.
Converts a utf - 8 byte buffer or a YAML / JSON string into an object and returns it .
// If we were given a byte Buffer, parse it as utf-8 string. // if we were given a a JS object, return it now. // If we now have a string, then assume it is a YAML/JSON string.