preprocessData(data, fields) {
    const processedData = Array.isArray(data) ? data : [data];

    if (!fields && (processedData.length === 0 || typeof processedData[0] !== 'object')) {
      throw new Error('Data should not be empty or the "fields" option should be included');
    }

    if (this.opts.transforms.length === 0) return processedData;

    return processedData
      .flatMap(row => this.preprocessRow(row));
  }
Preprocess the data according to the give opts (unwind, flatten, etc.)
    and calculate the fields and field names if they are not provided.

@param {Array|Object} data Array or object to be converted to CSV