content-check
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published


Content-Check
API Stability TypeScript Styled with prettier Build status Test Coverage NPM Version Downloads Browser Bundle Size

Utility for working with the content-type header isomorphically.

Installation

npm install content-check

API

check(data: any): string|undefined

Attempt to guess the content type for some data. Returns undefined if it could not be guessed.

import * as fs from "fs";
import { check } from "content-check";
 
check("hello"); // "text/plain"
check("<body></body>"); // "text/html"
check({ a: 1 }); // "application/json"
check(new Buffer("hello")); // "application/octet-stream"
check(fs.createReadStream(__dirname + "/index.js")); // "application/javascript"

Contributions

  • Use npm test to run tests.

Please feel free to create a PR!

Package Sidebar

Install

npm i content-check

Weekly Downloads

81

Version

1.0.4

License

MIT

Last publish

Collaborators

  • dylanpiercey