DEV Community

Omar Dulaimi
Omar Dulaimi

Posted on

Check user's permissions on file/dir in Nodejs

The ๐—ณ๐˜€๐—ฃ๐—ฟ๐—ผ๐—บ๐—ถ๐˜€๐—ฒ๐˜€.๐—ฎ๐—ฐ๐—ฐ๐—ฒ๐˜€๐˜€ method tests a user's permissions for the file or directory specified by path.

This is the recommended method by ๐—ก๐—ผ๐—ฑ๐—ฒ๐—ท๐˜€ and the replacement of ๐—ณ๐˜€.๐—ฒ๐˜…๐—ถ๐˜€๐˜๐˜€, as it was deprecated.

Also it's usually not a good idea to use the sync version ๐—ณ๐˜€.๐—ฒ๐˜…๐—ถ๐˜€๐˜๐˜€๐—ฆ๐˜†๐—ป๐—ฐ since it blocks the main thread.

It's better than ๐—ณ๐˜€.๐—ฒ๐˜…๐—ถ๐˜€๐˜๐˜€ as you can see; promisified and provides more modes than just checking if the file exists.

I enjoyed learning about this method, hopefully you did too!


Did you learn something new today?

Like and share this post, and follow me for more!

access method

Top comments (0)