file-type 19.4.0 → 19.4.1
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/core.d.ts +2 -2
- package/core.js +2 -2
- package/index.d.ts +2 -1
- package/index.js +2 -2
- package/package.json +2 -2
package/core.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ Typings for primary entry point, Node.js specific typings can be found in index.
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type {ReadableStream as WebReadableStream} from 'node:stream/web';
|
|
6
|
-
import type {ITokenizer} from 'strtok3';
|
|
6
|
+
import type {ITokenizer, AnyWebByteStream} from 'strtok3';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
Either the Node.js ReadableStream or the `lib.dom.d.ts` ReadableStream.
|
|
@@ -350,7 +350,7 @@ The file type is detected by checking the [magic number](https://en.wikipedia.or
|
|
|
350
350
|
@param stream - A [web `ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) streaming a file to examine.
|
|
351
351
|
@returns A `Promise` for an object with the detected file type, or `undefined` when there is no match.
|
|
352
352
|
*/
|
|
353
|
-
export function fileTypeFromStream(stream:
|
|
353
|
+
export function fileTypeFromStream(stream: AnyWebByteStream): Promise<FileTypeResult | undefined>;
|
|
354
354
|
|
|
355
355
|
/**
|
|
356
356
|
Detect the file type from an [`ITokenizer`](https://github.com/Borewit/strtok3#tokenizer) source.
|
package/core.js
CHANGED
|
@@ -51,8 +51,8 @@ export async function fileTypeFromTokenizer(tokenizer) {
|
|
|
51
51
|
return new FileTypeParser().fromTokenizer(tokenizer);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export async function fileTypeStream(webStream) {
|
|
55
|
-
return new FileTypeParser().toDetectionStream(webStream);
|
|
54
|
+
export async function fileTypeStream(webStream, options) {
|
|
55
|
+
return new FileTypeParser(options).toDetectionStream(webStream, options);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export class FileTypeParser {
|
package/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ Typings for Node.js specific entry point.
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type {Readable as NodeReadableStream} from 'node:stream';
|
|
6
|
+
import type {AnyWebByteStream} from 'strtok3';
|
|
6
7
|
import type {FileTypeResult, StreamOptions, AnyWebReadableStream, Detector, AnyWebReadableByteStreamWithFileType} from './core.js';
|
|
7
8
|
import {FileTypeParser} from './core.js';
|
|
8
9
|
|
|
@@ -85,6 +86,6 @@ if (stream2.fileType?.mime === 'image/jpeg') {
|
|
|
85
86
|
```
|
|
86
87
|
*/
|
|
87
88
|
export function fileTypeStream(readableStream: NodeReadableStream, options?: StreamOptions): Promise<ReadableStreamWithFileType>;
|
|
88
|
-
export function fileTypeStream(webStream:
|
|
89
|
+
export function fileTypeStream(webStream: AnyWebByteStream, options?: StreamOptions): Promise<AnyWebReadableByteStreamWithFileType>;
|
|
89
90
|
|
|
90
91
|
export * from './core.js';
|
package/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Node.js specific entry point.
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import {ReadableStream as WebReadableStream} from 'node:stream/web';
|
|
6
|
-
import {pipeline, PassThrough} from 'node:stream';
|
|
6
|
+
import {pipeline, PassThrough, Readable} from 'node:stream';
|
|
7
7
|
import * as strtok3 from 'strtok3';
|
|
8
8
|
import {FileTypeParser, reasonableDetectionSizeInBytes} from './core.js';
|
|
9
9
|
|
|
@@ -27,7 +27,7 @@ export class NodeFileTypeParser extends FileTypeParser {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
async toDetectionStream(readableStream, options = {}) {
|
|
30
|
-
if (readableStream instanceof
|
|
30
|
+
if (!(readableStream instanceof Readable)) {
|
|
31
31
|
return super.toDetectionStream(readableStream, options);
|
|
32
32
|
}
|
|
33
33
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "file-type",
|
|
3
|
-
"version": "19.4.
|
|
3
|
+
"version": "19.4.1",
|
|
4
4
|
"description": "Detect the file type of a file, stream, or data",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "sindresorhus/file-type",
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
],
|
|
220
220
|
"dependencies": {
|
|
221
221
|
"get-stream": "^9.0.1",
|
|
222
|
-
"strtok3": "^8.
|
|
222
|
+
"strtok3": "^8.1.0",
|
|
223
223
|
"token-types": "^6.0.0",
|
|
224
224
|
"uint8array-extras": "^1.3.0"
|
|
225
225
|
},
|