From e2f1a1cf97e91d8ac5bf8ef7439d597ee1f0e246 Mon Sep 17 00:00:00 2001 From: Borewit Date: Wed, 11 Dec 2024 14:46:05 +0100 Subject: [PATCH] Add instructions on how to load file-type in a CommonJS + TypeScript (#700) Co-authored-by: Sindre Sorhus --- readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index e55839bd..48b35119 100644 --- a/readme.md +++ b/readme.md @@ -16,13 +16,13 @@ We accept contributions for commonly used modern file formats, not historical or npm install file-type ``` -**This package is an ESM package. Your project needs to be ESM too. [Read more](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).** +**This package is an ESM package. Your project needs to be ESM too. [Read more](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). For TypeScript + CommonJS, see [`load-esm`](https://github.com/Borewit/load-esm).** If you use it with Webpack, you need the latest Webpack version and ensure you configure it correctly for ESM. ## Usage -#### Node.js +### Node.js Determine file type from a file: @@ -91,7 +91,7 @@ const write = fs.createWriteStream(`decrypted.${streamWithFileType.fileType.ext} streamWithFileType.pipe(write); ``` -#### Browser +### Browser ```js import {fileTypeFromStream} from 'file-type';