githubEdit

@nodelib/fs.stat

Get the status of a file with some features.

💡 Highlights

Wrapper over standard methods (fs.lstatarrow-up-right, fs.statarrow-up-right) with some features.

  • 🔰 Normally follows symlinks.

  • ⚙️ Can safely work with broken symlinks (returns information about symlink instead of generating an error).

Install

$ npm install @nodelib/fs.stat

Usage

const fsStat = require('@nodelib/fs.stat');

fsStat.stat('path').then((stat) => {
    console.log(stat); // => fs.Stats
});

API

fsStat.stat(path, [options])

Returns a Promise<fs.Stats>arrow-up-right for provided path.

fsStat.statSync(path, [options])

Returns a fs.Statsarrow-up-right for provided path.

fsStat.statCallback(path, [options], callback)

Returns a fs.Statsarrow-up-right for provided path with standard callback-style.

path

  • Type: string | Buffer | URL

The path argument for fs.lstatarrow-up-right or fs.statarrow-up-right method.

options

  • Type: Object

See options section for more detailed information.

Options

  • Type: boolean

  • Default: true

Throw an error or return information about symlink, when symlink is broken. When false, methods will be return lstat call for broken symlinks.

  • Type: boolean

  • Default: true

By default, the methods of this package follows symlinks. If you do not want it, set this option to false or use the standard method fs.lstatarrow-up-right.

fs

  • Type: FileSystemAdapter

  • Default: built-in FS methods

By default, the built-in Node.js module (fs) is used to work with the file system. You can replace each method with your own.

Changelog

See the Releases section of our GitHub projectarrow-up-right for changelogs for each release version.

License

This software is released under the terms of the MIT license.

Last updated