Skip to content

Commit

Permalink
Merge pull request #7 from ruiquelhas/support/update-documentation
Browse files Browse the repository at this point in the history
Update documentation
  • Loading branch information
ruiquelhas committed Dec 19, 2015
2 parents a43ed55 + fb140b7 commit 42392c2
Showing 1 changed file with 21 additions and 35 deletions.
56 changes: 21 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,59 +20,45 @@ $ npm install magik
## Usage

### `guess(buffer, fn)`
Get the list of file types that match the buffer signature. If the input is not a buffer or the buffer signature is invalid, it results in an error.
Get the list of file types that match the buffer signature. If the input is not a `Buffer` or the buffer signature is invalid, it results in an error.

#### Examples

```js
const Magik = require('magik');

const png = new Buffer([0x89, 0x50]);
Magik.guess(png, (err, types) => {
console.log(types); // ['png']
Magik.guess(new Buffer([0x89, 0x50]), (err, types) => {

console.log(types); // ['png']
});

const unknown = new Buffer([0x00, 0x00]);
Magik.guess(unknown, (err, types) => {
console.log(types); // []
Magik.guess(new Buffer([0x00, 0x00]), (err, types) => {

console.log(types); // []
});

const input = {};
Magik.guess(input, (err, types) => {
console.log(err); // [Error: invalid input type]
Magik.guess({}, (err, types) => {

console.log(err); // [Error: invalid input type]
});

const invalid = new Buffer([0xFF]);
Magik.guess(invalid, (err, types) => {
console.log(err); // [Error: invalid file signature]
Magik.guess(new Buffer([0xFF]), (err, types) => {

console.log(err); // [Error: invalid file signature]
});
```

## Supported File Types

Currently, the following file types are supported:

* `gz`, `gzip`
* `pdf`
* `asf`, `wma`, `wmv`
* `mp4`, `mpeg4`
* `7z`
* `bz`, `bz2`, `bzip`
* `bmp`
* `iso`
* `aif`, `aifc`, `aiff`, `iff`, `snd`
* `gif`
* `mp3`, `mpeg1`, `mpeg2`
* `tif`, `tiff`
* `oga`, `ogg`, `ogv`
* `pkzip`, `zip`
* `avi`, `wav`
* `flac`
* `3g2`, `3gp`
* `tar`
* `dmg`
* `png`
* `doc`, `xls`, `ppt`
* `jpg`, `jpeg`
Category | Type
-------- | ----------
Audio/Video | `3g2`, `3gp`, `aif`, `aifc`, `aiff`, `asf`, `avi`, `flac`, `iff`, `mp3`, `mp4`, `mpeg1`, `mpeg2`, `mpeg4`, `oga`, `ogg`, `ogv`, `snd`, `wav`, `wma`, `wmv`
Compression | `7z`, `bz`, `bz2`, `bzip`, `gz`, `gzip`, `pkzip`, `tar`, `zip`
Documents | `doc`, `pdf`, `ppt`, `xls`
Images | `bmp`, `gif`, `jpg`, `jpeg`, `png`, `tif`, `tiff`
Miscellaneous | `dmg`, `iso`

[coveralls-img]: https://coveralls.io/repos/ruiquelhas/magik/badge.svg
[coveralls-url]: https://coveralls.io/github/ruiquelhas/magik
Expand Down

0 comments on commit 42392c2

Please sign in to comment.