mime-bytes 0.0.2 → 0.2.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/README.md CHANGED
@@ -14,13 +14,13 @@
14
14
 
15
15
  **Lightning-fast file type detection using magic bytes (file signatures) with a focus on stream processing and minimal memory usage.**
16
16
 
17
- [Features](#-features) • [Installation](#-installation) • [Quick Start](#-quick-start) • [API](#-api) • [File Types](#-supported-file-types) • [Performance](#-performance)
17
+ [Features](#features) • [Installation](#installation) • [Quick Start](#quick-start) • [API](#api) • [File Types](#supported-file-types) • [Performance](#performance)
18
18
 
19
19
  </div>
20
20
 
21
21
  ---
22
22
 
23
- ## Features
23
+ ## Features
24
24
 
25
25
  - 🚀 **Stream-based detection** - Process files of any size without loading them into memory
26
26
  - 📦 **100+ file types** - Comprehensive coverage of common and specialized formats
@@ -33,13 +33,13 @@
33
33
  - 🌐 **Charset detection** - Automatic encoding detection for text files
34
34
  - 🛡️ **Robust error handling** - Graceful degradation for unknown formats
35
35
 
36
- ## 📦 Installation
36
+ ## Installation
37
37
 
38
38
  ```bash
39
39
  npm install mime-bytes
40
40
  ```
41
41
 
42
- ## 🚀 Quick Start
42
+ ## Quick Start
43
43
 
44
44
  ```typescript
45
45
  import { FileTypeDetector } from 'mime-bytes';
@@ -63,7 +63,7 @@ console.log(fileType);
63
63
  // }
64
64
  ```
65
65
 
66
- ## 📖 API
66
+ ## API
67
67
 
68
68
  ### FileTypeDetector
69
69
 
@@ -200,7 +200,7 @@ interface FileTypeResult {
200
200
  }
201
201
  ```
202
202
 
203
- ## 🗂️ Supported File Types
203
+ ## Supported File Types
204
204
 
205
205
  ### Images (30+ formats)
206
206
  - **Common**: PNG, JPEG, GIF, WebP, SVG, ICO
@@ -242,7 +242,7 @@ interface FileTypeResult {
242
242
  - **Database**: SQLite
243
243
  - **Disk Images**: ISO, DMG
244
244
 
245
- ## Performance
245
+ ## Performance
246
246
 
247
247
  mime-bytes is designed for speed and efficiency:
248
248
 
@@ -323,7 +323,7 @@ async function detectMultipleFiles(files: string[]) {
323
323
  }
324
324
  ```
325
325
 
326
- ## 🛡️ Error Handling
326
+ ## Error Handling
327
327
 
328
328
  ```typescript
329
329
  try {
@@ -341,7 +341,7 @@ try {
341
341
  }
342
342
  ```
343
343
 
344
- ## 🤝 Contributing
344
+ ## Contributing
345
345
 
346
346
  Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
347
347
 
@@ -248,7 +248,7 @@ export class FileTypeDetector {
248
248
  if (lastDot !== -1) {
249
249
  const extension = filename.substring(lastDot + 1);
250
250
  // Check for generic text files that might have specific content types
251
- if (magicResult.name === 'text' && magicResult.charset) {
251
+ if (magicResult.mimeType === 'text/plain' && magicResult.charset) {
252
252
  const contentType = getContentTypeForExtension(extension, magicResult.charset);
253
253
  if (contentType) {
254
254
  // Enhance the result with charset-aware content type
@@ -1090,7 +1090,7 @@ export const CONTENT_TYPE_MAPPINGS = [
1090
1090
  [['md'], 'text/markdown', 'utf-8'],
1091
1091
  [['scss'], 'text/x-scss', 'utf-8'],
1092
1092
  [['sh'], 'application/x-sh', 'utf-8'],
1093
- [['sql'], 'application/sql', 'utf-8'],
1093
+ [['sql'], 'application/x-sql', 'utf-8'],
1094
1094
  [['yaml'], 'application/x-yaml', 'utf-8'],
1095
1095
  [['yml'], 'application/x-yaml', 'utf-8'],
1096
1096
  [['jsx'], 'text/jsx', 'utf-8'],
@@ -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
@@ -1099,7 +1099,7 @@ exports.CONTENT_TYPE_MAPPINGS = [
1099
1099
  [['md'], 'text/markdown', 'utf-8'],
1100
1100
  [['scss'], 'text/x-scss', 'utf-8'],
1101
1101
  [['sh'], 'application/x-sh', 'utf-8'],
1102
- [['sql'], 'application/sql', 'utf-8'],
1102
+ [['sql'], 'application/x-sql', 'utf-8'],
1103
1103
  [['yaml'], 'application/x-yaml', 'utf-8'],
1104
1104
  [['yml'], 'application/x-yaml', 'utf-8'],
1105
1105
  [['jsx'], 'text/jsx', 'utf-8'],
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "mime-bytes",
3
- "version": "0.0.2",
3
+ "version": "0.2.0",
4
4
  "author": "Dan Lynch <pyramation@gmail.com>",
5
- "description": "mime-bytes",
5
+ "description": "Lightning-fast file type detection using magic bytes (file signatures) with a focus on stream processing and minimal memory usage",
6
6
  "main": "index.js",
7
7
  "module": "esm/index.js",
8
8
  "types": "index.d.ts",
@@ -34,5 +34,5 @@
34
34
  "@types/glob": "^8.1.0",
35
35
  "glob": "^11.0.2"
36
36
  },
37
- "gitHead": "52bbc49baf1ed0e4a1b1f349bf1817b3f71f72b0"
37
+ "gitHead": "d3f4befdbf70969bef95d742dbdbe131a064919c"
38
38
  }