bin/amigo.js
function _param(req, param, pdefault){

    var ret = null;

    // Try the route parameter space.
    if( req && req.params && typeof(req.params[param]) !== 'undefined' ){
	ret = req.params[param];
    }

    // Try the get space.
    if( ! ret ){

	if( req && req.query && req.query[param] && typeof(req.query[param]) !== 'undefined' ){
	    ret = req.query[param];
	}
    }

    // Otherwise, try the body space.
    if( ! ret ){

	var decoded_body = req.body || {};
	if( decoded_body && ! us.isEmpty(decoded_body) && decoded_body[param] ){
	    ret = decoded_body[param];
	}
    }

    // Reduce to first if array.
    if( us.isArray(ret) ){
	if( ret.length === 0 ){
	    ret = pdefault;
	}else{
	    ret = ret[0];
	}
    }

    // Finally, default.
    if( ! ret ){
	ret = pdefault;
    }

    return ret;
}
function _param(req, param, pdefault){

    var ret = null;

    // Try the route parameter space.
    if( req && req.params && typeof(req.params[param]) !== 'undefined' ){
	ret = req.params[param];
    }

    // Try the get space.
    if( ! ret ){

	if( req && req.query && req.query[param] && typeof(req.query[param]) !== 'undefined' ){
	    ret = req.query[param];
	}
    }

    // Otherwise, try the body space.
    if( ! ret ){

	var decoded_body = req.body || {};
	if( decoded_body && ! us.isEmpty(decoded_body) && decoded_body[param] ){
	    ret = decoded_body[param];
	}
    }

    // Reduce to first if array.
    if( us.isArray(ret) ){
	if( ret.length === 0 ){
	    ret = pdefault;
	}else{
	    ret = ret[0];
	}
    }

    // Finally, default.
    if( ! ret ){
	ret = pdefault;
    }

    return ret;
}
function _param ( req , param , pdefault ) { var ret = null ; // Try the route parameter space. if ( req && req . params && typeof ( req . params [ param ] ) !== 'undefined' ) { ret = req . params [ param ] ; } // Try the get space. if ( ! ret ) { if ( req && req . query && req . query [ param ] && typeof ( req . query [ param ] ) !== 'undefined' ) { ret = req . query [ param ] ; } } // Otherwise, try the body space. if ( ! ret ) { var decoded_body = req . body || { } ; if ( decoded_body && ! us . isEmpty ( decoded_body ) && decoded_body [ param ] ) { ret = decoded_body [ param ] ; } } // Reduce to first if array. if ( us . isArray ( ret ) ) { if ( ret . length === 0 ) { ret = pdefault ; } else { ret = ret [ 0 ] ; } } // Finally, default. if ( ! ret ) { ret = pdefault ; } return ret ; }
Extract singular arguments; will take first if multiple.
Extract singular arguments ; will take first if multiple .