# scratch-asset-types **Repository Path**: mirrors_llk/scratch-asset-types ## Basic Information - **Project Name**: scratch-asset-types - **Description**: Supported asset detection and types for Scratch backend - **Primary Language**: Unknown - **License**: BSD-3-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-02-27 - **Last Updated**: 2025-09-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # scratch-asset-types ![Build Status](https://travis-ci.org/LLK/scratch-asset-types.svg?branch=master) 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: ```json {ext: 'gif', mime: 'image/gif'} ``` Examples: Synchronous check on if a filename includes an acceptable extension: ```javascript const assetTypes = require('scratch-asset-types'); const result = assetTypes.acceptableExtension('filename'); ``` Synchronous check on a buffer: ```javascript const assetTypes = require('scratch-asset-types'); const result = assetTypes.bufferCheck(someBuffer); ``` Synchronous check on a filename: ```javascript const assetTypes = require('scratch-asset-types'); const result = assetTypes.syncCheck('full/path/to/filename'); ``` Asynchronous check on a filename: ```javascript 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](https://www.npmjs.com/package/file-type) npm module.