file-is

1.0.0 • Public • Published

file-is

NPM version Build status Test coverage Dependency Status License Downloads

Check the mime type of a file or binary. A thin wrapper around type-is and mmmagic.

const is = require('file-is')
 
is('./some/image.png', 'image/*').then(type => console.log(type))
is(new Buffer('something'), 'text/*').then(type => console.log(type))

API

is(String | Buffer | Stream, types...).then( type => )

The first input can be a string for the filename or a buffer/stream for the actual contents. The content can not be a string because then there's no point in using this library.

types is an array or argument of types. See typeis.is() for more details.

type is the first match in the list of types.

Package Sidebar

Install

npm i file-is

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jongleberry