// Returns the first value of the given named parameter.
//
// @param params
// as returned by parseParams or null/undefined
//
function getParamValue(params, name, defaultValue) {
if (!params)
return defaultValue;
var p = params[0][name];
return (!p || p.length == 0) ? defaultValue : p[0];
}
// Returns the first value of the given boolean named parameter.
//
// @param params
// as returned by parseParams or null/undefined
//
function getBooleanParamValue(params, name, defaultValue) {
var f = getParamValue(params, name, null);
if (f === null)
return defaultValue;
return (typeof f == "boolean") ? f : f.toString() == "true";
}
I found the following two helper functions very useful when working with the named parameter feature (i.e. the stuff around the "parseParams" function).
it would be quite handy to have something like that in the core though. ;)