A simple Javascript circular buffer implementation.