lib/util.js
function (entity, options, modifiers) {
        !options && (options = {});

        var self = this,
            noDefaults = options.noDefaults,
            isV1 = modifiers && modifiers.isV1,
            retainEmpty = options.retainEmptyValues,
            source = entity && (entity.variables || entity.variable || (isV1 && entity.pathVariableData)),
            fallback = options.fallback && options.fallback.values,
            result = _.map(source || fallback, function (item) {
                var result = {
                    id: (noDefaults || item.id) ? item.id : self.uid(),
                    key: item.key || item.id,
                    value: item.value,
                    type: (item.type === 'text' ? 'string' : item.type) || self.typeMap[typeof item.value] || 'any'
                };

                item.disabled && (result.disabled = true);

                if (item.description) { result.description = item.description; }
                else if (retainEmpty) { result.description = null; }

                return result;
            });

        if (result.length) { return result; }
    }
function (entity, options, modifiers) {
        !options && (options = {});

        var self = this,
            noDefaults = options.noDefaults,
            isV1 = modifiers && modifiers.isV1,
            retainEmpty = options.retainEmptyValues,
            source = entity && (entity.variables || entity.variable || (isV1 && entity.pathVariableData)),
            fallback = options.fallback && options.fallback.values,
            result = _.map(source || fallback, function (item) {
                var result = {
                    id: (noDefaults || item.id) ? item.id : self.uid(),
                    key: item.key || item.id,
                    value: item.value,
                    type: (item.type === 'text' ? 'string' : item.type) || self.typeMap[typeof item.value] || 'any'
                };

                item.disabled && (result.disabled = true);

                if (item.description) { result.description = item.description; }
                else if (retainEmpty) { result.description = null; }

                return result;
            });

        if (result.length) { return result; }
    }
function ( entity , options , modifiers ) { ! options && ( options = { } ) ; var self = this , noDefaults = options . noDefaults , isV1 = modifiers && modifiers . isV1 , retainEmpty = options . retainEmptyValues , source = entity && ( entity . variables || entity . variable || ( isV1 && entity . pathVariableData ) ) , fallback = options . fallback && options . fallback . values , result = _ . map ( source || fallback , function ( item ) { var result = { id : ( noDefaults || item . id ) ? item . id : self . uid ( ) , key : item . key || item . id , value : item . value , type : ( item . type === 'text' ? 'string' : item . type ) || self . typeMap [ typeof item . value ] || 'any' } ; item . disabled && ( result . disabled = true ) ; if ( item . description ) { result . description = item . description ; } else if ( retainEmpty ) { result . description = null ; } return result ; } ) ; if ( result . length ) { return result ; } }
A generic utility method to sanitize variable transformations across collection formats.

@param {Object} entity - A generic object that could contain variable data.
@param {?Object} options - The set of options for variable handling.
@param {?Object} options.fallback - The fallback values to be used if no variables are present.
@param {?Boolean} options.noDefaults - When set to true, id will be retained.
@param {?Boolean} options.retainEmptyValues - When set to true, empty property values will be set to ''
instead of being deleted.
@param {Object} [modifiers] - A set of behavioral modifiers for variable handling.
@param {Boolean} [modifiers.isV1=false] - When set to true, looks for the pathVariableData property as well.
@returns {Object[]} - The set of sanitized entity level variables.
A generic utility method to sanitize variable transformations across collection formats .