How to use the mime._types function in mime

To help you get started, we’ve selected a few mime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github skypager / skypager / src / runtimes / node / src / features / fs-adapter.js View on Github external
methods.push(...methods.map(name => `${name}Sync`))
  methods.push(...methods.map(name => `${name}Async`))

  const selected = pick(fsx, methods)

  selected.findUpAsync = findUp
  selected.findUp = findUp
  selected.findUpSync = findUp.sync
  selected.existingSync = (...paths) => paths.filter(fsx.existsSync)
  selected.existingAsync = selected.existing = (...paths) =>
    Promise.all(paths.map(p => fsx.existsAsync(p).then(r => r && p))).then(results =>
      results.filter(p => p)
    )

  const mime = require('mime')
  const mimeTypes = mime.types || mime._types

  selected.mimeTypes = () => mimeTypes
  selected.mimeType = ext => mimeTypes[ext.replace('.', '')]

  return selected
}