1.0.1 • Published 4 years ago

promisefs_2.0 v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

Promise File System

Description

A promise based wrapper around Node.js fs module so that it can be used with async/await or the .then().catch();

require()

const promiseFS = require('promisefs_2.0');

Functions:

  • promiseFS.createFolder(path);

    • Function: Creates a folder on the specified path
    • Parameters:
      • file system path as a String
    • Returns: nothing
  • promiseFS.createFile(path,content);

    • Function: Creates a file on the specified path
    • Parameters:
      • file system path as a String
    • Resturns: nothing
  • promiseFS.deleteFile(path);

    • Function: Deletes file on the specified path
    • Parameters:
      • file system path as a String
    • Returns: nothing
  • promiseFS.deleteFolder(path);

    • Function: Deletes folder on the specified path
    • Parameters:
      • file system path as a String
    • Returns: nothing
  • promiseFS.readFile(path);

    • Function: Returns file contents on the specified path
    • Parameters:
      • file system path as a String
    • Returns: file contents with the default node.js settings
  • promiseFS.readFolder(path);

    • Function: Returns folder contents on the specified path
    • Parameters:
      • file system path as a String
    • Returns: folder contents in an Array of Strings
  • promiseFS.exists(path);

    • Function: Check whether or not the file or folder exists
    • Parameters:
      • file system path as a String
    • Returns: A boolean value of true if exists and false if it does not exist(will also return false if you don't have read and write access to the file/folder)
  • promiseFS.rename(path,newPath);

    • Function: Rename file or folder

    • Parameters:

      • file system path as a String
    • Returns: nothing

Examples:

async/ await example

async function makeAFile(){
  await promiseFS.createFile('./test.txt','Hello World');
}
makeAFile();

.then .catch

promiseFS.readFile('./test.txt').then((data)=>{
    console.log(data.toString());
}).catch((error)=>{
    console.log(error);
});

Hecho en 🇵🇷 por Radamés J. Valentín Reyes