https://github.com/ts-stack/type-is
A fork of the widely used `type-is` library, but this one accepts headers instead of a request object.
https://github.com/ts-stack/type-is
Last synced: 6 months ago
JSON representation
A fork of the widely used `type-is` library, but this one accepts headers instead of a request object.
- Host: GitHub
- URL: https://github.com/ts-stack/type-is
- Owner: ts-stack
- License: mit
- Created: 2024-07-26T19:58:02.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-09-25T10:45:38.000Z (8 months ago)
- Last Synced: 2024-11-09T18:50:25.689Z (6 months ago)
- Language: TypeScript
- Size: 79.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @ts-stack/type-is
Infer the content-type of a request by headers. This is a fork of [type-is](https://github.com/jshttp/type-is), but this one accepts headers instead of a request object. Writen in TypeScript in format ESM.
## Install
```sh
npm install @ts-stack/type-is
```## Usage
```ts
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')
})
```## License
[MIT](LICENSE)