JavaScript class for handling and manipulating intervals