Supported asset detection and types for Scratch backend
Find a file
Colby Gutierrez-Kraybill ef21497c4d
Update package.json patch level
Bump patch level
2024-04-24 17:39:42 -04:00
.github ci: use npm ci 2023-11-30 11:17:40 -05:00
lib Merge branch 'develop' into update_svg_detection 2022-03-11 17:36:36 -05:00
test Merge branch 'update_svg_detection' of github.com:colbygk/scratch-asset-types into update_svg_detection 2022-03-15 11:38:00 -04:00
.eslintignore Add linting rules, add synchronous and asynchronous checks and appropriate 2018-01-17 10:53:16 -05:00
.eslintrc.js Add linting rules, add synchronous and asynchronous checks and appropriate 2018-01-17 10:53:16 -05:00
.gitignore Ignore the usual 2018-01-17 09:04:15 -05:00
.npmignore add travis support and npm handling support 2018-01-17 11:15:41 -05:00
.nvmrc chore: add nvmrc file 2023-11-15 10:18:55 -05:00
index.js Merge branch 'develop' into update_svg_detection 2022-03-11 17:36:36 -05:00
LICENSE Add correct license and trademark notices 2018-06-18 14:50:12 -04:00
Makefile works with our existing list of types 2018-01-17 09:01:38 -05:00
package-lock.json ci: move devDependencies to dependencies 2023-11-30 11:17:00 -05:00
package.json Update package.json patch level 2024-04-24 17:39:42 -04:00
README.md Add check on filename extension. Add SVG soft detection. 2022-03-11 15:49:28 -05:00
TRADEMARK Add correct license and trademark notices 2018-06-18 14:50:12 -04:00

scratch-asset-types Build Status

A library for detecting types for Scratch backend services that is optimized for the specific file types that Scratch services depend on.

Usage:

Three possible use cases:

bufferCheck, syncCheck, asyncCheck

These will return null if the type is not recognized. If recognized, a JSON object will be returned of the form:

{ext: 'gif', mime: 'image/gif'}

Examples:

Synchronous check on if a filename includes an acceptable extension:

const assetTypes = require('scratch-asset-types');
const result = assetTypes.acceptableExtension('filename');

Synchronous check on a buffer:

const assetTypes = require('scratch-asset-types');
const result = assetTypes.bufferCheck(someBuffer);

Synchronous check on a filename:

const assetTypes = require('scratch-asset-types');
const result = assetTypes.syncCheck('full/path/to/filename');

Asynchronous check on a filename:

const assetTypes = require('scratch-asset-types');
assetTypes.asyncCheck('full/path/to/filename').then( ... );

There is no asynchronous check on a buffer as that would be highly inefficent.

Thanks to file-type

This library is derived from the more general file-type npm module.