You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # ext-name [![Build Status](https://travis-ci.org/kevva/ext-name.svg?branch=master)](https://travis-ci.org/kevva/ext-name)
  2. > Get the file extension and MIME type from a file
  3. ## Install
  4. ```
  5. $ npm install --save ext-name
  6. ```
  7. ## Usage
  8. ```js
  9. const extName = require('ext-name');
  10. console.log(extName('foobar.tar'));
  11. //=> [{ext: 'tar', mime: 'application/x-tar'}]
  12. console.log(extName.mime('application/x-tar'));
  13. //=> [{ext: 'tar', mime: 'application/x-tar'}]
  14. ```
  15. ## API
  16. ### extName(filename)
  17. Returns an `Array` with objects with the file extension and MIME type.
  18. #### filename
  19. Type: `string`
  20. Get the extension and MIME type from a filename.
  21. ### extName.mime(mimetype)
  22. Returns an `Array` with objects with the file extension and MIME type.
  23. #### mimetype
  24. Type: `string`
  25. Get the extension and MIME type from a MIME type.
  26. ## Related
  27. * [ext-name-cli](https://github.com/kevva/ext-name-cli) - CLI for this module
  28. * [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array
  29. ## License
  30. MIT © [Kevin Mårtensson](https://github.com/kevva)