Linear partitioning in straight up javascript.