@ts-stack/type-is
v1.0.1
Published
A fork of the widely used `type-is` library, but this one accepts headers instead of a request object.
Downloads
767
Readme
@ts-stack/type-is
Infer the content-type of a headers.
Install
npm install @ts-stack/type-is
Usage
import http from 'http';
import { typeIs } from '@ts-stack/type-is';
http.createServer(function (req, res) {
const istext = typeIs(req.headers, ['text/*'])
res.end('you ' + (istext ? 'sent' : 'did not send') + ' me text')
})