code: function UnionType(attrs, opts) {
    Type.call(this);
  
    if (!Array.isArray(attrs)) {
      throw new Error(f('non-array union schema: %j', attrs));
    }
    if (!attrs.length) {
      throw new Error('empty union');
    }
    this._types = attrs.map(function (obj) { return createType(obj, opts); });
  
    this._branchIndices = {};
    this._types.forEach(function (type, i) {
      if (Type.isType(type, 'union')) {
        throw new Error('unions cannot be directly nested');
      }
      var branch = type.getName(true);
      if (this._branchIndices[branch] !== undefined) {
        throw new Error(f('duplicate union branch name: %j', branch));
      }
      this._branchIndices[branch] = i;
    }, this);
  }
docs: Base "abstract" Avro union type.