girder/web_client/src/misc.js
function defineFlags(options, allOption) {
    var i = 0,
        obj = {};

    if (allOption) {
        obj[allOption] = 1;
    }
    _.each(options, function (opt) {
        obj[opt] = 1 << i;

        if (allOption) {
            obj[allOption] |= obj[opt];
        }

        i += 1;
    });

    return obj;
}
function defineFlags(options, allOption) {
    var i = 0,
        obj = {};

    if (allOption) {
        obj[allOption] = 1;
    }
    _.each(options, function (opt) {
        obj[opt] = 1 << i;

        if (allOption) {
            obj[allOption] |= obj[opt];
        }

        i += 1;
    });

    return obj;
}
Create a set of flags that can be OR'd (|) together to define a set of
options.

@param {Array} options An array of strings defining the option names.
@param {string} allOption If you want an option that enables all options,
pass its name as this parameter.
@return {Object} An object mapping the names of options to values.