JavaScript k-means implementation with equal cluster size option