Add Promise
support for mmmagic.
npm install promise-mmmagic
or
yarn add promise-mmmagic
const fs = require('fs')
const Magic = require('promise-mmmagic')
const magicFile = 'node_modules/mmmagic/src/binding.cc'
const magic = new Magic(Magic.MAGIC_MIME_TYPE)
// file path
magic
.detectFile(magicFile)
.then(result => {
// text/x-c++
console.log(result)
})
// buffer
const buffer = fs.readFileSync(magicFile)
magic
.detect(buffer)
.then(result => {
// text/x-c++
console.log(result)
})
Having trouble? Open an issue!
The MIT License (MIT). Please see License File for more information.