aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ext-name/readme.md
blob: 8df382bba9576f0b94f825b8009a1a58618de587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# ext-name [![Build Status](https://travis-ci.org/kevva/ext-name.svg?branch=master)](https://travis-ci.org/kevva/ext-name)

> Get the file extension and MIME type from a file


## Install

```
$ npm install --save ext-name
```


## Usage

```js
const extName = require('ext-name');

console.log(extName('foobar.tar'));
//=> [{ext: 'tar', mime: 'application/x-tar'}]

console.log(extName.mime('application/x-tar'));
//=> [{ext: 'tar', mime: 'application/x-tar'}]
```


## API

### extName(filename)

Returns an `Array` with objects with the file extension and MIME type.

#### filename

Type: `string`

Get the extension and MIME type from a filename.

### extName.mime(mimetype)

Returns an `Array` with objects with the file extension and MIME type.

#### mimetype

Type: `string`

Get the extension and MIME type from a MIME type.


## Related

* [ext-name-cli](https://github.com/kevva/ext-name-cli) - CLI for this module
* [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array


## License

MIT © [Kevin Mårtensson](https://github.com/kevva)