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

enfsaddins

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enfsaddins

Additional methods for node fs module

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by12.5%
Maintainers
1
Weekly downloads
 
Created
Source

Travis Status Appveyor status Codacy Badge Donate

NPM

enfsaddins

Additional methods for node fs module

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

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

Description

This module will change some behaviors of fs module from node such as creating a queue for opening files when limit is reached, catching the error's and proceeding with the process when possible.

  • This module will change the behaviour of:
    • exists
    • existsSync

Usage

enfsaddins

Valid usage but not the better:

    var fs = require("fs");
    var enfs = require("enfsaddins")(fs);

It's better to use

    var enfs = require("enfspatch");

this will use enfspatch 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

exists

  • exists(path, callback)

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

Sync:

  • existsSync(path)
    enfs.exists("/etc/passwd", function(err, itemExists){
        console.log(itemExists ? 'it\'s there' : 'no passwd!');
    });

check: fs.exists

existAccess

  • existAccess(path, [mode], callback)

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

Sync:

  • existAccessSync(path, [mode])
    enfs.existAccess("/etc/passwd", function(err,itemExists){
        console.log(itemExists ? "it\'s there and have access" : "don\'t exist or don\'t have access");
    });

check: fs.access

existStat

existLStat

  • existStat(path,callback)
  • existLStat(path,callback)

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

Sync:

  • existStatSync(path)
  • existLStatSync(path)
    enfs.existStat("/etc/passwd", function(err,itemExists){
        console.log(itemExists ? "it\'s there" : "don\'t exist");
    });

check: fs.stat

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

check: fs.lstat

existFStat

  • existFStat(fd,callback)

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

Sync:

  • existFStatSync(path)
    enfs.existFStat("/etc/passwd", function(err,itemExists){
        console.log(itemExists ? "it\'s there" : "don\'t exist");
    });

check: fs.fstat

existStatIsDirectory

existLStatIsDirectory

existFStatIsDirectory

  • existStatIsDirectory(path,callback)
  • existLStatIsDirectory(path,callback)
  • existFStatIsDirectory(path,callback)

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

Sync:

  • existStatIsDirectorySync(path)
  • existLStatIsDirectorySync(path)
  • existFStatIsDirectorySync(path)
    enfs.existStatIsDirectory("/etc", function(err,isDirectory,stat){
        console.log(isDirectory ? "it's a directory" : "don\'t exist or it's not a directory.");
    });

check: fs.stat fs.lstat fs.fstat

existStatIsFile

existLStatIsFile

existFStatIsFile

  • existStatIsFile(path,callback)
  • existLStatIsFile(path,callback)
  • existFStatIsFile(path,callback)

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

Sync:

  • existStatIsFileSync(path)
  • existLStatIsFileSync(path)
  • existFStatIsFileSync(path)
    enfs.existStatIsFile("/etc/passwd", function(err,isFile,stat){
        console.log(isFile ? "it's a file" : "don\'t exist or it's not a file.");
    });

check: fs.stat fs.lstat fs.fstat

  • existIsSymlink(path,callback)

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

Sync:

  • existIsSymlinkSync(path)
    enfs.existIsSymlink("/etc/symlink", function(err,isSymlink,stat){
        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) 2016 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 11 Apr 2016

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