media-typer

WebJar for media-typer

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

media-typer
Последняя версия

Последняя версия

0.3.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

media-typer
WebJar for media-typer
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/jshttp/media-typer

Скачать media-typer

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/media-typer/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>media-typer</artifactId>
    <version>0.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/media-typer/
implementation 'org.webjars.npm:media-typer:0.3.0'
// https://jarcasting.com/artifacts/org.webjars.npm/media-typer/
implementation ("org.webjars.npm:media-typer:0.3.0")
'org.webjars.npm:media-typer:jar:0.3.0'
<dependency org="org.webjars.npm" name="media-typer" rev="0.3.0">
  <artifact name="media-typer" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='media-typer', version='0.3.0')
)
libraryDependencies += "org.webjars.npm" % "media-typer" % "0.3.0"
[org.webjars.npm/media-typer "0.3.0"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

media-typer

NPM Version NPM Downloads Node.js Version Build Status Test Coverage

Simple RFC 6838 media type parser.

This module will parse a given media type into it's component parts, like type, subtype, and suffix. A formatter is also provided to put them back together and the two can be combined to normalize media types into a canonical form.

If you are looking to parse the string that represents a media type and it's parameters in HTTP (for example, the Content-Type header), use the content-type module.

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install media-typer

API

var typer = require('media-typer')

typer.parse(string)

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

Parse a media type string. This will return an object with the following properties (examples are shown for the string 'image/svg+xml; charset=utf-8'):

  • type: The type of the media type (always lower case). Example: 'image'

  • subtype: The subtype of the media type (always lower case). Example: 'svg'

  • suffix: The suffix of the media type (always lower case). Example: 'xml'

If the given type string is invalid, then a TypeError is thrown.

typer.format(obj)

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

Format an object into a media type string. This will return a string of the mime type for the given object. For the properties of the object, see the documentation for typer.parse(string).

If any of the given object values are invalid, then a TypeError is thrown.

typer.test(string)

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

Validate a media type string. This will return true is the string is a well- formatted media type, or false otherwise.

License

MIT

org.webjars.npm
Low-Level JavaScript HTTP-related Modules

Версии библиотеки

Версия
0.3.0
0.2.0