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 🙏

© 2026 – Pkg Stats / Ryan Hefner

file-map

v0.0.1

Published

builds a file tree, given a directory

Readme

File Map

npm tests coverage dependencies

Builds a recursive file tree from a root directory

Note: This project is in early development, and versioning is a little different. Read this for more details.

Why should you care?

Sometimes, you need to recursively read a directory and get back a flat array of files. Other times, you might want to get back a nested structure so you can walk through the different levels. If you are looking for the former, readdirp does a remarkable job of this. This library covers the latter case.

Installation

npm i file-map

Usage

The interface is quite simple, pass it a directory as an argument, and get back a promise with the file map structure. For example:

var file_map = require('file-map');
file_map(__dirname).then(console.log);

If you had a directory structure that looked like this, and passed in the example folder to file-map:

/Users/example
├── some_folder
│   ├── foo.txt
│   └── nested
│       └── bar.txt
└── wow.txt

The structure you'll get back will look something like this:

[{
  type: 'directory',
  path: 'some_folder',
  fullPath: '/Users/example/some_folder',
  stat: [Object], // result of fs.stat
  children: [{
    type: 'file',
    path: 'some_folder/foo.txt'
    fullPath: '/Users/example/some_folder/foo.txt',
    stat: [Object]
  }, {
    type: 'directory',
    path: 'some_folder/nested',
    fullPath: '/Users/example/some_folder/nested',
    stat: [Object],
    children: [{
      type: 'file',
      path: 'some_folder/nested/bar.txt'
      fullPath: '/Users/example/some_folder/nested/bar.txt'
      stat: [Object]
    }]
  }]
}, {
  type: 'file',
  path: 'wow.txt'
  fullPath: '/Users/example/wow.txt',
  stat: [Object]
}]

So overall, each object contains a type (file or directory), path (relative path), fullPath (absolute path), and stat (fs.stat result). Directories also contain an array of children, and utility functions that pull just the files or directories from the children.

Ignores

If there are certain files or folders you want to ignore, you can do this by passing in some additional options.

file_map(__dirname, { ignore_files: 'secret.*', ignore_directories: ['**/wow.txt'] })

The ignore_files and ignore_directories options both take either a string or an array of strings, and they can be minimatch strings. Matches are made against the relative path, so you can include globstars, even though this is a recursive read. So fancy.

FAQs

There is no callback interface, because promises are much more flexible, and with such a simple interface, promises don't make it any more complicated anyway. The promise returned is A+ compliant and decorated with extra utilities from when.js. There is no sync mode because you shouldn't be doing big i/o reads like this synchronously anyway.

License & Contributing