diff --git a/index.d.ts b/index.d.ts index 01693232..57221048 100644 --- a/index.d.ts +++ b/index.d.ts @@ -58,9 +58,9 @@ The file type is detected by checking the [magic number](https://en.wikipedia.or export function fileTypeFromStream(stream: AnyWebReadableStream | NodeReadableStream): Promise; /** -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()`. +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. @@ -68,11 +68,11 @@ A smaller sample size will result in lower probability of the best file type det **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'; diff --git a/readme.md b/readme.md index af5bd71b..a54054df 100644 --- a/readme.md +++ b/readme.md @@ -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.