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 String
s. 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();
fileGroups.image.mediaTypes();
fileGroups.video.extensions();
fileGroups.video.mediaTypes();
Images can be filtered on by raster, vector, or web:
fileGroups.image.web.extensions();
fileGroups.image.raster.extensions();
fileGroups.image.vector.extensions();
For a complete list pass in true
to any of these methods:
fileGroups.image.extensions(true);
Spreadsheets
Retrieve a list of file extensions or media types used by spreadsheets:
const fileGroups = require('file-groups');
fileGroups.spreadsheet.extensions();
fileGroups.spreadsheet.mediaTypes();
If you only want values specific to CSVs:
fileGroups.spreadsheet.csv.mediaTypes();
If you only want values specific to Microsoft Excel:
fileGroups.spreadsheet.excel.extensions();
fileGroups.spreadsheet.excel.mediaTypes();
Or for OpenOffice Calc:
fileGroups.spreadsheet.calc.extensions();
By default these only return common extensions, to return all:
fileGroups.spreadsheet.excel.extensions(true);
Everything Else
See the list of categories and tags.
Author
Skye Shaw (skye.shaw -AT- gmail)
License
https://opensource.org/licenses/MIT