compose-gateway-locations.js 468 Bytes
/**
 * @param  {Object} config
 * @param  {Array.<string>} [config.locations]
 * @returns {Array.<string>}
 */
module.exports = (config) => {
    const retval = ((
        Array.isArray(config.locations) && config.locations.length && config.locations)
        || []
    )
        .filter((item) => typeof item === 'string')
        .map((item) => item.trim())
        .filter((item) => item.length);

    if (!retval.length) retval.push('ALL');

    return retval;
};