Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
realpath-native
Advanced tools
The realpath-native npm package provides a way to resolve the real path of a file or directory, similar to the native `fs.realpath` method but with better performance and additional features.
Resolve Real Path
This feature allows you to resolve the real path of a given file or directory. It works asynchronously and provides a callback with the resolved path.
const realpathNative = require('realpath-native');
realpathNative('/some/path', (err, resolvedPath) => {
if (err) throw err;
console.log(resolvedPath);
});
Synchronous Real Path Resolution
This feature allows you to resolve the real path of a given file or directory synchronously. It throws an error if the path cannot be resolved.
const realpathNative = require('realpath-native');
try {
const resolvedPath = realpathNative.sync('/some/path');
console.log(resolvedPath);
} catch (err) {
console.error(err);
}
Promise-based Real Path Resolution
This feature allows you to resolve the real path of a given file or directory using Promises, making it easier to work with async/await syntax.
const realpathNative = require('realpath-native');
realpathNative.promise('/some/path')
.then(resolvedPath => console.log(resolvedPath))
.catch(err => console.error(err));
fs-extra is a package that extends the native `fs` module with additional methods and features, including methods for resolving real paths. It provides both callback and promise-based APIs, similar to realpath-native.
graceful-fs is a drop-in replacement for the native `fs` module that improves handling of file system operations, including real path resolution. It aims to handle errors more gracefully and provide better performance.
path-exists is a simple package that checks if a given path exists. While it does not directly resolve real paths, it can be used in conjunction with other packages to ensure a path exists before resolving it.
Use the system's native
realpath
Node 9.3 added fs.realpath(Sync).native
. On older Nodes you have to use
process.binding
to access the same function. This module does that check for
you.
The advantage of the native realpath
over fs.realpath
is that the native one
better supports paths on Windows.
On node 8 the function uses the old fs.realpath
function.
Install the module with npm
:
$ npm install realpath-native
const realpath = require('realpath-native');
realpath('some-path'); // returns a promise
realpath.sync('some-path');
Returns a promise for the resolved path of the input.
Type: string
Returns the resolved path of the input synchronously.
Type: string
FAQs
Use the system's native `realpath`
The npm package realpath-native receives a total of 1,548,568 weekly downloads. As such, realpath-native popularity was classified as popular.
We found that realpath-native demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.