code: function insert (history, state, limit, group) {
    debug.log('inserting', state)
    debug.log('new free: ', limit - lengthWithoutFuture(history))
  
    const { past, _latestUnfiltered } = history
    const historyOverflow = limit && lengthWithoutFuture(history) >= limit
  
    const pastSliced = past.slice(historyOverflow ? 1 : 0)
    const newPast = _latestUnfiltered != null
      ? [
        ...pastSliced,
        _latestUnfiltered
      ] : pastSliced
  
    return newHistory(newPast, state, [], group)
  }
docs: insert: insert `state` into history, which means adding the current state into `past`, setting the new `state` as `present` and erasing the `future`.