Supported asset detection and types for Scratch backend
Find a file
2018-04-26 19:02:13 -04:00
lib Add test for wav 2018-01-17 11:02:31 -05:00
test Add test for wav 2018-01-17 11:02:31 -05: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
.travis.yml update environment to node 8 for travis build 2018-04-26 19:02:13 -04:00
index.js Add linting rules, add synchronous and asynchronous checks and appropriate 2018-01-17 10:53:16 -05:00
Makefile works with our existing list of types 2018-01-17 09:01:38 -05:00
package-lock.json Fixes issue/2 2018-04-26 18:49:57 -04:00
package.json update license to MIT 2018-04-26 19:01:52 -04:00
README.md Add build status 2018-01-18 09:38:42 -05: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 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.