Skip to content
list items in the file system for fs module of node with promises
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.eslintrc
.gitignore
.npmignore
.travis.yml
CHANGELOG.md
LICENSE
Makefile
README.md
appveyor.yml
index.js
package.json

README.md

Build Status AppVeyor status Codacy Badge Donate

NPM

enfslist-promise

Module that add list functionality to node fs module

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

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

Description

This module will add a method that allows the obtaining of the list of items in the file system under one directory and sub-directories.

  • This module will add following methods to node fs module:
    • list
    • listSync
    • listP

Usage

enfslist

    const enfslist = require("enfslist");

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

list

  • list(path, [options], callback)

Obtain the list of items under a directory and sub-directories asynchronously. Each item will be an object containing: {path: pathToItem, stat: itemStat}

[options]:

  • fs (Object): an alternative fs module to use (default will be enfspatch)
  • dereference (Boolean): if true will dereference symlinks listing the items to where it points (default: false)
  • back (Number): What you want to get back (0- an array of objects with path and stats, 1- only the paths, 2- only the stats);
  • stats (Array): What information you want in stats. Ex: js ["isFile", "atime", "size"]
  • ignoreAccessError (Boolean): If true will ignore all files and folder's without access permission (default false)
    enfslist.list("/home", function(err, listOfItems){
        listOfItems.forEach(function(item){
            //do something
        });
    });

listSync

  • listSync(path, [options])

Obtain the list of items under a directory and sub-directories synchronously Each item will be an object containing: {path: pathToItem, stat: itemStat}

[options]:

  • fs (Object): an alternative fs module to use (default will be enfspatch)
  • dereference (Boolean): if true will dereference symlinks listing the items to where it points (default: false)
  • back (Number): What you want to get back (0- an array of objects with path and stats, 1- only the paths, 2- only the stats);
  • stats (Array): What information you want in stats. Ex: js ["isFile", "atime", "size"]
  • ignoreAccessError (Boolean): If true will ignore all files and folder's without access permission (default false)
    const listOfItems = enfslist.listSync("/home");
    listOfItems.forEach(function(item){
        //do something
    });

listP

  • listP(path, [options])

Obtain the list of items under a directory and sub-directories asynchronously. Each item will be an object containing: {path: pathToItem, stat: itemStat}

[options]:

  • fs (Object): an alternative fs module to use (default will be enfspatch)
  • dereference (Boolean): if true will dereference symlinks listing the items to where it points (default: false)
  • back (Number): What you want to get back (0- an array of objects with path and stats, 1- only the paths, 2- only the stats);
  • stats (Array): What information you want in stats. Ex: js ["isFile", "atime", "size"]
  • ignoreAccessError (Boolean): If true will ignore all files and folder's without access permission (default false)
    enfslist.listP("/home").then(function(listOfItems){
        listOfItems.forEach(function(item){
            //do something
        });
    }).catch(function(err){
        console.log("Error occurred: "+err.message);
    });

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 CC-BY-4.0.

You can’t perform that action at this time.