Combine enums and strings.

The order of the returned symbols is undefined and the returned enum is
197003
function combineStrings(types, opts) {
  var symbols = {};
  var i, l, type, typeSymbols;
  for (i = 0, l = types.length; i < l; i++) {
    type = types[i];
    if (type.typeName === 'string') {
      // If at least one of the types is a string, it will be the supertype.
      return type;
    }
    typeSymbols = type.symbols;
    var j, m;
    for (j = 0, m = typeSymbols.length; j < m; j++) {
      symbols[typeSymbols[j]] = true;
    }
  }
  return Type.forSchema({type: 'enum', symbols: Object.keys(symbols)}, opts);
}
1043948
function stringify(js, indent, indentUnit) {
    if (typeof indent === 'undefined') indent = '';
    if (typeof indentUnit === 'undefined') indentUnit = '  ';
    var t = typeof js;
    if (t === 'string') {
        return JSON.stringify(js);
    }
    if (t === 'number') {
        return js;
    }
    if (t === 'boolean') {
        return js ? "true" : "false";
    }
    var out = '', txt, small, lastIndent;
    if (Array.isArray(js)) {
        out = '[';
        txt = JSON.stringify(js);
        small = txt.length < 40;
        if (!small) out += "\n" + indent;
        js.forEach(
            function(itm, idx) {
                if (idx > 0) {
                    out += "," + (small ? " " : "\n" + indent);
                }
                out += stringify(itm, indent + indentUnit);
            }
        );
        out += ']';
        return out;
    }
    if (t === 'object') {
        lastIndent = indent;
        indent += indentUnit;
        out = '{';
        txt = JSON.stringify(js);
        small = txt.length < 40;
        if (!small) out += "\n" + indent;
        var k, v, idx = 0;
        for (k in js) {
            v = js[k];
            if (idx > 0) {
                out += "," + (small ? " " : "\n" + indent);
            }
            out += JSON.stringify(k) + ": " + stringify(v, indent);
            idx++;
        }
        out += (small ? "" : "\n" + lastIndent) + '}';
        return out;
    }
    return '"<' + t + '>"';
}
118002
function envar(key)
{
  var i, value;

  // be extra paranoid
  if (typeof key != 'string' || !key) return undefined;

  // lookup according to the order
  for (i=0; i<state.order.length; i++)
  {
    if ((value = lookup[state.order[i]](key)) !== undefined)
    {
      return value;
    }
  }

  // nothing found
  return undefined;
}
491768
function getEnums(spec_c, bygroup, parent) {
  var spec_js = {};
  var enumGroups = _.find(getChildren(spec_c, 'sectiondef'), function(section) {
    var kind = getAttr(section, 'kind');
    return ((kind == 'enum') || (kind == 'public-type'));
  });
  if (enumGroups) {
    _.each(enumGroups.children, function(enumGroup) {
      var enumGroupName = getText(getChild(enumGroup, 'name'), 'name');
      var enumGroupDescription = getText(getChild(enumGroup, 'detaileddescription'), 'description');
      var enumGroupVals = getChildren(enumGroup, 'enumvalue');
      if (bygroup) {
        spec_js[enumGroupName] = {
          description: enumGroupDescription,
          members: []
        };
      }
      _.each(enumGroupVals, function(e) {
        // TODO: get prefix as option
        var enumName = getText(getChild(e, 'name'), 'name').replace(/^MRAA_/, '');
        var enumDescription = getText(getChild(e, 'detaileddescription'), 'description');
        if (!bygroup) {
          spec_js[enumName] = {
            type: enumGroupName,
            description: enumDescription
          };
        } else {
          spec_js[enumGroupName].members.push(enumName);
        }
      });
    });
  }
  return spec_js;
}
578106
function EnumSet(iter) {
    var p = {};
    priv.set(this, p);
    var newIter = iter;
    if (Array.isArray(iter)) {
      newIter = Array.prototype.map.call(iter, function(x) {
        return [x, x];
      });
    } else if(iter && typeof iter.entries === 'function') {
      if (iter instanceof EnumMap) {
        newIter = {
          entries: function() {
            var pi = priv.get(iter);
            return new Iterator(pi.sequence.sequence, undefined, function(x) {
              return [x, x];
            });
          }
        };
      }
    }
    p.sequence = new Sequence(newIter);
  }
1181265
def enum(**enums):
    
    enums['reverse'] = dict((value, key) for key, value in six.iteritems(enums))
    return type('Enum', (), enums)
244761
function enum_ (options) {
  options.hash.kind = 'member'
  options.hash.isEnum = true
  var result = _identifier(options)
  return result ? options.fn(result) : 'ERROR, Cannot find enum.'
}
899938
function Enum(keys) {
  if (!(keys instanceof Array)) {
    throw new Error('Expected keys to be an array!');
  }

  const map = {};
  keys.forEach(key => {
    map[key] = key;
  });

  // ------------------------------------------------
  // Install an iterator that iterates over the
  // enum keys

  map[Symbol.iterator] = function() {
    let nextIndex = 0;

    const members = Object.values(map);

    return {
      next: function() {
        return nextIndex < keys.length ? {value: members[nextIndex++], done: false} : {done: true};
      },
    };
  };

  function testProperty(map, property) {
    if (!map[property]) {
      throw new Error(`Member '${property}' not found on the Enum.`);
    }
    return map[property];
  }

  const functions = {
    // ------------------------------------------------
    // Return an array of enums
    toArray: function() {
      return Object.values(map);
    },

    // ------------------------------------------------
    // Check if an enum key is valid
    isValid: function(key) {
      return map.hasOwnProperty(key);
    },

    // ------------------------------------------------
    // Enum to string
    toString: function() {
      return 'Enum{' + functions.toArray().join(', ') + '}';
    },
  };

  // ------------------------------------------------
  // Restrict reads and writes of properties to this
  // Enum object
  return new Proxy(map, {
    get: (target, property) => {
      if (functions[property]) {
        return functions[property];
      }
      return testProperty(map, property);
    },
    set: (target, property, value) => {
      throw new Error('Enum members may not be added.');
    },
  });
}
173852
function normalizeMethodName(method) {
    if (typeof method !== 'string')
        return method;
    switch (method.toUpperCase()) {
        case 'GET':
            return __WEBPACK_IMPORTED_MODULE_0__enums__["b" /* RequestMethod */].Get;
        case 'POST':
            return __WEBPACK_IMPORTED_MODULE_0__enums__["b" /* RequestMethod */].Post;
        case 'PUT':
            return __WEBPACK_IMPORTED_MODULE_0__enums__["b" /* RequestMethod */].Put;
        case 'DELETE':
            return __WEBPACK_IMPORTED_MODULE_0__enums__["b" /* RequestMethod */].Delete;
        case 'OPTIONS':
            return __WEBPACK_IMPORTED_MODULE_0__enums__["b" /* RequestMethod */].Options;
        case 'HEAD':
            return __WEBPACK_IMPORTED_MODULE_0__enums__["b" /* RequestMethod */].Head;
        case 'PATCH':
            return __WEBPACK_IMPORTED_MODULE_0__enums__["b" /* RequestMethod */].Patch;
    }
    throw new Error("Invalid request method. The method \"" + method + "\" is not supported.");
}
1198014
function glEnumToString(value) {
  checkInit();
  var name = glEnums[value];
  return (name !== undefined) ? name :
      ("*UNKNOWN WebGL ENUM (0x" + value.toString(16) + ")");
}
1125415
function combineNumbers(types) {
  var typeNames = ['int', 'long', 'float', 'double'];
  var superIndex = -1;
  var superType = null;
  var i, l, type, index;
  for (i = 0, l = types.length; i < l; i++) {
    type = types[i];
    index = typeNames.indexOf(type.typeName);
    if (index > superIndex) {
      superIndex = index;
      superType = type;
    }
  }
  return superType;
}
642872
function (items, options) {

            debug('Extracting keys...');

            let pairs = items.map(item => {

                if (typeof item === typeof '') {

                    // split items on equality character (default is: '=')
                    const parts = item.split(options.equality);

                    if (typeof parts[0] === typeof '' && parts[0].length > 0) {

                        if (parts.length === 1) {

                            debug('No value provided. Using boolean as existence');

                            parts.push('true'); // set existence to true
                        }

                        const output = {
                            key: parts[0],
                            value: options.decodeURIComponent(parts[1])
                        };

                        debug('Key/Value pair: %o', output);

                        return output;

                    } else {

                        debug('Key cannot be empty');
                    }

                } else {

                    debug('item must be a valid string');
                }

                return undefined;
            });

            debug('Removing null and undefined values...');

            // remove undefined/null/empty string keys
            pairs = _.without(pairs, null, undefined);

            debug('Pairs: %o', pairs);

            return pairs;
        }
1239069
def have_enum_values(enum, values, headers = nil, &b)
      values.each do |value|
        have_enum_value(enum, value, headers, &b)
      end
    end
722465
private String generateInvalidErrorMessage(Object[] enumValues, String testValue)
    {
        StringBuffer errorMessage = new StringBuffer("Unable to convert value [" + testValue + "].");

        errorMessage.append(" Allowed values are (case insensitive) ");

        StringBuffer valueList = new StringBuffer();

        int index = 1;
        for (Object enumValue : enumValues) {
            if (valueList.length() > 0) {
                if (++index == enumValues.length) {
                    valueList.append(" or ");
                } else {
                    valueList.append(", ");
                }
            }

            valueList.append('"');
            valueList.append(enumValue);
            valueList.append('"');
        }

        errorMessage.append(valueList);
        errorMessage.append('.');

        return errorMessage.toString();
    }
1241483
function enum_ (options) {
  options.hash.kind = 'enum'
  var result = ddata._identifier(options)
  return result ? options.fn(result) : 'ERROR, Cannot find enum.'
}
755679
function combine(types, opts) {
  if (!types.length) {
    throw new Error('no types to combine');
  }
  if (types.length === 1) {
    return types[0]; // Nothing to do.
  }
  opts = opts || {};

  // Extract any union types, with special care for wrapped unions (see below).
  var expanded = [];
  var numWrappedUnions = 0;
  var isValidWrappedUnion = true;
  types.forEach(function (type) {
    switch (type.getTypeName()) {
      case 'union:unwrapped':
        isValidWrappedUnion = false;
        expanded = expanded.concat(type.getTypes());
        break;
      case 'union:wrapped':
        numWrappedUnions++;
        expanded = expanded.concat(type.getTypes());
        break;
      case 'null':
        expanded.push(type);
        break;
      default:
        isValidWrappedUnion = false;
        expanded.push(type);
    }
  });
  if (numWrappedUnions) {
    if (!isValidWrappedUnion) {
      // It is only valid to combine wrapped unions when no other type is
      // present other than wrapped unions and nulls (otherwise the values of
      // others wouldn't be valid in the resulting union).
      throw new Error('cannot combine wrapped union');
    }
    var branchTypes = {};
    expanded.forEach(function (type) {
      var name = type.getName(true);
      var branchType = branchTypes[name];
      if (!branchType) {
        branchTypes[name] = type;
      } else if (!type.equals(branchType)) {
        throw new Error('inconsistent branch type');
      }
    });
    var wrapUnions = opts.wrapUnions;
    var unionType;
    opts.wrapUnions = true;
    try {
      unionType = createType(Object.keys(branchTypes).map(function (name) {
        return branchTypes[name];
      }), opts);
    } catch (err) {
      opts.wrapUnions = wrapUnions;
      throw err;
    }
    opts.wrapUnions = wrapUnions;
    return unionType;
  }

  // Group types by category, similar to the logic for unwrapped unions.
  var bucketized = {};
  expanded.forEach(function (type) {
    var bucket = getTypeBucket(type);
    var bucketTypes = bucketized[bucket];
    if (!bucketTypes) {
      bucketized[bucket] = bucketTypes = [];
    }
    bucketTypes.push(type);
  });

  // Generate the "augmented" type for each group.
  var buckets = Object.keys(bucketized);
  var augmented = buckets.map(function (bucket) {
    var bucketTypes = bucketized[bucket];
    if (bucketTypes.length === 1) {
      return bucketTypes[0];
    } else {
      switch (bucket) {
        case 'null':
        case 'boolean':
          return bucketTypes[0];
        case 'number':
          return combineNumbers(bucketTypes);
        case 'string':
          return combineStrings(bucketTypes, opts);
        case 'buffer':
          return combineBuffers(bucketTypes, opts);
        case 'array':
          // Remove any sentinel arrays (used when inferring from empty arrays)
          // to avoid making things nullable when they shouldn't be.
          bucketTypes = bucketTypes.filter(function (t) {
            return t !== EMPTY_ARRAY_TYPE;
          });
          if (!bucketTypes.length) {
            // We still don't have a real type, just return the sentinel.
            return EMPTY_ARRAY_TYPE;
          }
          return createType({
            type: 'array',
            items: combine(bucketTypes.map(function (t) {
              return t.getItemsType();
            }))
          }, opts);
        default:
          return combineObjects(bucketTypes, opts);
      }
    }
  });

  if (augmented.length === 1) {
    return augmented[0];
  } else {
    // We return an (unwrapped) union of all augmented types.
    return createType(augmented, opts);
  }
}
854278
def generate_enum(self):
        
        enum = self._definition['enum']
        if not isinstance(enum, (list, tuple)):
            raise JsonSchemaDefinitionException('enum must be an array')
        with self.l('if {variable} not in {enum}:'):
            enum = str(enum).replace('"', '\\"')
            self.l('raise JsonSchemaException("{name} must be one of {}")', enum)