Skip to content

Commit

Permalink
Improve README, types comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Borewit committed Aug 1, 2024
1 parent a119280 commit 257bc99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ export function fileTypeFromStream(stream: AnyWebReadableStream<Uint8Array> | No
/**
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()`.
This method can be handy to put in between a stream, but it comes with a price.
This method can be handy to put in between a stream, but it comes with a price.
Internally `stream()` builds up a buffer of `sampleSize` bytes, used as a sample, to determine the file type.
The sample size impacts the file detection resolution.
A smaller sample size will result in lower probability of the best file type detection.
**Note:** This method is only available when using Node.js.
**Note:** Requires Node.js 14 or later.
@param readableStream - A [readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable) containing a file to examine.
@param options - May be used to override the default sample size with an added `fileType` property, which is an object like the one returned from `fileTypeFromFile()`.
@example
@returns A `Promise` which resolves to the original readable stream argument, but
@param readableStream - A [Node.js `stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable)
or [web `ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream), streaming a file to examine.
@param options - May be used to override the default sample size with an added `fileType` property, wh` property, which is an object like the one returned from `fileTypeFromFile()`.
@exampleich is an object like the one returned from `fileTypeFromFile()`.
@returns A `Promise` which resolves to the original readable stream argument, but with an added `fileType
```
import got from 'got';
import {fileTypeStream} from 'file-type';
Expand Down
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ Returns a `Promise` for an object with the detected file type:
Or `undefined` when there is no match.

#### stream
Streaming a file to examine.

Type: [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable)
Type: [Node.js `stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable)
or [web `ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)

A readable stream representing file data.

Expand Down

0 comments on commit 257bc99

Please sign in to comment.