Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/enniel/promise-mmmagic
https://github.com/enniel/promise-mmmagic
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/enniel/promise-mmmagic
- Owner: enniel
- License: mit
- Created: 2017-05-04T09:13:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-10-26T17:07:00.000Z (about 4 years ago)
- Last Synced: 2024-12-06T09:18:16.195Z (about 2 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# promise-mmmagic
Add `Promise` support for [mmmagic](https://github.com/mscdex/mmmagic).
## Installation
```sh
npm install promise-mmmagic
```
or```sh
yarn add promise-mmmagic
```## Example
```js
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)
})
```## Credits
- [Evgeni Razumov](https://github.com/enniel)
## Support
Having trouble? [Open an issue](https://github.com/enniel/promise-mmmagic/issues/new)!
## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.