Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between fsExtra.pathExists and fsExtra.exists?

I know exists is deprecated in fs but it is able in fs-extra.

I used both fsExtra.pathExists and fsExtra.exists.

But I could not find the difference.

They performe same.

like image 891
Kuru Avatar asked Nov 23 '25 13:11

Kuru


1 Answers

There is not much difference between these two methods.

fs-extra is a superset of fs, inheriting all its methods, so fsExtra.exists is the same as fs.exists. And as you said it's deprecated.

The difference between exists() and pathExists() lies in the signature of the functions.

Like fs.exists, but with a normal callback signature (err, exists).

Internally, fs native module use a try catch block, while fs-extra use a Promise style. And they both use fs.access() method to determine if the specified file is accessible.

And yes, they both have the same use.

like image 74
TGrif Avatar answered Nov 26 '25 03:11

TGrif



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!