Added 'isImage' and 'isType' functions

This commit is contained in:
n1474335 2018-12-26 18:40:27 +00:00
parent f355fe3447
commit f4f9b5c91c
6 changed files with 130 additions and 105 deletions

View file

@ -9,7 +9,7 @@ import { fromHex } from "../lib/Hex";
import Operation from "../Operation";
import OperationError from "../errors/OperationError";
import Utils from "../Utils";
import { detectFileType } from "../lib/FileType";
import { isType, detectFileType } from "../lib/FileType";
/**
* PlayMedia operation
@ -66,8 +66,7 @@ class PlayMedia extends Operation {
// Determine file type
const types = detectFileType(input);
if (!(types && types.length && /^audio|video/.test(types[0].mime))) {
if (!isType(/^(audio|video)/, input)) {
throw new OperationError("Invalid or unrecognised file type");
}