Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

file-groups

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

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.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
84
increased by2.44%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 13 Feb 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc