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

afst

v0.2.1

Published

* node version 8 or higher

Readme

Abstract File System Tree

Define an abstract tree of directories and files with content and create it in one go.

Requirements

  • node version 8 or higher

Installation

$ git clone [email protected]:ViddaDigital/afst.git
$ yarn install

How to use

$ yarn build

Linking afst during development

Change directory to where your cloned afst.

$ yarn afst

Change directory to your local project.

$ yarn link afst

Usage

   let tree: AbstractFileSystemTree = {
      path: '/some/kind/of/path',
      children: [
        {
          type: 'dir',
          name: 'dir1',
          children: [
            {
              type: 'file',
              name: 'file2a.txt',
              content: 'File 2 a content'
            },
            {
              type: 'file',
              name: 'file2b.txt',
              content: 'File 2 b content'
            },
            {
              type: 'dir',
              name: 'dir2c',
              children: [
                {
                  type: 'file',
                  name: 'file3a.txt',
                  content: 'File 3 a content'
                },
                {
                  type: 'file',
                  name: 'file3b.txt',
                  content: 'File 3 b content'
                }
              ]
            }
          ]
        },
        {
          type: 'file',
          name: 'file2.txt',
          content: 'File 2 content'
        }
      ]
   }

  new AFST(tree, { log: true }).write()

This will create these files and directories:

├── dir1
│    ├── file2a.txt
│    ├── file2b.txt
│    └── dir2c
│        ├── file3a.txt
│        └── file3b.txt
└── file2.txt

Builder

You can also use the builder to create the tree like this:

new AFST({path: '/some/kind/of/path'})
  .dir('a', a => a
    .file('c.txt', 'Text content')
    .file('d.md', 'Markdown content')
    .dir('e', e => {
      e.file('f', 'File without extension')
      e.file('g', 'File without extension')
      return e
    })
  )
  .file('.b', 'Some dotfile content')
  .write()

This will create these files and directories:

├── a
│    ├── c.txt
│    ├── d.md
│    └── e
│        ├── f
│        └── g
└── .b

Updating existing file content

To update file content provide a function like so:

new AFST({path: '/some/kind/of/path'})
  .file('c.txt', 'Content always replaces content')
  .file('d.txt', content =>
    content
      .replace("foo", "bar")
      .replace("baz", "baq")
  )
  .write()

If a file exists the content will be read and provided as a string to your function during writing.

Conditional directories and files

new AFST({path: '/some/kind/of/path'})
  .file_if(false, "1.txt", 'This file is not created')
  .file_if(true, "2.txt", 'This file is created')
  .dir_if(true, dir =>
    dir
      .file("a.txt", 'This file is created')
      .file("b.txt", 'This file is created')
  )
  .dir_if(false, dir =>
    dir
      .file("a.txt", 'This file is not created')
      .file("b.txt", 'This file is not created')
  )
  .file_unless(false, "3.txt", 'You can flip the condition with file_unless')
  .dir_unless(false, 'four', 'You can flip the condition with dir_unless')
  .write()