promisefs_2.0

1.0.1 • Public • Published

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

Package Sidebar

Install

npm i promisefs_2.0

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

5.3 kB

Total Files

5

Last publish

Collaborators

  • onlinespawn