addToResult(result, port, packet, before = false) {
    const res = result;
    const ip = packet;
    const { name, index } = normalizePortName(port);
    const method = before ? 'unshift' : 'push';
    if (this.outPorts.ports[name].isAddressable()) {
      const idx = /** @type {number} */ (index ? parseInt(index, 10) : ip.index);
      if (!res[name]) {
        res[name] = {};
      }
      if (!res[name][idx]) {
        res[name][idx] = [];
      }
      ip.index = idx;
      res[name][idx][method](ip);
      return;
    }
    if (!res[name]) {
      res[name] = [];
    }
    res[name][method](ip);
  }
@param {ProcessResult} result
@param {Object} port
@param {IP} packet
@param {boolean} [before]