From 080abb013821e8921604aeed3f3696e49b6dd1a8 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Tue, 28 May 2024 11:52:26 +0200 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 2 +- ts/index.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 575f59e..6e108b2 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartmime', - version: '2.0.0', + version: '2.0.1', description: 'A module for detecting MIME types with support for binary and text file distinctions.' } diff --git a/ts/index.ts b/ts/index.ts index 1e61ec1..b44cbca 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -39,3 +39,11 @@ export const getEncoding = async (optionsArg: { }) => { return (await isBinary(optionsArg)) ? 'binary' : 'utf8'; }; + +/** + * Synchronous version to get encoding based on the file extension + */ +export const getPathEncodingSync = (path: string): 'binary' | 'utf8' => { + const mimeType = plugins.mime.getType(path); + return binaryMimeTypes.includes(mimeType) ? 'binary' : 'utf8'; +}; \ No newline at end of file