function updateBinaryMode()

in packages/miew/src/Miew.js [1820:1855]


function updateBinaryMode(opts) {
  let { binary } = opts;

  // detect by format
  if (opts.fileType !== undefined) {
    const TheParser = _.head(io.parsers.find({ format: opts.fileType }));
    if (TheParser) {
      binary = TheParser.binary || false;
    } else {
      throw new Error('Could not find suitable parser for this format');
    }
  }

  // detect by file extension
  if (binary === undefined && opts.fileExt !== undefined) {
    const TheParser = _.head(io.parsers.find({ ext: opts.fileExt }));
    if (TheParser) {
      binary = TheParser.binary || false;
    }
  }

  // temporary workaround for animation
  if (opts.fileExt !== undefined && opts.fileExt.toLowerCase() === '.man') {
    opts.binary = true;
    opts.animation = true; // who cares?
  }

  // update if detected
  if (binary !== undefined) {
    if (opts.binary !== undefined && opts.binary !== binary) {
      opts.context.logger.warn('Overriding incorrect binary mode');
    }
  }

  opts.binary = binary || false;
}