diff --git a/core.d.ts b/core.d.ts index bea77675..0c56c7c2 100644 --- a/core.d.ts +++ b/core.d.ts @@ -402,7 +402,7 @@ A smaller sample size will result in lower probability of the best file type det @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()`. @example -``` + import got from 'got'; import {fileTypeStream} from 'file-type'; @@ -414,18 +414,18 @@ const stream2 = await fileTypeStream(stream1, {sampleSize: 1024}); if (stream2.fileType?.mime === 'image/jpeg') { // stream2 can be used to stream the JPEG image (from the very beginning of the stream) } -``` + */ export function fileTypeStream(readableStream: ReadableStream, options?: StreamOptions): Promise; /** -Detect the file type of a [`Blob`](https://nodejs.org/api/buffer.html#class-blob) or . +Detect the file type of a [`Blob`](https://nodejs.org/api/buffer.html#class-blob) or [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File). @param blob [`Blob`](https://nodejs.org/api/buffer.html#class-blob) used for file detection @returns The detected file type and MIME type, or `undefined` when there is no match. @example -``` + import {fileTypeFromBlob} from 'file-type'; const blob = new Blob([''], { @@ -435,7 +435,7 @@ const blob = new Blob([''], { console.log(await fileTypeFromBlob(blob)); //=> {ext: 'txt', mime: 'plain/text'} -``` + */ export declare function fileTypeFromBlob(blob: Blob): Promise; @@ -457,7 +457,6 @@ If the detector returns `undefined`, there are 2 possible scenarios: Example detector array which can be extended and provided via the fileTypeOptions argument: -```js import {FileTypeParser} from 'file-type'; const customDetectors = [ @@ -477,7 +476,6 @@ const buffer = Buffer.from("UNICORN"); const parser = new FileTypeParser({customDetectors}); const fileType = await parser.fromBuffer(buffer); console.log(fileType); -``` @param tokenizer - An [`ITokenizer`](https://github.com/Borewit/strtok3#tokenizer) usable as source of the examined file. @param fileType - FileTypeResult detected by the standard detections or a previous custom detection. Undefined if no matching fileTypeResult could be found.