Adjust MIMEType Predicate Signatures (#4832)
This commit is contained in:
parent
06dd10844d
commit
819554f6b3
1 changed files with 9 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2018-2020 Signal Messenger, LLC
|
// Copyright 2018-2021 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
export type MIMEType = string & { _mimeTypeBrand: never };
|
export type MIMEType = string & { _mimeTypeBrand: never };
|
||||||
|
@ -17,12 +17,13 @@ export const VIDEO_MP4 = 'video/mp4' as MIMEType;
|
||||||
export const VIDEO_QUICKTIME = 'video/quicktime' as MIMEType;
|
export const VIDEO_QUICKTIME = 'video/quicktime' as MIMEType;
|
||||||
export const LONG_MESSAGE = 'text/x-signal-plain' as MIMEType;
|
export const LONG_MESSAGE = 'text/x-signal-plain' as MIMEType;
|
||||||
|
|
||||||
export const isJPEG = (value: MIMEType): boolean => value === 'image/jpeg';
|
export const isJPEG = (value: string): value is MIMEType =>
|
||||||
export const isImage = (value: MIMEType): boolean =>
|
value === 'image/jpeg';
|
||||||
value && value.startsWith('image/');
|
export const isImage = (value: string): value is MIMEType =>
|
||||||
export const isVideo = (value: MIMEType): boolean =>
|
Boolean(value) && value.startsWith('image/');
|
||||||
value && value.startsWith('video/');
|
export const isVideo = (value: string): value is MIMEType =>
|
||||||
|
Boolean(value) && value.startsWith('video/');
|
||||||
// As of 2020-04-16 aif files do not play in Electron nor Chrome. We should only
|
// As of 2020-04-16 aif files do not play in Electron nor Chrome. We should only
|
||||||
// recognize them as file attachments.
|
// recognize them as file attachments.
|
||||||
export const isAudio = (value: MIMEType): boolean =>
|
export const isAudio = (value: string): value is MIMEType =>
|
||||||
value && value.startsWith('audio/') && !value.endsWith('aiff');
|
Boolean(value) && value.startsWith('audio/') && !value.endsWith('aiff');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue