Socket
Socket
Sign inDemoInstall

path-type

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

path-type

Check if a path is a file, directory, or symlink

    5.0.0latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
53,207,673
increased by3.47%

Weekly downloads

Package description

What is path-type?

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.

What are path-type's main functionalities?

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
});

Other packages similar to path-type

Readme

Source

path-type

Check if a path is a file, directory, or symlink

Install

$ npm install path-type

Usage

import {isFile} from 'path-type';

console.log(await isFile('package.json'));
//=> true

API

isFile(path)

Check whether the passed path is a file.

Returns a Promise<boolean>.

path

Type: string

The path to check.

isDirectory(path)

Check whether the passed path is a directory.

Returns a Promise<boolean>.

isSymlink(path)

Check whether the passed path is a symlink.

Returns a Promise<boolean>.

isFileSync(path)

Synchronously check whether the passed path is a file.

Returns a boolean.

isDirectorySync(path)

Synchronously check whether the passed path is a directory.

Returns a boolean.

isSymlinkSync(path)

Synchronously check whether the passed path is a symlink.

Returns a boolean.


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Keywords

FAQs

Last updated on 27 Jan 2021

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc