Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Blob, file, and stream method documentation #641

Merged
merged 16 commits into from
Jul 16, 2024

Conversation

Borewit
Copy link
Collaborator

@Borewit Borewit commented Jul 10, 2024

Improve documentation of:

  • fileTypeFromFile(filePath): explain this method can only be used if the JavaScript engine is Node.js
  • fileTypeFromStream(stream) explain that Node.js stream is only available when used with Node.js
  • fileTypeFromBlob(blob) explain that this is the method to used for web API File

Resolves #640

@Borewit Borewit requested a review from sindresorhus July 10, 2024 18:20
@Borewit Borewit force-pushed the improve-blob-and-stream-documentation branch from 47fe441 to 2f738a8 Compare July 10, 2024 18:27
readme.md Outdated
@@ -147,7 +150,9 @@ The file path to parse.

### fileTypeFromStream(stream)

Detect the file type of a [Node.js readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable) or a [Web API ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream).
Detect the file type of a [Web API ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Detect the file type of a [Web API ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream).
Detect the file type of a [Web `ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream).

@sindresorhus
Copy link
Owner

You also need to update the doc comments in the types.

@Borewit Borewit self-assigned this Jul 11, 2024
@Borewit Borewit requested a review from sindresorhus July 11, 2024 08:25
@sindresorhus
Copy link
Owner

Some of my suggested changes were not applied. It would have been better to simply commit the changes directly (they are diff suggestions, so you could have just pressed "commit suggestion").

@sindresorhus
Copy link
Owner

There are still missed things, like #641 (comment)

Borewit and others added 5 commits July 16, 2024 22:45
Mapped updated documentation to typings, and added some missing documentation
Explained difference, and when to use `NodeFileTypeParser` instead of the `FileTypeParser` class
Co-authored-by: Sindre Sorhus <[email protected]>
Co-authored-by: Sindre Sorhus <[email protected]>
@Borewit Borewit force-pushed the improve-blob-and-stream-documentation branch from 35bc2bc to 7b4969b Compare July 16, 2024 20:47
@Borewit Borewit requested a review from sindresorhus July 16, 2024 21:16
@sindresorhus sindresorhus merged commit db37ee3 into main Jul 16, 2024
6 checks passed
@sindresorhus sindresorhus deleted the improve-blob-and-stream-documentation branch July 16, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fileTypeFromFile are not defined in browser.d.ts
2 participants