New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

flexfile

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flexfile

Flexfile is a simple file management system for Node.js

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

FlexFile

A Node.js package for handling files and folders in a directory.

Installation

Use npm to install the package:

npm install flexfile

Usage

Import the package in your Node.js project:

const flexFile = require('flexfile');

getFilesAndSubfiles

Recursively retrieves all files and subfiles in a directory.

fileUtils.getFilesAndSubfiles({
  path: '/path/to/directory',
  allowedExtensions: ['js', 'txt'], // Optional. Specify the allowed file extensions. Default is ['js'].
  avoidFiles: ['example.js'] // Optional. Specify files to avoid. Default is an empty array.
})
  .then(files => {
    console.log(files);
  })
  .catch(error => {
    console.error(error);
  });

getFilesAndFolders

Retrieves both files and folders in a directory.

fileUtils.getFilesAndFolders({
  path: '/path/to/directory',
  allowedExtensions: ['js', 'txt'], // Optional. Specify the allowed file extensions. Default is ['js'].
  avoidFiles: ['example.js'], // Optional. Specify files to avoid. Default is an empty array.
})
  .then(result => {
    console.log('Folders:', result.folders);
    console.log('Files:', result.files);
  })
  .catch(error => {
    console.error(error);
  });

getFiles

Retrieves only files in a directory.

fileUtils.getFiles({
  path: '/path/to/directory',
  allowedExtensions: ['js', 'txt'], // Optional. Specify the allowed file extensions. Default is ['js'].
  avoidFiles: ['example.js'], // Optional. Specify files to avoid. Default is an empty array.
})
  .then(files => {
    console.log(files);
  })
  .catch(error => {
    console.error(error);
  });

getFolders

Retrieves only folders in a directory.

fileUtils.getFolders({
  path: '/path/to/directory',
  avoidFolder: ['node_modules'] // Optional. Specify folders to avoid. Default is an empty array.
})
  .then(folders => {
    console.log(folders);
  })
  .catch(error => {
    console.error(error);
  });

getFoldersAndSubfolders

Recursively retrieves all folders and subfolders in a directory.

fileUtils.getFoldersAndSubfolders({
  path: '/path/to/directory',
  avoidFolders: ['node_modules'] // Optional. Specify folders to avoid. Default is an empty array.
})
  .then(folders => {
    console.log(folders);
  })
  .catch(error => {
    console.error(error);
  });

License

This project is licensed under the MIT License.

Keywords

file

FAQs

Package last updated on 16 Jun 2023

Did you know?

Socket

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.

Install

Related posts