0.1.0 • Published 1 year ago

speedwalk v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

SpeedWalk

Install size

Walk an entire directory. Fast, simple, and asynchronous.

Features

  • Zero dependencies. Small bundle size.
  • Written in TypeScript.
  • Fast and asynchronous. Suitable for large directories. Fastest tree-traversal solution on NPM.
  • Dead simple. Modeled after Golang's filepath.Walk.
  • Modern ESModules support.

Comparisons

Some comparisons between speedwalk and other Node.js libraries that provide tree-traversal solutions.

All tests were conducted on the same large directory. Each result is the average of each library's time to complete the walk with no custom functions provided.

PackageResult
speedwalk6.95ms
walk13826.33ms
@root/walk276.96ms
walker296.05ms

Usage

Import the walk function from the package. To call it, pass in a root directory and a callback function accepting a path and a dirent.

import { walk } from 'speedwalk';

await walk('./', (path, dirent) => {
    console.log('Path:', path);
    console.log('Is a file:', dirent.isFile());

    if (dirent.isDirectory() && dirent.name === 'node_modules') {
        // Tell "walk" to skip the traversal of a certain
        // directory by returning "true" from the callback.
        return true;
    }
});

The function will asynchronously walk through the root directory and all subsequent directories until the entire tree has been traversed.

0.1.0

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago