Slice through large amounts of data in Javascript