src/index.js
function mapOne(resultSet, maps, mapId, columnPrefix, isRequired = true) {

    var mappedCollection = map(resultSet, maps, mapId, columnPrefix);

    if (mappedCollection.length > 0) {
        return mappedCollection[0];
    }
    else if (isRequired) {
        throw new NotFoundError('EmptyResponse');
    }
    else {
        return null;
    }
}
function mapOne(resultSet, maps, mapId, columnPrefix, isRequired = true) {

    var mappedCollection = map(resultSet, maps, mapId, columnPrefix);

    if (mappedCollection.length > 0) {
        return mappedCollection[0];
    }
    else if (isRequired) {
        throw new NotFoundError('EmptyResponse');
    }
    else {
        return null;
    }
}
function mapOne ( resultSet , maps , mapId , columnPrefix , isRequired = true ) { var mappedCollection = map ( resultSet , maps , mapId , columnPrefix ) ; if ( mappedCollection . length > 0 ) { return mappedCollection [ 0 ] ; } else if ( isRequired ) { throw new NotFoundError ( 'EmptyResponse' ) ; } else { return null ; } }
Maps a resultSet to a single object.

Although the result is a single object, resultSet may have multiple results (e.g. when the
top-level object has many children in a one-to-many relationship). So mapOne() must still
call map(), only difference is that it will return only the first result.

@param {Array} resultSet - an array of database results
@param {Array} maps - an array of result maps
@param {String} mapId - mapId of the top-level object in the resultSet
@param {String} [columnPrefix] - prefix that should be applied to the column names of the top-level object
@param {boolean} [isRequired] - is it required to have a mapped object as a return value? Default is true.
@returns {Object} one mapped object or null
@throws {NotFoundError} if object is not found and isRequired is true
Maps a resultSet to a single object .