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

walker

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

walker

A simple directory tree walker.

  • 1.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27M
increased by4.93%
Maintainers
1
Weekly downloads
 
Created

What is walker?

The `walker` npm package is a tool designed for efficiently walking (traversing) file trees in a Node.js environment. It allows developers to easily perform operations on file systems, such as listing all files in a directory and its subdirectories, filtering files based on certain criteria, and processing each file individually. This package is particularly useful for tasks that involve bulk file operations, such as building a search index, file analysis, or automated file organization.

What are walker's main functionalities?

File Traversal

This feature allows the user to traverse all files starting from a specified directory. It emits events for each file found, enabling the execution of custom logic such as logging or processing of each file.

const walker = require('walker');
const path = '/path/to/start/directory';

walker(path)
  .on('file', function(file, stat) {
    console.log('Found file: ' + file);
  })
  .on('error', function(err, entry) {
    console.error('Error at: ' + entry + ' - ' + err);
  })
  .on('end', function() {
    console.log('All files have been processed');
  });

Directory Filtering

This feature demonstrates how to filter directories during traversal, allowing the user to skip certain directories (e.g., 'node_modules'). This is useful for focusing on relevant files and improving performance by avoiding unnecessary directories.

const walker = require('walker');
const path = '/path/to/start/directory';

walker(path)
  .filterDir(function(dir, stat) {
    // Only traverse directories that are not named 'node_modules'
    return dir.indexOf('node_modules') === -1;
  })
  .on('file', function(file, stat) {
    console.log('Found file: ' + file);
  });

Other packages similar to walker

Keywords

FAQs

Package last updated on 23 Oct 2021

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