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

Separate Node.js dependency #265

Merged
merged 2 commits into from
Dec 22, 2019
Merged

Separate Node.js dependency #265

merged 2 commits into from
Dec 22, 2019

Conversation

Borewit
Copy link
Collaborator

@Borewit Borewit commented Dec 2, 2019

Node.js functions are the default:

const fileType = require('file-type');

(async () => {
    const fileType = await fileType.fromFile('/home/borewit/Pictures/background.png');
    // fileType = {ext: 'png', mime: 'image/png'}
})();

Common (internal) functions are accessible via sub-inclusion (file-type/core):

(async () => {
    const fileType = await fileType.fromTokenizer(tokenizer);
    // fileType = {ext: 'png', mime: 'image/png'}
})();

This is part of the implementation of #248 Change proposal: break the fixed sample limit

@sindresorhus
Copy link
Owner

I think it should be the other way around. require('file-type') should include the Node.js stuff, and require('file-type/browser'); should be browser-only.

@Borewit
Copy link
Collaborator Author

Borewit commented Dec 3, 2019

I think it should be the other way around. require('file-type') should include the Node.js stuff, and require('file-type/browser'); should be browser-only.

Makes sense, I will adjust to your preference (same way as I had done it in my modules, requires a bit more shift code around, that is is why I have not done it).

Okay, I will:

  • 'filetype' for Node.js, importing filetype/core
    • fromFile(), reading from file path
    • +core functions
  • 'filetype/core' common part, Node.js & browser compatible.
  • 'filetype/browser', descoped for now, importing filetype/core, adding browser specific functions

@Borewit
Copy link
Collaborator Author

Borewit commented Dec 4, 2019

To convert the Web-API readable stream (from browser part) into Node.js readable stream (core) I planned to use readable-web-to-node-stream.

Would you like to keep /browser as part of file-type or put this in a dedicated module @sindresorhus?

@sindresorhus
Copy link
Owner

Would you like to keep /browser as part of file-type or put this in a dedicated module @sindresorhus?

I would prefer to keep everything in this package.

@Borewit
Copy link
Collaborator Author

Borewit commented Dec 5, 2019

I will prepare a PR adding the browser functions within 2 days.

If you have time, it would be great if you can review & merge, these PR's to the development branch:

@Borewit Borewit mentioned this pull request Dec 21, 2019
/**
Supported MIME types.
*/
const mimeTypes: core.MimeType;
Copy link
Owner

Choose a reason for hiding this comment

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

Note: eff47af

@sindresorhus sindresorhus merged commit 146f872 into sindresorhus:stream-tokenizer Dec 22, 2019
@sindresorhus
Copy link
Owner

Merging this to unblock you, but don't forget to fix #265 (comment)

@Borewit Borewit mentioned this pull request Dec 22, 2019
This was referenced Jan 1, 2020
@Borewit Borewit mentioned this pull request Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants