Socket
Socket
Sign inDemoInstall

file-groups

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    file-groups

File extensions and media types, grouped by application and type. Useful when you need to process or restrict processing to certain types of files.


Version published
Weekly downloads
17
decreased by-48.48%
Maintainers
1
Install size
29.7 kB
Created
Weekly downloads
 

Readme

Source

file-groups

File extensions and media types, grouped by application and type. Useful when you need to process or restrict processing to certain types of files.

Usage

Properties on file-groups return objects containing a set of media types and file extensions. These are accessible via the mediaTypes and extensions properties, which return an Array of Strings. By default only commonly used values are returned. To return all know values pass true to either, e.g., object.mediaTypes(true)

In some cases additional methods can be called on the object to further restrict the set.

Let's look at some examples.

Images & Video

Retrieve a list of file extensions or media types used by images and video:

const fileGroups = require('file-groups');

fileGroups.image.extensions();  // ["bmp", "gif", "ico", "jpeg", ... ]
fileGroups.image.mediaTypes();  // ["image/bmp", "image/x-ms-bmp", "image/gif", ... ]
fileGroups.video.extensions();  // ["asf", "mov", "qt", "movie", ... ]
fileGroups.video.mediaTypes();  // ["video/x-ms-asf", "video/quicktime", ... ]

Images can be filtered on by raster, vector, or web:

fileGroups.image.web.extensions();     // ["gif", "jpeg", "jpg", "png", "svg", "webp"]
fileGroups.image.raster.extensions();  // ["bmp", "gif", "ico", "jpeg", "jpg", "tif", "tiff", "webp"]
fileGroups.image.vector.extensions();  // ["svg"]

For a complete list pass in true to any of these methods:

fileGroups.image.extensions(true);  // ["bmp", "dib", "gif", "ico", "jfif", "jpe", "jpeg", ... ]

Spreadsheets

Retrieve a list of file extensions or media types used by spreadsheets:

const fileGroups = require('file-groups');

fileGroups.spreadsheet.extensions();  // ["csv", "xls", "xlsx", "xlt", ... ]
fileGroups.spreadsheet.mediaTypes();  // ["text/csv", "application/vnd.ms-excel", ... ]

If you only want values specific to CSVs:

fileGroups.spreadsheet.csv.mediaTypes();  // ["text/csv", "text/comma-separated-values" ]

If you only want values specific to Microsoft Excel:

fileGroups.spreadsheet.excel.extensions();  // ["xls", "xlsx", "xlt", "xltx", "xlw"]
fileGroups.spreadsheet.excel.mediaTypes();  // ["application/vnd.ms-excel", ... ]

Or for OpenOffice Calc:

fileGroups.spreadsheet.calc.extensions();  // ["ods", "ots"]

By default these only return common extensions, to return all:

fileGroups.spreadsheet.excel.extensions(true); // ["xls", "xlsx", "xlt", "xltx", ... ]

Everything Else

See the list of categories and tags.

Author

Skye Shaw (skye.shaw -AT- gmail)

License

https://opensource.org/licenses/MIT

Keywords

FAQs

Last updated on 13 Feb 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc