Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on Apr 11, 2024 via pnpm

media-typer 0.3.0

Simple RFC 6838 media type parser and formatter
Package summary
Share
0
issues
1
license
1
MIT
Package created
13 Jun 2014
Version published
8 Sep 2014
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
media-typer@0.3.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of media-typer 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does media-typer do?

Media-Typer is an efficient tool for managing media types in your JavaScript applications. It functions as a simple RFC 6838 media type parser and formatter which can accurately parse a given media type into its component parts such as type, subtype and suffix. Moreover, it also includes a formatter that can compile these component parts back together. This dual functionality allows it to be effectively used for normalizing media types into a canonical form. Please note, if you wish to parse the string that represents a media type and its parameters as commonly found in HTTP like in 'Content-Type' header, it is suggested to use the content-type module.

How do you use media-typer?

Using Media-Typer in your program is straightforward. First, you will need to install it from the npm registry. You can simply do this with the npm install command like: npm install media-typer.

Once you have installed it, require it in your project as such:

var typer = require('media-typer')

To parse a media type string, you can call the parse function on the required object, passing the media type string as an argument. For example:

var obj = typer.parse('image/svg+xml')

This will return an object with the format as described in the 'parse(string)' section of the readme.

Similarly, if you wish to format an object into a media type string, you can do so using the format function, passing the object as the argument. For example:

var obj = typer.format({ type: 'image', subtype: 'svg', suffix: 'xml' })

This would return a media type string in the required format.

Finally, to validate a media-type string, call the test function on the desired string:

var valid = typer.test('image/svg+xml')

This returns true if the string is well-formatted, and false otherwise.

Please note, TypeError is thrown if an invalid type string or invalid object values are provided to the parse and format functions respectively.

Where are the media-typer docs?

The official documentation and more detailed usage guidelines for media-typer can be found directly in the README file of the GitHub project repository - https://github.com/jshttp/media-typer.git. It contains robust instructions for installation, API usage as well as license information. For more complex or specific issues, users might find it helpful to refer directly to the source code which is also available in the repository.