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

fs-notation

v1.3.1

Published

Standardized dot notation for file streams

Downloads

2

Readme

FS-Notation

As your app grows, we can get some complicated folder structures. Use "fs-notation" to convert your folder structure into a friendly JSON object to do as you will with your files.

The Rundown

It's one thing to have an organized folder structure but then there are times where you just need to gain access to certain files to meet the goal of your awesome app. FsNotation can help bring certain files you created to the front and center of your app with little effort. This script will organize your files based on file extensions in general or you can create your ruleset based on your naming conventions.

Usage

Install it into your app, of course!

npm i fs-notation

Now lets add it to your project for some good use!

//-- slap this package into your project
const fsNotation = require("fs-notation");
//-or-//
import fsn from "fs-notation";
//-Import type for Typescript Use-//
import { FsNotation } from "fs-notation/lib/FsNotation"; //- Typescript Use
let sourceFiles:FsNotation = fsn("/rootDir");

//-- initiate the app with your directory
let sourceFiles = fsn("./_src");

/* vvv Now lets start calling some methods defined below vvv */

The Deets

constructor

Initiates the process of building out your groups and folder tree.

rootPath [STRING] - Path to your root folder groups [ARRAY][OPTIONAL] - Path to your root folder

const fsNotation = require("fs-notation");
let fsn = fsNotation("./_sourceFiles", [
    {
        name: "view files", //- spaces will be converted to underscores
        ext: ".view.html"
    },
    {
        name: "model files",
        ext: ".model.js"
    }
]);
let viewFiles = fsn.getGroups(["view_files", model_files]);
/*
{
    view_files: [
        {
            filename: "index.view.html",
            path: "./rootPath/subPath/index.view.html",
            _isFile_: true
        },
        {
            filename: "button.view.html",
            path: "./rootPath/subPath/button.view.html",
            _isFile_: true
        }
    ],
    model_files: [
        {
            filename: "index.model.js",
            path: "./rootPath/subPath/index.model.js",
            _isFile_: true
        },
        {
            filename: "button.model.js",
            path: "./rootPath/subPath/button.model.js",
            _isFile_: true
        }
    ]
}
*/

tree

Returns your folder tree in JSON format

const fsNotation = require("fs-notation");
let sourceFiles = fsNotation("./rootPath");
let sourceTree = sourceFiles.tree;
/*
{
    subFolder: {
        index_html: {
            filename: "index.html",
            path: "./rootPath/subPath/index.html",
            _isFile_: true
        }
    }
}
*/

getTypes(extension)

Returns an array of files of your choice

extension [STRING][OPTIONAL] - Extension of file(s) you wan't to return. No value will return all files.

const fsn = require("fs-notation");
let sourceFiles = fsn("./_source");

let jsFiles = fsn.getTypes("js"); //-- Return all Javascript files ending with ".js" (EXAMPLE BELOW)

let frontEndFiles = fsn.getTypes(["js","css"]); //-- Return all Javascript (.js) and CSS (.css) files

let allFiles = fsn.getTypes(); //-- Return all files found within the root path

/*
//-- OUTPUT EXAMPLE --//
[
    {
        filename: "formActions.js",
        path: "./rootPath/subPath/formActions.js",
        _isFile_: true
    },
    {
        filename: "btnActions.js",
        path: "./rootPath/subPath/btnActions.js",
        _isFile_: true
    }
]
*/

getGroups(name)

Returns an array of files of your choice

name [STRING][OPTIONAL] - Name of user defined group decared in constructor. No value will return all groups.

const fsn = require("fs-notation");
let sourceFiles = fsn("./_source");

let jsFiles = fsn.getGroups("view_files"); //-- Return all defined "view_files" (EXAMPLE BELOW)

let frontEndFiles = fsn.getGroups(["view_files","model_files"]); //-- Return all "view_files" and "model_files" files

let allFiles = fsn.getGroups(); //-- Return all files found within the root path

/*
//-- OUTPUT EXAMPLE --//
[
    {
        filename: "form.view.html",
        path: "./rootPath/subPath/form.view.html",
        _isFile_: true
    },
    {
        filename: "button.view.html",
        path: "./rootPath/subPath/button.view.html",
        _isFile_: true
    }
]
*/

Log

  • 1.3.1 - Removed debugging consoles
  • 1.3.0 - Updated output to include "_isFile_"
  • 1.2.0 - Typescript Optimization
  • 1.1.1 - Updated a README error
  • 1.1.0 - Cleaned up the Returns
  • 1.0.1 - Meta data updates
  • 1.0.0 - Initial Build
  • 0.1.0 - First Publish