Skip to content

Commit

Permalink
Sync Detector type documentation from README to type definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed Dec 17, 2024
1 parent f08c857 commit 1fb69e9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,14 @@ console.log(await fileTypeFromBlob(blob));
export declare function fileTypeFromBlob(blob: Blob): Promise<FileTypeResult | undefined>;

/**
Function that allows specifying custom detection mechanisms.
A custom detector is a function that allows specifying custom detection mechanisms
An iterable of detectors can be provided via the `fileTypeOptions` argument for the {@link FileTypeParser.constructor}.
An array of detectors can be provided via the `fileTypeOptions` argument for the `FileTypeParser` constructor.
In Node.js, you should use `NodeFileTypeParser`, which extends `FileTypeParser` and provides access to Node.js specific functions.
The detectors are called before the default detections in the provided order.
Detectors can be added via the constructor options, or by adding it directly to `FileTypeParser.detectors`.
The detectors provided via the constructor options, are called before the default detectors are called.
Custom detectors can be used to add new `FileTypeResults` or to modify return behavior of existing `FileTypeResult` detections.
Expand Down Expand Up @@ -181,8 +184,9 @@ export function fileTypeStream(webStream: AnyWebReadableStream<Uint8Array>, opti

export declare class FileTypeParser {
/**
File-type detectors
*/
File-type detectors, initialized with a single entry holding the build in detector function.
The array is used to iterate over all detectors, as long as the function returns `undefined`.
*/
readonly detectors: Detector[];

constructor(options?: {customDetectors?: Iterable<Detector>; signal?: AbortSignal});
Expand Down

0 comments on commit 1fb69e9

Please sign in to comment.