### Developing a Svelte Project Source: https://github.com/redmundas/file-type-mime/blob/main/websites/file-type-mime/README.md Commands to start the development server for a Svelte application after dependencies are installed, including an option to automatically open the app in a browser tab. ```bash npm run dev # or start the server and open the app in a new browser tab npm run dev -- --open ``` -------------------------------- ### Creating a Svelte Project with npm Source: https://github.com/redmundas/file-type-mime/blob/main/websites/file-type-mime/README.md Instructions to initialize a new Svelte project using `npm create svelte@latest`, either in the current directory or a specified new directory. ```bash # create a new project in the current directory npm create svelte@latest # create a new project in my-app npm create svelte@latest my-app ``` -------------------------------- ### Building a Svelte Project for Production Source: https://github.com/redmundas/file-type-mime/blob/main/websites/file-type-mime/README.md Command to create a production-ready build of the Svelte application. Mentions `npm run preview` for testing the build and the need for adapters for deployment. ```bash npm run build ``` -------------------------------- ### file-type-mime API Reference Source: https://github.com/redmundas/file-type-mime/blob/main/README.md Detailed API documentation for the `file-type-mime` library, including the `parse` function signature, arguments, and return types. ```APIDOC function parse(buffer: ArrayBuffer, options: Options = {}): Result | undefined Arguments: buffer: Type: ArrayBuffer Description: A buffer representing file data options (optional): Type: { extra?: boolean; hint?: { ext?: string; mime?: string } } Description: hint - used to short-circuit general flow by filtering signatures list extra - used to parse additional file type formats (like json, txt) Return: Type: { ext: string; mime: string } | undefined ``` -------------------------------- ### file-type-mime API Reference Source: https://github.com/redmundas/file-type-mime/blob/main/packages/file-type-mime/README.md Detailed API documentation for the `parse` function, including its signature, arguments, and return type. It describes how to use the function to determine file MIME types from an ArrayBuffer. ```APIDOC Signature: function parse(buffer: ArrayBuffer, options: Options = {}): Result | undefined Arguments: buffer: Type: ArrayBuffer Description: A buffer representing file data options (optional): Type: { extra?: boolean; hint?: { ext?: string; mime?: string } } Description: hint: used to short-circuit general flow by filtering signatures list extra: used to parse additional file type formats (like json, txt) Return: Type: { ext: string; mime: string } | undefined ``` -------------------------------- ### Supported File Extension to MIME Type Mappings Source: https://github.com/redmundas/file-type-mime/blob/main/packages/file-type-mime/README.md This table lists common file extensions and their standard content (MIME) types. It serves as a lookup for identifying file formats based on their extensions, which is essential for content handling and validation. ```APIDOC | File extension | Content (mime) type | | -------------- | ------------------------------------------------------------------------- | | bmp | image/bmp | | gif | image/gif | | ico | image/x-icon | | jpg | image/jpeg | | heic | image/heic | | png | image/png | | tiff | image/tiff | | pdf | application/pdf | | rtf | application/rtf | | epub | application/epub+zip | | gz | application/gzip | | jar | application/java-archive | | zip | application/zip | | bz2 | application/x-bzip2 | | rar | application/x-rar-compressed | | tar | application/x-tar | | docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document | | pptx | application/vnd.openxmlformats-officedocument.presentationml.presentation | | xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | | opd | application/vnd.oasis.opendocument.presentation | | ods | application/vnd.oasis.opendocument.spreadsheet | | odt | application/vnd.oasis.opendocument.text | | db | application/vnd.sqlite3 | | 7z | application/x-7z-compressed | | avi | video/x-msvideo | | mp3 | audio/mp3 | | mp4 | video/mp4 | | oga | audio/ogg | | ogg | audio/ogg | | ogm | video/ogg | | ogv | video/ogg | | ogx | application/ogg | | wav | audio/wav | | woff | font/woff | | woff2 | font/woff2 | | deb | application/x-deb | | flac | audio/x-flac | | psd | image/vnd.adobe.photoshop | | wasm | application/wasm | | webp | image/webp | | class | application/java-vm | | exe | application/x-msdownload | | parquet | application/vnd.apache.parquet | | json | application/json | | txt | text/plain | | vsix | application/vsix | | mov | video/quicktime | | afiv | image/avif | | m4v | video/x-m4v | | m4a | audio/mp4 | ``` -------------------------------- ### File Extension to MIME Type Mapping Source: https://github.com/redmundas/file-type-mime/blob/main/README.md A comprehensive table mapping various file extensions to their standard content (MIME) types. This list details the formats supported by the file-type-mime project. ```APIDOC | File extension | Content (mime) type | | -------------- | ------------------------------------------------------------------------- | | bmp | image/bmp | | gif | image/gif | | ico | image/x-icon | | jpg | image/jpeg | | heic | image/heic | | png | image/png | | tiff | image/tiff | | pdf | application/pdf | | rtf | application/rtf | | epub | application/epub+zip | | gz | application/gzip | | jar | application/java-archive | | zip | application/zip | | bz2 | application/x-bzip2 | | rar | application/x-rar-compressed | | tar | application/x-tar | | docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document | | pptx | application/vnd.openxmlformats-officedocument.presentationml.presentation | | xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | | opd | application/vnd.oasis.opendocument.presentation | | ods | application/vnd.oasis.opendocument.spreadsheet | | odt | application/vnd.oasis.opendocument.text | | db | application/vnd.sqlite3 | | 7z | application/x-7z-compressed | | avi | video/x-msvideo | | mp3 | audio/mp3 | | mp4 | video/mp4 | | oga | audio/ogg | | ogg | audio/ogg | | ogm | video/ogg | | ogv | video/ogg | | ogx | application/ogg | | wav | audio/wav | | woff | font/woff | | woff2 | font/woff2 | | deb | application/x-deb | | flac | audio/x-flac | | psd | image/vnd.adobe.photoshop | | wasm | application/wasm | | webp | image/webp | | class | application/java-vm | | exe | application/x-msdownload | | parquet | application/vnd.apache.parquet | | json | application/json | | txt | text/plain | | vsix | application/vsix | | mov | video/quicktime | | afiv | image/avif | | m4v | video/x-m4v | | m4a | audio/mp4 | ``` -------------------------------- ### Parse MIME Type in Node.js Source: https://github.com/redmundas/file-type-mime/blob/main/packages/file-type-mime/README.md Shows how to use `file-type-mime` in a Node.js environment to parse the MIME type of a local file. It reads the file into a buffer using `node:fs` and then passes it to the `parse` function. ```javascript import { parse } from "file-type-mime"; import { readFileSync } from "node:fs"; import { resolve } from "node:path"; const file = resolve("./path/to/file.pdf"); const buffer = readFileSync(file); const result = parse(buffer); console.log("MIME_TYPE", result); ``` -------------------------------- ### Parse MIME Type in Node.js Source: https://github.com/redmundas/file-type-mime/blob/main/README.md Shows how to parse the MIME type of a local file in a Node.js environment. It reads the file into a buffer using `node:fs` and then processes it with the `file-type-mime` library. ```javascript import { parse } from "file-type-mime"; import { readFileSync } from "node:fs"; import { resolve } from "node:path"; const file = resolve("./path/to/file.pdf"); const buffer = readFileSync(file); const result = parse(buffer); console.log("MIME_TYPE", result); ``` -------------------------------- ### Parse MIME Type in Browser (React) Source: https://github.com/redmundas/file-type-mime/blob/main/packages/file-type-mime/README.md Demonstrates how to use `file-type-mime` in a React application to parse the MIME type of a file selected via an input element. It reads the file as an ArrayBuffer and then uses the `parse` function. ```javascript import { parse } from 'file-type-mime'; export default function fileUpload() { async function onChange(e) { const [file] = e.target.files; const buffer = await file.arrayBuffer(); const result = parse(buffer); console.log('MIME_TYPE', result); } return (
); } ``` -------------------------------- ### Parse MIME Type in Browser (React) Source: https://github.com/redmundas/file-type-mime/blob/main/README.md Demonstrates how to parse the MIME type of a file selected via an HTML input element in a React application. It reads the file content into an ArrayBuffer and uses the `file-type-mime` library's `parse` function. ```javascript import { parse } from 'file-type-mime'; export default function fileUpload() { async function onChange(e) { const [file] = e.target.files; const buffer = await file.arrayBuffer(); const result = parse(buffer); console.log('MIME_TYPE', result); } return ( ); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.