/* =========================================
* Copyright (c) 2015-present, Billgo.
* Copyright (c) 2015-present, Facebook, Inc.
*
* All rights reserved.
*======================================== */

import emptyFunction from "../emptyFunction.js";
import Set from "../Set.js";

var Iterable;

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;
}

export default countDistinct;
