Supported asset detection and types for Scratch backend
Find a file
2023-02-28 05:09:54 +07:00
.circleci remove the 'npm build' step from the circleci config 2023-02-28 05:09:54 +07: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
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 Add CircleCI config folder & file 2023-02-28 05:01:08 +07:00
package.json Update version to 1.2.0 2022-03-15 12:18:29 -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.