build/SPE.js
function( arg, type, defaultValue ) {
        'use strict';

        // If the argument being checked is an array, loop through
        // it and ensure all the values are of the correct type,
        // falling back to the defaultValue if any aren't.
        if ( Array.isArray( arg ) ) {
            for ( var i = arg.length - 1; i >= 0; --i ) {
                if ( typeof arg[ i ] !== type ) {
                    return defaultValue;
                }
            }

            return arg;
        }

        // If the arg isn't an array then just fallback to
        // checking the type.
        return this.ensureTypedArg( arg, type, defaultValue );
    }
function( arg, type, defaultValue ) {
        'use strict';

        // If the argument being checked is an array, loop through
        // it and ensure all the values are of the correct type,
        // falling back to the defaultValue if any aren't.
        if ( Array.isArray( arg ) ) {
            for ( var i = arg.length - 1; i >= 0; --i ) {
                if ( typeof arg[ i ] !== type ) {
                    return defaultValue;
                }
            }

            return arg;
        }

        // If the arg isn't an array then just fallback to
        // checking the type.
        return this.ensureTypedArg( arg, type, defaultValue );
    }
function ( arg , type , defaultValue ) { 'use strict' ; // If the argument being checked is an array, loop through // it and ensure all the values are of the correct type, // falling back to the defaultValue if any aren't. if ( Array . isArray ( arg ) ) { for ( var i = arg . length - 1 ; i >= 0 ; -- i ) { if ( typeof arg [ i ] !== type ) { return defaultValue ; } } return arg ; } // If the arg isn't an array then just fallback to // checking the type. return this . ensureTypedArg ( arg , type , defaultValue ) ; }
Given an array of values, a type, and a default value,
ensure the given array's contents ALL adhere to the provided type,
returning the default value if type check fails.

If the given value to check isn't an Array, delegates to SPE.utils.ensureTypedArg.

@param  {Array|boolean|string|number|object} arg          The array of values to check type of.
@param  {String} type         The type that should be adhered to.
@param  {(boolean|string|number|object)} defaultValue A default fallback value.
@return {(boolean|string|number|object)}              The given value if type check passes, or the default value if it fails.
Given an array of values a type and a default value ensure the given array s contents ALL adhere to the provided type returning the default value if type check fails .