npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@contentful/mimetype

v2.4.1

Published

"Identify mimetypes and associate them with filegroups"

Downloads

58,736

Readme

contentful-mimetype [CircleCI] codecov

Mimetype handling and identification

This is mostly used by the UI to figure out which icons to show for different filetypes.

It does a best effort guess to figure out which icon to show, which might not always come out very accurate.

It should be updated over time with relevant file types and mime types and it is by no means a definitive representation of all available file types.

Glossary

  • type - A media/MIME type http://en.wikipedia.org/wiki/Internet_media_type
  • group - A group of types that corresponds to a more global type of media (ex: plaintext, image, video, audio, etc)
  • group name - the display name for a given group
  • group label - the label used to identify a group in fileGroups.json and groupNames.json

API

Options object used by various methods

The methods that take this object as a parameter will always try to use the type if available. If the type is not available or is undefined, it will use the file extension as a fallback. You can also provide a fallback file name from which the extension will be extracted if not provided.

/**
 * @typedef {object} mimetypeParams
 * @prop {string} type Content MIME type
 * @prop {string} fallbackExt Fallback extension
 * @prop {string} fallbackFileName Fallback file name
*/

getGroupNames

  /**
   * Gets list of names for groups of mimetypes
   *
   * @returns {object}
  */

getGroupName

  /**
   * Gets name of group file belongs to
   *
   * @param {mimetypeParams} mimetypeParams MIME type parameters
   * @returns {string}
  */

getGroupLabels

  /**
   * Gets list of labels for groups
   *
   * @returns {array}
  */

getGroupLabel

  /**
   * Gets label for group the file belongs to
   *
   * @param {mimetypeParams} mimetypeParams MIME type parameters
   * @returns {string}
  */

getExtension

  /**
   * Gets extension for a given filename
   *
   * @param {string} fileName
   * @returns {string} Extracted extension
   */

getTypesForGroup

  /**
   * Gets list of mimetypes for a group
   *
   * @param {string} groupLabel
   * @returns {array}
  */

hasPreview

  /**
   * Checks if file type is considered previewable
   *
   * @param {mimetypeParams} mimetypeParams MIME type parameters
   * @returns {boolean}
  */

typeExists

  /**
   * Checks if type exists
   *
   * @param {mimetypeParams} mimetypeParams MIME type parameters
   * @returns {boolean}
  */

getValidTypes

  /**
   * Gets list of types for all groups
   *
   * @returns {array}
  */

License

This repository is published under the MIT license.