END_SAME_AS_BEGIN = function (mode) {
    return Object.assign(mode,
      {
        /** @type {ModeCallback} */
        'on:begin': (m, resp) => { resp.data._beginMatch = m[1]; },
        /** @type {ModeCallback} */
        'on:end': (m, resp) => { if (resp.data._beginMatch !== m[1]) resp.ignoreMatch(); }
      });
  }
Adds end same as begin mechanics to a mode

Your mode must include at least a single () match group as that first match
group is what is used for comparison
@param {Partial<Mode>} mode