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

walk-sync

Package Overview
Dependencies
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

walk-sync

Get an array of recursive directory contents

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3M
decreased by-23.75%
Maintainers
3
Weekly downloads
 
Created

What is walk-sync?

The walk-sync npm package is designed to provide a simple and efficient way to recursively list all files and directories within a given directory, similar to the Unix 'find' command. It is particularly useful for tasks involving file system traversal, such as building file trees, indexing project files, or performing batch operations on multiple files.

What are walk-sync's main functionalities?

Basic Directory Listing

This feature allows you to list all files and directories within a specified directory. The result is an array of strings, each representing a path relative to the initial directory.

const walkSync = require('walk-sync');
const paths = walkSync('path/to/directory');
console.log(paths);

Directory Listing with Options

This feature enhances the basic directory listing by allowing you to specify options such as excluding directories from the output or filtering files by glob patterns. This is useful for more targeted file system operations.

const walkSync = require('walk-sync');
const options = { directories: false, globs: ['**/*.js'] };
const paths = walkSync('path/to/directory', options);
console.log(paths);

Directory Listing with Entry Objects

This feature returns detailed information about each file and directory in the form of entry objects, including properties like size and relativePath. This is useful for applications that need more information about file system entries than just their paths.

const walkSync = require('walk-sync');
const options = { directories: true, includeBasePath: true, entries: true };
const entries = walkSync('path/to/directory', options);
entries.forEach(entry => {
  console.log(entry.relativePath, entry.size);
});

Other packages similar to walk-sync

FAQs

Package last updated on 05 Aug 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