πŸ“… You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP β†’
Socket
Sign inDemoInstall
Socket

filemanagementsystemfornode

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filemanagementsystemfornode

A file management system for node.js application making managements of files easier, all in one code, you can delete, move, etc, files all in one code, making ability to manage a system eg a application requiring transfering of files in folders easier

1.0.2
latest
npm
Version published
Weekly downloads
11
-21.43%
Maintainers
0
Weekly downloads
Β 
Created
Source

πŸ“˜ File Management System - TypeScript

A powerful, flexible, and chainable file management system for Node.js.

πŸ“˜ File Management System - TypeScript

A powerful, flexible, and chainable file management system for Node.js.
This system provides an easy way to manage files and directories while supporting:

  • Custom error handling
  • Custom chainable methods
  • Advanced file operations like compression, metadata retrieval, and content manipulation.

πŸ“Œ Key Features

πŸš€ File Operations

βœ” Rename, Move, Copy, and Delete files
βœ” Append content to files
βœ” Retrieve compressed file content (getInfo())
βœ” Retrieve file metadata (getMetaInfo())

πŸ“‚ Directory Operations

βœ” Create, Delete, and List directories
βœ” Check if a file/folder exists (syncExist())

βš™ Customization & Error Handling

βœ” Custom error handling (e.g., auto-create missing files on error)
βœ” Add custom chainable methods (addMethod())
βœ” Invoke custom chain methods dynamically (invokeMethod())

πŸ“₯ Installation

To install and use this package, run:

git clone https://github.com/Whitzzscott/FileManagement.git
cd FileManagement
npm install

πŸ›  Usage Example

This example demonstrates:

  • Error handling: Automatically creating a missing file if an error occurs.
  • Custom chainable methods: Adding a method that logs the file path.
  • File operations: Renaming, moving, copying, appending, and deleting a file.
import { FileWrapper } from "./wrappers/FileWrapper";

const file = new FileWrapper("./testFolder/sample.txt");

// βœ… Custom error handling: Auto-create missing files when they are not found
file.errorOnFound = (error) => {
    if (error.code === "ENOENT") {
        file.sync().writeFile("Default content");
        console.log(`πŸ“„ File created: ${file.getPath()}`);
    }
};

// βœ… Add a custom method (e.g., logging the file path)
file.addMethod("logPath", function () {
    console.log("File is at:", this.getPath());
    return this;
});

// βœ… Chainable file operations
(async () => {
    file
        .rename("renamed.txt")  // Renames file
        .invokeMethod("logPath") // Logs new file path
        .move("./testFolder/moved") // Moves file to a new folder
        .copy("./backup")  // Creates a copy in the backup folder
        .append("\nMore content added.") // Appends text to the file
        .delete();  // Deletes the file

    console.log("πŸ“„ Compressed File Content:", file.getInfo());
    console.log("πŸ“‘ File Metadata:", file.getMetaInfo());
    console.log("πŸ“‚ Files in directory:", file.list());
})();

πŸ“œ API Reference

This file management system offers multiple operations for handling files and folders.

πŸ“‚ File Operations

MethodDescriptionExample
rename(newName: string)Renames the filefile.rename("newName.txt")
move(destination: string)Moves the file to a new directoryfile.move("./newFolder")
copy(destination: string)Copies the file to a new locationfile.copy("./backup")
delete()Deletes the file permanentlyfile.delete()
writeFile(content: string)Writes new content to the file (overwrites existing content)file.writeFile("Hello, world!")
append(content: string)Appends new content to the filefile.append("\nNew content")

πŸ“ Directory Operations

MethodDescriptionExample
syncExist()Checks if a file or folder existsif (file.syncExist()) {...}
sync()Ensures the directory exists (creates it if missing)file.sync()
list()Lists all files in the directoryconsole.log(file.list())

πŸ“Š File Info & Metadata

MethodDescriptionExample
getInfo()Reads and compresses the entire file contentconsole.log(file.getInfo())
getMetaInfo()Retrieves metadata such as size, creation date, and modification dateconsole.log(file.getMetaInfo())

βš™ Customization & Error Handling

MethodDescriptionExample
errorOnFound = (error) => {...}Custom error handling (e.g., auto-create files)file.errorOnFound = (err) => {...}
addMethod(name, method)Adds a custom chainable methodfile.addMethod("customMethod", function () {...})
invokeMethod(name, ...args)Calls a custom method dynamicallyfile.invokeMethod("customMethod")

πŸ”§ How to Use This Project

  • Install the package
    npm install filemanagementsystemfornode
    
  • Run the script
    npm run start
    
  • Modify settings
    • Change file paths in src/main.ts to test different operations.
    • Modify core functionality in src/Wrapper if necessary.

πŸ“œ License

This project is open-source and free to use.

πŸ’‘ Future Enhancements

We plan to add:

  • πŸ”Ή File encryption support (AES, RSA encryption for file security)
  • πŸ”Ή File versioning (track changes over time)
  • πŸ”Ή Logging & monitoring system (track operations in a log file)

πŸš€ Enjoy simplified file management with powerful chaining!
Feel free to suggest new features or improvements! 🎯

πŸ‘¨β€πŸ’» Author

WhitzScott - Developer of the File Management System.
If you have questions or ideas, feel free to reach out!

Keywords

typescript

FAQs

Package last updated on 02 Mar 2025

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