We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
From Wikipedia:
A filename extension, file name extension or file extension is a suffix to the name of a computer file (e.g., .txt, .docx, .md).
.txt
.docx
.md
When the ext without a period(.), i need write code like this:
ext
.
import path from 'path'; import {fileTypeFromFile} from 'file-type'; const filetype = await fileTypeFromFile('Unicorn.png')); // {ext: 'png', mime: 'image/png'} const pathname = path.format({ dir: '/path/to/somewhere', name: 'Unicorn', ext: filetype?.ext ? '.' + filetype?.txt : '' }); // /path/to/somewhere/Unicorn.png
With a period(.):
const filetype = await fileTypeFromFile('Unicorn.png')); // {ext: '.png', mime: 'image/png'} const pathname = path.format({ dir: '/path/to/somewhere', name: 'Unicorn', ext: filetype?.ext }); // /path/to/somewhere/Unicorn.png
If the ext has a period, it's convenient to use it.
The text was updated successfully, but these errors were encountered:
The extension is png. The dot is just the separator. Same as the filename is not /Unicorn.png, since / is the path separator.
png
/Unicorn.png
/
nodejs/node#44343
Sorry, something went wrong.
No branches or pull requests
From Wikipedia:
When the
ext
without a period(.
), i need write code like this:With a period(
.
):If the
ext
has a period, it's convenient to use it.The text was updated successfully, but these errors were encountered: