1.0.0 • Published 10 years ago
file-is v1.0.0
file-is
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.