jspm_packages/npm/babel-core@5.8.38/lib/types/flow.js
function removeTypeDuplicates(nodes) {
  var generics = {};
  var bases = {};

  // store union type groups to circular references
  var typeGroups = [];

  var types = [];

  for (var i = 0; i < nodes.length; i++) {
    var node = nodes[i];
    if (!node) continue;

    // detect duplicates
    if (types.indexOf(node) >= 0) {
      continue;
    }

    // this type matches anything
    if (t.isAnyTypeAnnotation(node)) {
      return [node];
    }

    //
    if (t.isFlowBaseAnnotation(node)) {
      bases[node.type] = node;
      continue;
    }

    //
    if (t.isUnionTypeAnnotation(node)) {
      if (typeGroups.indexOf(node.types) < 0) {
        nodes = nodes.concat(node.types);
        typeGroups.push(node.types);
      }
      continue;
    }

    // find a matching generic type and merge and deduplicate the type parameters
    if (t.isGenericTypeAnnotation(node)) {
      var _name = node.id.name;

      if (generics[_name]) {
        var existing = generics[_name];
        if (existing.typeParameters) {
          if (node.typeParameters) {
            existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params.concat(node.typeParameters.params));
          }
        } else {
          existing = node.typeParameters;
        }
      } else {
        generics[_name] = node;
      }

      continue;
    }

    types.push(node);
  }

  // add back in bases
  for (var type in bases) {
    types.push(bases[type]);
  }

  // add back in generics
  for (var _name2 in generics) {
    types.push(generics[_name2]);
  }

  return types;
}
function removeTypeDuplicates(nodes) {
  var generics = {};
  var bases = {};

  // store union type groups to circular references
  var typeGroups = [];

  var types = [];

  for (var i = 0; i < nodes.length; i++) {
    var node = nodes[i];
    if (!node) continue;

    // detect duplicates
    if (types.indexOf(node) >= 0) {
      continue;
    }

    // this type matches anything
    if (t.isAnyTypeAnnotation(node)) {
      return [node];
    }

    //
    if (t.isFlowBaseAnnotation(node)) {
      bases[node.type] = node;
      continue;
    }

    //
    if (t.isUnionTypeAnnotation(node)) {
      if (typeGroups.indexOf(node.types) < 0) {
        nodes = nodes.concat(node.types);
        typeGroups.push(node.types);
      }
      continue;
    }

    // find a matching generic type and merge and deduplicate the type parameters
    if (t.isGenericTypeAnnotation(node)) {
      var _name = node.id.name;

      if (generics[_name]) {
        var existing = generics[_name];
        if (existing.typeParameters) {
          if (node.typeParameters) {
            existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params.concat(node.typeParameters.params));
          }
        } else {
          existing = node.typeParameters;
        }
      } else {
        generics[_name] = node;
      }

      continue;
    }

    types.push(node);
  }

  // add back in bases
  for (var type in bases) {
    types.push(bases[type]);
  }

  // add back in generics
  for (var _name2 in generics) {
    types.push(generics[_name2]);
  }

  return types;
}
function removeTypeDuplicates ( nodes ) { var generics = { } ; var bases = { } ; // store union type groups to circular references var typeGroups = [ ] ; var types = [ ] ; for ( var i = 0 ; i < nodes . length ; i ++ ) { var node = nodes [ i ] ; if ( ! node ) continue ; // detect duplicates if ( types . indexOf ( node ) >= 0 ) { continue ; } // this type matches anything if ( t . isAnyTypeAnnotation ( node ) ) { return [ node ] ; } // if ( t . isFlowBaseAnnotation ( node ) ) { bases [ node . type ] = node ; continue ; } // if ( t . isUnionTypeAnnotation ( node ) ) { if ( typeGroups . indexOf ( node . types ) < 0 ) { nodes = nodes . concat ( node . types ) ; typeGroups . push ( node . types ) ; } continue ; } // find a matching generic type and merge and deduplicate the type parameters if ( t . isGenericTypeAnnotation ( node ) ) { var _name = node . id . name ; if ( generics [ _name ] ) { var existing = generics [ _name ] ; if ( existing . typeParameters ) { if ( node . typeParameters ) { existing . typeParameters . params = removeTypeDuplicates ( existing . typeParameters . params . concat ( node . typeParameters . params ) ) ; } } else { existing = node . typeParameters ; } } else { generics [ _name ] = node ; } continue ; } types . push ( node ) ; } // add back in bases for ( var type in bases ) { types . push ( bases [ type ] ) ; } // add back in generics for ( var _name2 in generics ) { types . push ( generics [ _name2 ] ) ; } return types ; }
Dedupe type annotations.
Dedupe type annotations .