<commit_before>import './setup.js'
import { suffixMediaTypeMap }  from './mediatypes.js'
import { readSource } from './reader.js'
import { transcribers, requestHeaders } from './transcribers.js'

const MAX_REDIRECTS = 32

export async function read (source, opts = {}) {
  if (typeof opts === 'string') {
    opts = {type: opts}
  }

  if (opts == null && typeof source === 'object') {
    opts = source
  } else if (typeof source === 'string') {
    opts.source = source
  } else if (source) {
    opts.data = source
  }

  let type = opts.type
  type = suffixMediaTypeMap[type] || type
  opts.type = type

  if (opts.maxRedirects == null) {
    opts.maxRedirects = MAX_REDIRECTS
  }<commit_msg>Fix handling of read calls using only opts object<commit_after>import './setup.js'
import { suffixMediaTypeMap }  from './mediatypes.js'
import { readSource } from './reader.js'
import { transcribers, requestHeaders } from './transcribers.js'

const MAX_REDIRECTS = 32

export async function read (source, opts = {}) {
  if (typeof opts === 'string') {
    opts = {type: opts}
  }

  if (typeof source === 'object') {
    Object.assign(opts, source)
  } else if (typeof source === 'string') {
    opts.source = source
  } else if (source) {
    opts.data = source
  }

  let type = opts.type
  type = suffixMediaTypeMap[type] || type
  opts.type = type

  if (opts.maxRedirects == null) {
    opts.maxRedirects = MAX_REDIRECTS
  }
{'fraction_non_alphanumeric': 0.13955119214586256, 'fraction_numerical': 0.002805049088359046, 'mean_word_length': 3.285285285285285, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7094377', 'n_tokens_mistral': 468, 'n_tokens_neox': 462, 'n_words': 134}