npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

file-system-explorer

v1.1.11

Published

Utility class to get information from File System. Get Directory Tree using absolute path and many more(s)

Downloads

200

Readme

file-system-explorer

FileSystemExplorer is an utility class with which you can:

  • Create JSON object from the file system

  • Get all files/directories details from the file system

  • Get list of files/directories

  • Create directory

  • Delete file/directory

  • Rename file/directory

  • Check free mount space

from the given path and many more(s).

Installation

npm install file-system-explorer

Usage

How to import file-system-explorer?

    const fileSystemExplorer = require('file-system-explorer');

or

    import { FileSystemExplorer } from 'file-system-explorer';

After import, create an object of FileSystemExplorer class.

    // For JS
    const fsExplorer = new fileSystemExplorer.FileSystemExplorer();

or

    // For TypeScript
    const fsExplorer: FileSystemExplorer = new FileSystemExplorer();
Create JSON object from a given path (tree like structure)
// return JSON object for directory tree
const myPathTree = fsExplorer.createFileSystemTree('/path/to/dir/or/file');
Get All Directories path from a prepared Directory Tree
const myPathTree = fsExplorer.createFileSystemTree('/path/to/dir/or/file');
// returns string[]
const myPathDirectories = fsExplorer.getAllDirectoryPathFromPreparedFSInfo(myPathTree);
Get All Directories path from a given path (includes directories from the sub-directories)
// returns string[]
const myPathDirectories = fsExplorer.getAllDirectoryPathFromFileSystem('/path/to/dir/or/file'); 
Get All Files path from a prepared Directory Tree
    const myPathTree = fsExplorer.createFileSystemTree('/path/to/dir/or/file');
    const myPathFiles = fsExplorer.getAllFilePathFromPreparedFSInfo(myPathTree); // returns string[]
Get All Files path from a given path (includes files from the sub-directories)
    const myPathFiles = fsExplorer.getAllFilePathFromFileSystem('/path/to/dir/or/file'); // returns string[]
Get All Files and Directories details from a given path (include all files/directories from sub directories)
// returns array of File/Directory details IFSInfo[]
// Details include size, file name, type, last modified time, extension, complete path
const myPathAllFSDetails = fsExplorer.getAllFSElementsDetailsFromFileSystem('/path/to/dir/or/file');
Get All Files and Directories details from a prepared Directory Tree
const myPathTree = fsExplorer.createFileSystemTree('/path/to/dir/or/file');
// returns array of File/Directory details IFSInfo[]
const myPathAllFSDetails = fsExplorer.getAllFSElementsDetailsFromPreparedFSInfo(myPathTree);
Get All Files and Directories details from the given path
// returns array of File/Directory details IFSInfo[]
const myPathContents = fsExplorer.getDirectoryContentList('/path/to/dir');
Create Directory in a Given path
// creates 'New Folder' directory inside '/path/to/dir'
const mkdirResponse = createDirectory('/path/to/dir/New Folder', true);
// creates 'New Folder' directory inside '/path/to/dir', if already exists, then will create 'New Folder (1)'
const mkdirResponse = createDirectory('/path/to/dir');
// Return mkdirResponse.errno 0 on success
Delete Directory/Files
// To delete directory, pass second paramater as true
const deleteDirResponse = deleteDirectory('/path/to/dir', true);
const deleteDirResponse = deleteDirectory('/path/to/file');
// Returns errno 0, on success
Rename Directory/Files
// pass rename File/Directory details IRenameFileDetails in function parameter
// IRenameFileDetails include old_path_length, old_path_, new_path_length, new_path
const renameFSResponse = renameFile('/path/to/old/dir/or/file', '/path/to/new/dir/or/file');
// Returns errno 0, on success
Check Directory Read/Write Persmission
const directoryRWPermRes = checkDirectoryReadWritePersmission('/path/to/dir');
// Returns errno 0, on success
Check FS Element Exists
// check if file exists or not
const fsElementExistsResponse = checkFSElementExists('/path/to/dir/or/file');
// Returns true, on FS Element exist
Get FS Element Details
// Returns FS Element IFSInfo 
// Details include size, file name, type, last modified time, extension, complete path
const fsElementDetails = getFSElementDetails('/path/to/dir/or/file');
Check Mount Free Space
// Check if free space available for the mount in which this file is present
const freeSpaceInBytes = checkMountFreeSpace('/path/to/dir/or/file');
// Return free space available in bytes for mount which contain the file. If command fails, return 0