Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
The path-type npm package is a simple utility that provides functions to check the type of a filesystem path. It can determine whether a path is a file, directory, symbolic link, etc. It is useful for validating paths and handling them conditionally based on their type.
isFile
Checks if a path is a file.
const pathType = require('path-type');
pathType.isFile('source.js').then(isFile => {
console.log(isFile); //=> true or false
});
isDirectory
Checks if a path is a directory.
const pathType = require('path-type');
pathType.isDirectory('source').then(isDirectory => {
console.log(isDirectory); //=> true or false
});
isSymlink
Checks if a path is a symbolic link.
const pathType = require('path-type');
pathType.isSymlink('link').then(isSymlink => {
console.log(isSymlink); //=> true or false
});
fs-extra is a package that extends the built-in fs module, providing additional methods and also includes the functionality to check path types. It is more comprehensive than path-type as it includes file system operations beyond type checking.
fs-promise is a package that promisifies the Node.js fs module and adds support for promises to file system operations, including checking if a path is a file or directory. It is similar to path-type but is integrated with the fs module's other functionalities.
Check if a path is a file, directory, or symlink
npm install path-type
import {isFile} from 'path-type';
console.log(await isFile('package.json'));
//=> true
Check whether the passed path
is a file.
Returns a Promise<boolean>
.
Type: string
The path to check.
Check whether the passed path
is a directory.
Returns a Promise<boolean>
.
Check whether the passed path
is a symlink.
Returns a Promise<boolean>
.
Synchronously check whether the passed path
is a file.
Returns a boolean
.
Synchronously check whether the passed path
is a directory.
Returns a boolean
.
Synchronously check whether the passed path
is a symlink.
Returns a boolean
.
FAQs
Check if a path is a file, directory, or symlink
The npm package path-type receives a total of 56,184,665 weekly downloads. As such, path-type popularity was classified as popular.
We found that path-type demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.