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

make minimumBytes = 4100 public #381

Closed
FranckFreiburger opened this issue Jul 25, 2020 · 2 comments
Closed

make minimumBytes = 4100 public #381

FranckFreiburger opened this issue Jul 25, 2020 · 2 comments

Comments

@FranckFreiburger
Copy link

const minimumBytes = 4100; // A fair amount of file-types are detectable within this range

It would be great to export minimumBytes in order to make it available to caller code.

eg.

res = await fetch(url, { headers: {
	'Range': `bytes=0-${ FileType.minimumBytes }`,
} });

await FileType.fromStream(res.body);

@sindresorhus
Copy link
Owner

It was exposed previously but then removed as we now support file types that might be larger. This constant is just an implementation detail for optimization.

@Borewit
Copy link
Collaborator

Borewit commented Jul 26, 2020

@FranckFreiburger, check the FileType.fromTokenizer(tokenizer) example which aiming to read as little as possible using range requests. Depending on the file the required range is determined.

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

No branches or pull requests

3 participants