Skip to content

Commit

Permalink
Pass options to NodeFileTypeParser constructor in fileTypeStream
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed Jul 30, 2024
1 parent 499b985 commit 5576603
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ Type: [`ITokenizer`](https:/Borewit/strtok3#tokenizer)

A file source implementing the [tokenizer interface](https:/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()`.

Expand All @@ -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

Expand Down

0 comments on commit 5576603

Please sign in to comment.