Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enfsaddins-promise

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enfsaddins-promise

Additional methods for node fs module with promises

  • 1.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Travis Status Appveyor status Codacy Badge Donate

NPM

enfsaddins-promise

Additional methods for node fs module with promises

enfs stands for [E]asy [N]ode [fs]

This module is intended to work as a sub-module of enfspatch-promise

Description

This module will add promises to enfsaddins for async methods All async methods will have their name + 'P' (ex: exists => existsP)

Usage

enfsaddins-promise

Valid usage but not the better:

    const fs = require("fs");
    const enfs = require("enfsaddins-promise")(fs);

It's better to use

    const enfs = require("enfspatch-promise");

this will use enfspatch-promise module that implements this module and allows access to all it's methods

Errors

All the methods follows the node culture.

  • Async: Every async method returns an Error in the first callback parameter
  • Sync: Every sync method throws an Error.

Additional Methods

existsp

  • existsP(path)

Change the natural behaviour of fs.exists to the node culture, it will return an error in the first callback parameter. As exists is deprecated if it cease to exist then exists will use (#existStat) instead

    enfs.existsP("/etc/passwd").then(function(itemExists){
        console.log(itemExists ? 'it\'s there' : 'no passwd!');
    });

check: fs.exists

existAccessP

  • existAccessP(path, [mode])

Will use fs.access to check if the item exists in the file system and if the process as access to the item.

    enfs.existAccessP("/etc/passwd").then(function(itemExists){
        console.log(itemExists ? "it\'s there and have access" : "don\'t exist or don\'t have access");
    });

check: fs.access

existStatP

existLStatP

  • existStatP(path)
  • existLStatP(path)

Will use fs.stat to check if the item exists in the file system.

    enfs.existStatP("/etc/passwd").then(function(itemExists){
        console.log(itemExists ? "it\'s there" : "don\'t exist");
    });

check: fs.stat

    enfs.existLStatP("/etc/passwd").then(function(itemExists){
        console.log(itemExists ? "it\'s there" : "don\'t exist");
    });

check: fs.lstat

existFStatP

  • existFStatP(fd)

Will use fs.fstat to check if the item exists in the file system.

    enfs.existFStatP(fs.openSync("/etc/passwd","r")).then(function(itemExists){
        console.log(itemExists ? "it\'s there" : "don\'t exist");
    });

check: fs.fstat

existStatIsDirectoryP

existLStatIsDirectoryP

  • existStatIsDirectoryP(path)
  • existLStatIsDirectoryP(path)

Will use fs.stat or fs.lstat or fs.fstat to check if the item exists in the file system, and if it's a directory. This method is just a shortcut to check if an item exists in the file system and it's type

    enfs.existStatIsDirectoryP("/etc").then(function(isDirectory){
        console.log(isDirectory ? "it's a directory" : "don\'t exist or it's not a directory.");
    });

check: fs.stat fs.lstat fs.fstat

existStatIsFileP

existLStatIsFileP

  • existStatIsFileP(path)
  • existLStatIsFileP(path)

Will use fs.stat or fs.lstat or fs.fstat to check if the item exists in the file system, and if it's a file. This method is just a shortcut to check if an item exists in the file system and it's type

    enfs.existStatIsFileP("/etc/passwd").then(function(isFile){
        console.log(isFile ? "it's a file" : "don\'t exist or it's not a file.");
    });

check: fs.stat fs.lstat fs.fstat

existIsSymlinkP

  • existIsSymlinkP(path)

Will use fs.lstat to check if the item exists in the file system, and if it's a symbolic link. This method is just a shortcut to check if an item exists in the file system and it's type

    enfs.existIsSymlinkP("/etc/symlink").then(function(isSymlink){
        console.log(isSymlink ? "it's a symlink" : "don\'t exist or it's not a symlink.");
    });

check: fs.lstat

License

Creative Commons Attribution 4.0 International License

Copyright (c) 2017 Joao Parreira joaofrparreira@gmail.com GitHub

This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit CCA4.

Keywords

FAQs

Package last updated on 02 Apr 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc