Skip to content

Commit

Permalink
Update typings to reflect moving fileTypeFromBlob() from browser to…
Browse files Browse the repository at this point in the history
… core.
  • Loading branch information
Borewit committed Mar 31, 2023
1 parent 0b8296b commit ced8839
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
21 changes: 1 addition & 20 deletions browser.d.ts
Expand Up @@ -18,28 +18,9 @@ console.log(fileType);
*/
export declare function fileTypeFromStream(stream: ReadableStream): Promise<FileTypeResult | undefined>;

/**
Detect the file type of a [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
__Note:__ This method is only available in the browser.
@example
```
import {fileTypeFromBlob} from 'file-type';
const blob = new Blob(['<?xml version="1.0" encoding="ISO-8859-1" ?>'], {
type: 'plain/text',
endings: 'native'
});
console.log(await fileTypeFromBlob(blob));
//=> {ext: 'txt', mime: 'plain/text'}
```
*/
export declare function fileTypeFromBlob(blob: Blob): Promise<FileTypeResult | undefined>;

export {
fileTypeFromBuffer,
fileTypeFromBlob,
supportedExtensions,
supportedMimeTypes,
type FileTypeResult,
Expand Down
18 changes: 18 additions & 0 deletions core.d.ts
Expand Up @@ -401,3 +401,21 @@ if (stream2.fileType?.mime === 'image/jpeg') {
```
*/
export function fileTypeStream(readableStream: ReadableStream, options?: StreamOptions): Promise<ReadableStreamWithFileType>;

/**
Detect the file type of a [`Blob`](https://nodejs.org/api/buffer.html#class-blob).
@example
```
import {fileTypeFromBlob} from 'file-type';
const blob = new Blob(['<?xml version="1.0" encoding="ISO-8859-1" ?>'], {
type: 'plain/text',
endings: 'native'
});
console.log(await fileTypeFromBlob(blob));
//=> {ext: 'txt', mime: 'plain/text'}
```
*/
export declare function fileTypeFromBlob(blob: Blob): Promise<FileTypeResult | undefined>;
2 changes: 1 addition & 1 deletion index.test-d.ts
Expand Up @@ -2,10 +2,10 @@ import {Buffer} from 'node:buffer';
import {createReadStream} from 'node:fs';
import {expectType} from 'tsd';
import {
fileTypeFromBlob,
type FileTypeResult as FileTypeResultBrowser,
} from './browser.js';
import {
fileTypeFromBlob,
fileTypeFromBuffer,
fileTypeFromFile,
fileTypeFromStream,
Expand Down

0 comments on commit ced8839

Please sign in to comment.