New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

dir-walk

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dir-walk

Walk a directory tree async or non-async

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

dir-walk

Linux Build status Windows Build status Test coverage

Walk a directory tree recursively with different implementations:

  • Sync Breadth-First Traversal
  • Sync Depth-First Traversal
  • Async using callbacks (Node v4)
  • Async using generators (Node v5)
  • Async using promises (Node v6)
  • Async using async/await (Node v8)

Install

$ yarn add dir-walk

Tests

$ yarn test

Examples

const walk = require('dir-walk');

// contents will like {filenames: [list], dirnames: [list], errors: [list]}

walk('/my-dir', function(contents) {
  console.log(contents);
});

// By default sync use Breadth-first Traversal
let contents = walk.sync('/my-dir');

// To use Sync Depth-first Traversal
let contents = walk.sync('/my-dir', {dfs: true});

TODO

  • Add other implementations
  • Promises (Node v4.7.2)
  • Generators (Node v5.11.0)
  • Async/await (Node v8.0.0)
  • Provide option for recursive & non-recursive version
  • Provide option to follow links
  • Check memory for callback-impl for large nested directories due to the merging logic.
  • Put a limit for max recursion to avoid stackoverflow.
  • Ensure the asyncs impls do not exceed max file descriptor limit on Linux.
  • Put a max cap on memory because the results stored in objects.
  • Provide option to skip non regular files like socket, device file, named pipe
  • Check what invalid inode look like
  • Avoid traversing the full file system, like dir = '/' or C://
  • Check different file systems (HFS+, ReFS, NTFS, etc..) handling for
    • Case senstivity & preservation
    • Unicode preservation
    • Hidden files and directories
  • Check support for external drive, USB or network drive
  • Check support of multiple filesystem mounted in the same working tree

License

MIT © Laith Shadeed

Keywords

walk

FAQs

Package last updated on 07 Feb 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