@kikobeats/content-type
v1.0.3
Published
A fast way to get the content type from the input string.
Downloads
31,714
Maintainers
Readme
@kikobeats/content-type
A fast way to get the content type from the input string.
This is a lightweight version of jshttp/content-type for scenarios where you only want to get the content type value without parameters.
It's 90% faster; see benchmark to know more.
Install
$ npm install @kikobeats/content-type --saveUsage
Let's say the input string is 'text/html; charset=utf-8;'.
Use the library to return the content type stripping parameters:
const contentType = require('@kikobeats/content-type')
contentType(res.headers['content-type'])
// => text/htmlAPI
getContentType(input, [options])
input
Required
Type: string
The input for getting the content type.
options
strict
Type: boolean
Default: false
When strict is enabled, it will return null when the input doesn not follow conten-type header spec.
License
@kikobeats/content-type © Kiko Beats, released under the MIT License. Authored and maintained by Kiko Beats with help from contributors.
kikobeats.com · GitHub Kiko Beats · Twitter @kikobeats
