
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
is-directory
Advanced tools
Returns true if a filepath exists on the file system and it's directory.
The 'is-directory' npm package is a simple utility that allows developers to check if a given path is a directory. It provides a straightforward API for synchronous and asynchronous checks, making it useful in various file system operations where such validation is necessary.
Synchronous Directory Check
This feature allows you to synchronously check if a specified path is a directory. It is useful when you need an immediate result and are working in a synchronous code context.
const isDirectory = require('is-directory');
const result = isDirectory.sync('/path/to/directory');
console.log(result); // outputs true if path is a directory, false otherwise
Asynchronous Directory Check
This feature provides an asynchronous method to check if a path is a directory. It is particularly useful in non-blocking environments where operations should not interrupt the main application flow.
const isDirectory = require('is-directory');
isDirectory('/path/to/directory', function(err, dir) {
if (err) throw err;
console.log(dir); // outputs true if path is a directory, false otherwise
});
fs-extra is an extension of the native 'fs' module in Node.js. It includes additional methods like 'ensureDir' which can be used to check if a directory exists and create it if it doesn't. This package offers more comprehensive file system operations compared to 'is-directory' which focuses only on directory checking.
node-dir provides utilities for reading directories, files, and their paths. It can check if a path is a directory, but it also includes capabilities to read directories recursively, which is not a feature of 'is-directory'. This makes node-dir suitable for applications that require more than just directory checking.
Returns true if a filepath exists on the file system and it's directory.
Install with npm:
$ npm install is-directory --save
var isDirectory = require('is-directory');
isDirectory('node_modules', function(err, dir) {
if (err) throw err;
console.log(dir);
//=> true
});
isDirectory.sync('README.md');
//=> false
You might also be interested in these projects:
path.isAbolute
. Returns true if a file path is absolute. | homepagetrue
if the given string looks like a glob pattern or an extglob pattern.… more | homepagetrue
if the path appears to be relative. | homepagePull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Generate readme and API documentation with verb:
$ npm install verb && npm run docs
Or, if verb is installed globally:
$ verb
Install dev dependencies:
$ npm install -d && npm test
Jon Schlinkert
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on May 21, 2016.
FAQs
Returns true if a filepath exists on the file system and it's directory.
The npm package is-directory receives a total of 9,810,108 weekly downloads. As such, is-directory popularity was classified as popular.
We found that is-directory 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
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.