Simple javascript queue implementation