a javascript implementation of a priority queue