Plato on Github
Report Home
node_modules\atropa-setAsOptionalArg\src\atropa-setAsOptionalArg.js
Maintainability
75.55
Lines of code
50
Difficulty
9.06
Estimated Errors
0.08
Function weight
By Complexity
By SLOC
/// <reference path="../../docs/vsdoc/OpenLayersAll.js"/> var atropa = require('atropa-header'); /*jslint indent: 4, maxerr: 50, white: true, browser: true, devel: true, plusplus: true, regexp: true */ /*global atropa */ // end header /** * Set default values for optional function parameters. * @example * <pre> * // To set a default value for an optional parameter * function(optionalArg) { * var defaultVal = 'hello there!'; * optionalArg = atropa.setAsOptionalArg(defaultVal, optionalArg); * return optionalArg; * } * </pre> * @author <a href="mailto:matthewkastor@gmail.com"> * Matthew Christopher Kastor-Inare III </a><br /> * ☭ Hial Atropa!! ☭ * @version 20120909 * @param {Mixed} defaultVal The default value to set. * @param {Mixed} optionalArg A reference to the optional argument. * @returns {Mixed} Returns the default value supplied when the optional * argument is undefined or null. Otherwise, the supplied optional argument * is returned. */ atropa.setAsOptionalArg = function (defaultVal, optionalArg) { "use strict"; if (optionalArg === undefined || optionalArg === null) { optionalArg = defaultVal; } return optionalArg; }; while(atropa.data.requirements.length > 0) { atropa.data.requirements.pop()(); } module.exports = atropa;