From 590e231ad58e71b48e5c1e488ba3f614f1697baf Mon Sep 17 00:00:00 2001 From: Borewit Date: Tue, 30 Jul 2024 22:30:38 +0200 Subject: [PATCH] Pass options to `NodeFileTypeParser` constructor in `fileTypeStream` --- index.js | 2 +- readme.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index ecebcaad..56dd18af 100644 --- a/index.js +++ b/index.js @@ -70,7 +70,7 @@ export async function fileTypeFromStream(stream, fileTypeOptions) { } export async function fileTypeStream(readableStream, options = {}) { - return new NodeFileTypeParser().toDetectionStream(readableStream, options); + return new NodeFileTypeParser(options).toDetectionStream(readableStream, options); } export {fileTypeFromTokenizer, fileTypeFromBuffer, fileTypeFromBlob, FileTypeParser, supportedMimeTypes, supportedExtensions} from './core.js'; diff --git a/readme.md b/readme.md index 82da982a..366f5ba2 100644 --- a/readme.md +++ b/readme.md @@ -265,7 +265,7 @@ Type: [`ITokenizer`](https://github.com/Borewit/strtok3#tokenizer) A file source implementing the [tokenizer interface](https://github.com/Borewit/strtok3#tokenizer). -### fileTypeStream(readableStream, options?) +### fileTypeStream(webStream, options?) Returns a `Promise` which resolves to the original readable stream argument, but with an added `fileType` property, which is an object like the one returned from `fileTypeFromFile()`. @@ -274,8 +274,8 @@ Internally `stream()` builds up a buffer of `sampleSize` bytes, used as a sample The sample size impacts the file detection resolution. A smaller sample size will result in lower probability of the best file type detection. -**Note:** This method is only available when using Node.js. -**Note:** Requires Node.js 14 or later. +**Note:** When using Node.js, a stream Readable maybe provided as well. +**Note:** Require[readme.md](readme.md)s Node.js 14 or later. #### readableStream