code: function countDistinct<T1, T2>(
    iter: Iterable<T1>,
    selector: (item: T1) => T2,
  ): number {
    selector = selector || emptyFunction.thatReturnsArgument;
  
    var set = new Set();
    for (var val of iter) {
      set.add(selector(val));
    }
  
    return set.size;
  }
docs: Returns the count of distinct elements selected from an array.