npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

recursive-file-walker

v3.1.3

Published

recursively look over all the files and sub directories from a starting directory

Downloads

7

Readme

recursive-file-walker

recursively look over all the files and sub directories from a starting directory

usage

npm i recursive-file-walker

or

npm i -D recursive-file-walker

import fileWalker from "recursive-file-walker";

const response = await fileWalker({
	id: 789,                           // pass an id, if you are using more than one fileWalker function (optional)
  entry: "path/to/start/directory",  // where to start the recursive file walker
  ignoreFiles: ["*.js", "foo/*.js"], // TODO will ignore files (string), or array of file types/paths
	ignoreDirectories: ["bar", "foo"], // TODO will ignore a directory (string), or array of directories
	ignoreDotFiles: true,              // will ignore dotfiles, default:true
  ignoreDotDirectories: true,        // TODO will ignore dotDirectories, default:true 
	readFiles: "modified",             // "true" - all files, "false" - no files, "modified" will only read the file if the contents have been changed, default:false
  flatten: false                    // if true, will flatten the response
  sort: "asc"                        // TODO - sort by depth if flat asc or desc
});

// when finished, array passed with all file and directory details
// will inc. contents if readFile:true or if readFile:"modified" and contents have changed
console.log(response);

example response for a file. contents will be undefined if readFile: false. modified will be true if the contents have changed, or if the file was created since the last walk (since the last time the function was called)

[
  {
    stats: Stats {
      dev: 16777220,
      mode: 33188,
      nlink: 1,
      uid: 501,
      gid: 20,
      rdev: 0,
      blksize: 4096,
      ino: 59344407,
      size: 4214700,
      blocks: 8320,
      atimeMs: 1613435111889.6147,
      mtimeMs: 1613432214420.2336,
      ctimeMs: 1613432214420.2336,
      birthtimeMs: 1613431128666.037,
      atime: 2021-02-16T00:25:11.890Z,
      mtime: 2021-02-15T23:36:54.420Z,
      ctime: 2021-02-15T23:36:54.420Z,
      birthtime: 2021-02-15T23:18:48.666Z
    },
    path: 'test/index.txt',
    name: 'index.txt',
    contents: <Buffer 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 20 61 64 69 70 69 73 69 63 69 6e ... 4214650 more bytes>,
    modified: true,
    depth: 0
  },
  [],  /* ignored directory */
  {},  /* ignored file */
  [    /* sub directory */
    {...},
    {...},
    [
      {...},
      {...},
      {...}
    ],
    {...}
  ]
]