Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

fs.exists doesn't follow the callback convention. #6311

Closed
petkaantonov opened this issue Oct 5, 2013 · 1 comment
Closed

fs.exists doesn't follow the callback convention. #6311

petkaantonov opened this issue Oct 5, 2013 · 1 comment

Comments

@petkaantonov
Copy link

On the docs it says:

File I/O is provided by simple wrappers around standard POSIX functions. To use this module do require('fs'). All the methods have asynchronous and synchronous forms.

The asynchronous form always take a completion callback as its last argument. The arguments passed to the completion callback depend on the method, but the first argument is always reserved for an exception. If the operation was completed successfully, then the first argument will be null or undefined.

But fs.exists doesn't really match that description at all.

@bnoordhuis
Copy link
Member

fs.exists() is an anomaly and something of a wart; it started out as path.exists() but was later moved to the fs module because the path module didn't do any I/O (except for path.exists(), of course), that's why it doesn't match the other fs functions.

I've added a note to the documentation in d97ea06 that hopefully stops people from using it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants