function _getFreeIndex(): number {
  let freeIndex = timerIDs.indexOf(null);
  if (freeIndex === -1) {
    freeIndex = timerIDs.length;
  }
  return freeIndex;
}
JS implementation of timer functions. Must be completely driven by an
external clock signal, all that's stored here is timerID, timer type, and
callback.