mime-bytes 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  // Main export file for mime-bytes package
2
2
  // Export the main detector class and convenience functions
3
- export { FileTypeDetector, defaultDetector, detectFromStream, detectFromBuffer, detectFromExtension } from './file-type-detector';
3
+ export { defaultDetector, detectFromBuffer, detectFromExtension, detectFromStream, FileTypeDetector } from './file-type-detector';
4
4
  // Export registry types and functions
5
- export { FILE_TYPES, CONTENT_TYPE_MAPPINGS, getFileTypeByMagicBytes, getFileTypeByExtension, getFileTypesByCategory, getContentTypeByExtension, detectCharset } from './file-types-registry';
5
+ export { CONTENT_TYPE_MAPPINGS, detectCharset, FILE_TYPES, getContentTypeByExtension, getFileTypeByExtension, getFileTypeByMagicBytes, getFileTypesByCategory } from './file-types-registry';
6
6
  // Export peek stream functionality
7
- export { peek, BufferPeekStream } from './peak';
7
+ export { BufferPeekStream, peek } from './peak';
8
8
  // Export utility functions
9
+ export * from './utils/extensions';
9
10
  export * from './utils/magic-bytes';
10
11
  export * from './utils/mime-types';
11
- export * from './utils/extensions';
@@ -1,5 +1,5 @@
1
1
  import { Readable } from 'stream';
2
- import { FileTypeDefinition, DetectionResult } from './file-types-registry';
2
+ import { DetectionResult, FileTypeDefinition } from './file-types-registry';
3
3
  export interface FileTypeDetectorOptions {
4
4
  peekBytes?: number;
5
5
  checkMultipleOffsets?: boolean;
@@ -5,10 +5,10 @@ exports.defaultDetector = exports.FileTypeDetector = void 0;
5
5
  exports.detectFromStream = detectFromStream;
6
6
  exports.detectFromBuffer = detectFromBuffer;
7
7
  exports.detectFromExtension = detectFromExtension;
8
- const peak_1 = require("./peak");
9
8
  const file_types_registry_1 = require("./file-types-registry");
10
- const magic_bytes_1 = require("./utils/magic-bytes");
9
+ const peak_1 = require("./peak");
11
10
  const extensions_1 = require("./utils/extensions");
11
+ const magic_bytes_1 = require("./utils/magic-bytes");
12
12
  const mime_types_1 = require("./utils/mime-types");
13
13
  class FileTypeDetector {
14
14
  fileTypes;
@@ -254,7 +254,7 @@ class FileTypeDetector {
254
254
  if (lastDot !== -1) {
255
255
  const extension = filename.substring(lastDot + 1);
256
256
  // Check for generic text files that might have specific content types
257
- if (magicResult.name === 'text' && magicResult.charset) {
257
+ if (magicResult.mimeType === 'text/plain' && magicResult.charset) {
258
258
  const contentType = (0, file_types_registry_1.getContentTypeForExtension)(extension, magicResult.charset);
259
259
  if (contentType) {
260
260
  // Enhance the result with charset-aware content type