Supported asset detection and types for Scratch backend
Find a file
Colby Gutierrez-Kraybill f5af1f8486
Merge pull request from colbygk/release/1.1.0
Release/1.1.0

Fixes issue 
Adds support for mp3 detection
Updates license to MIT
Updates testing environment to node 8
Updates version to 1.1.0
2018-04-26 20:02:26 -04:00
lib Add support for detecting mp3 audio 2018-04-26 19:49:49 -04:00
test Add support for detecting mp3 audio 2018-04-26 19:49:49 -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
.travis.yml update environment to node 8 for travis build 2018-04-26 19:02:13 -04:00
index.js Add support for detecting mp3 audio 2018-04-26 19:49:49 -04: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 version to 1.1.0 2018-04-26 20:00:18 -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.