From e62ca5d39f5abd1135b02c845ee8c81a48b12d3f Mon Sep 17 00:00:00 2001 From: Borewit Date: Fri, 10 Nov 2023 18:41:20 +0100 Subject: [PATCH] Remove markup style start and end code block declarations --- core.d.ts | 32 +++++++++++++++++--------------- readme.md | 3 ++- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/core.d.ts b/core.d.ts index bea77675..0514c9ed 100644 --- a/core.d.ts +++ b/core.d.ts @@ -419,12 +419,13 @@ if (stream2.fileType?.mime === 'image/jpeg') { 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'; @@ -436,13 +437,14 @@ const blob = new Blob([''], { console.log(await fileTypeFromBlob(blob)); //=> {ext: 'txt', mime: 'plain/text'} ``` + */ export declare function fileTypeFromBlob(blob: Blob): Promise; /** Function that allows specifying custom detection mechanisms. -An iterable of detectors can be provided via the fileTypeOptions argument for the {@link FileTypeParser.constructor}. +An iterable of detectors can be provided via the `fileTypeOptions` argument for the {@link FileTypeParser.constructor}. The detectors are called before the default detections in the provided order. @@ -452,12 +454,12 @@ If the detector returns `undefined`, there are 2 possible scenarios: 1. The detector has not read from the tokenizer, it will be proceeded with the next available detector. 2. The detector has read from the tokenizer (`tokenizer.position` has been increased). - In that case no further detectors will be executed and the final conclusion is that file-type returns undefined. - Note that this an exceptional scenario, as the detector takes the opportunity from any other detector to determine the file type. + In that case no further detectors will be executed and the final conclusion is that file-type returns undefined. + Note that this an exceptional scenario, as the detector takes the opportunity from any other detector to determine the file type. Example detector array which can be extended and provided via the fileTypeOptions argument: -```js +``` import {FileTypeParser} from 'file-type'; const customDetectors = [ @@ -499,27 +501,27 @@ export declare class FileTypeParser { constructor(options?: {customDetectors?: Iterable}); /** - * Works the same way as {@link fileTypeFromBuffer}, additionally taking into account custom detectors (if any were provided to the constructor). - */ + Works the same way as {@link fileTypeFromBuffer}, additionally taking into account custom detectors (if any were provided to the constructor). + */ fromBuffer(buffer: Uint8Array | ArrayBuffer): Promise; /** - * Works the same way as {@link fileTypeFromStream}, additionally taking into account custom detectors (if any were provided to the constructor). - */ + Works the same way as {@link fileTypeFromStream}, additionally taking into account custom detectors (if any were provided to the constructor). + */ fromStream(stream: ReadableStream): Promise; /** - * Works the same way as {@link fileTypeFromTokenizer}, additionally taking into account custom detectors (if any were provided to the constructor). - */ + Works the same way as {@link fileTypeFromTokenizer}, additionally taking into account custom detectors (if any were provided to the constructor). + */ fromTokenizer(tokenizer: ITokenizer): Promise; /** - * Works the same way as {@link fileTypeFromBlob}, additionally taking into account custom detectors (if any were provided to the constructor). - */ + Works the same way as {@link fileTypeFromBlob}, additionally taking into account custom detectors (if any were provided to the constructor). + */ fromBlob(blob: Blob): Promise; /** - * Works the same way as {@link fileTypeStream}, additionally taking into account custom detectors (if any were provided to the constructor). - */ + Works the same way as {@link fileTypeStream}, additionally taking into account custom detectors (if any were provided to the constructor). + */ toDetectionStream(readableStream: ReadableStream, options?: StreamOptions): Promise; } diff --git a/readme.md b/readme.md index 80dba09a..096caf83 100644 --- a/readme.md +++ b/readme.md @@ -327,7 +327,7 @@ If the detector returns `undefined`, there are 2 possible scenarios: Note that this an exceptional scenario, as the detector takes the opportunity from any other detector to determine the file type. -Example detector array which can be extended and provided to each public method via the fileTypeOptions argument: +Example detector array which can be extended and provided to each public method via the `fileTypeOptions` argument: ```js import {FileTypeParser} from 'file-type'; @@ -336,6 +336,7 @@ const customDetectors = [ const unicornHeader = [85, 78, 73, 67, 79, 82, 78]; // "UNICORN" as decimal string const buffer = Buffer.alloc(7); await tokenizer.peekBuffer(buffer, {length: unicornHeader.length, mayBeLess: true}); + if (unicornHeader.every((value, index) => value === buffer[index])) { return {ext: 'unicorn', mime: 'application/unicorn'}; }